mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Merge pull request #11577 from Snuffleupagus/Pages-tree-refs
Prevent circular references in the /Pages tree
This commit is contained in:
commit
e1586016c5
7 changed files with 155 additions and 8 deletions
|
@ -403,16 +403,20 @@ class PDFPageView {
|
|||
console.error("Must be in new state before drawing");
|
||||
this.reset(); // Ensure that we reset all state to prevent issues.
|
||||
}
|
||||
const { div, pdfPage } = this;
|
||||
|
||||
if (!this.pdfPage) {
|
||||
if (!pdfPage) {
|
||||
this.renderingState = RenderingStates.FINISHED;
|
||||
return Promise.reject(new Error("Page is not loaded"));
|
||||
|
||||
if (this.loadingIconDiv) {
|
||||
div.removeChild(this.loadingIconDiv);
|
||||
delete this.loadingIconDiv;
|
||||
}
|
||||
return Promise.reject(new Error("pdfPage is not loaded"));
|
||||
}
|
||||
|
||||
this.renderingState = RenderingStates.RUNNING;
|
||||
|
||||
const pdfPage = this.pdfPage;
|
||||
const div = this.div;
|
||||
// Wrap the canvas so that if it has a CSS transform for high DPI the
|
||||
// overflow will be hidden in Firefox.
|
||||
const canvasWrapper = document.createElement("div");
|
||||
|
|
|
@ -164,9 +164,14 @@ class PDFRenderingQueue {
|
|||
break;
|
||||
case RenderingStates.INITIAL:
|
||||
this.highestPriorityPage = view.renderingId;
|
||||
view.draw().finally(() => {
|
||||
this.renderHighestPriority();
|
||||
});
|
||||
view
|
||||
.draw()
|
||||
.finally(() => {
|
||||
this.renderHighestPriority();
|
||||
})
|
||||
.catch(reason => {
|
||||
console.error(`renderView: "${reason}"`);
|
||||
});
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -295,6 +295,13 @@ class PDFThumbnailView {
|
|||
console.error("Must be in new state before drawing");
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
const { pdfPage } = this;
|
||||
|
||||
if (!pdfPage) {
|
||||
this.renderingState = RenderingStates.FINISHED;
|
||||
return Promise.reject(new Error("pdfPage is not loaded"));
|
||||
}
|
||||
|
||||
this.renderingState = RenderingStates.RUNNING;
|
||||
|
||||
const renderCapability = createPromiseCapability();
|
||||
|
@ -339,7 +346,7 @@ class PDFThumbnailView {
|
|||
canvasContext: ctx,
|
||||
viewport: drawViewport,
|
||||
};
|
||||
const renderTask = (this.renderTask = this.pdfPage.render(renderContext));
|
||||
const renderTask = (this.renderTask = pdfPage.render(renderContext));
|
||||
renderTask.onContinue = renderContinueCallback;
|
||||
|
||||
renderTask.promise.then(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue