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

Prevent circular references in the /Pages tree

This commit is contained in:
Jonas Jenwald 2020-02-08 17:43:53 +01:00
parent e2b30e9e9c
commit 3c7b7be100
7 changed files with 155 additions and 8 deletions

View file

@ -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");

View file

@ -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;

View file

@ -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(