1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Don't re-create the structTreeLayer on zooming and rotation

Compared to the recent PR 15722 for the `textLayer` this one should be a (comparatively) much a smaller win overall, since most documents don't have any structTree-data and the required parsing should be cheaper. However, it seems to me that it cannot hurt to improve this nonetheless.

Note that by moving the `structTreeLayer` initialization we remove the need for the "textlayerrendered" event listener, which thus simplifies the code a little bit.

Also, removes the API-caching of the structTree-data since this was basically done to offset the lack of caching in the viewer.
This commit is contained in:
Jonas Jenwald 2022-12-04 00:27:44 +01:00
parent cd72818438
commit da0e6bc590
3 changed files with 43 additions and 42 deletions

View file

@ -1623,9 +1623,7 @@ class PDFPageProxy {
* or `null` when no structure tree is present for the current page.
*/
getStructTree() {
return (this._structTreePromise ||= this._transport.getStructTree(
this._pageIndex
));
return this._transport.getStructTree(this._pageIndex);
}
/**
@ -1659,7 +1657,6 @@ class PDFPageProxy {
this._bitmaps.clear();
this._annotationPromises.clear();
this._jsActionsPromise = null;
this._structTreePromise = null;
this.pendingCleanup = false;
return Promise.all(waitOn);
}
@ -1694,7 +1691,6 @@ class PDFPageProxy {
this.objs.clear();
this._annotationPromises.clear();
this._jsActionsPromise = null;
this._structTreePromise = null;
if (resetStats && this._stats) {
this._stats = new StatTimer();
}