From af8df207bb04687b746833c93cb71342362a4d66 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 1 Jun 2023 17:44:14 +0200 Subject: [PATCH 1/2] Don't dispatch "pagerendered"-events on the *temporary* CSS-only zooming done when `drawingDelay` is used (PR 15812 follow-up) We shouldn't dispatch a "pagerendered"-event when doing *temporary* CSS-only zooming, but simply wait until the actual rendering is done. While I don't believe that this regression has caused any actual bugs, dispatching *duplicate* events is nonetheless inconsistent and should be fixed. --- web/pdf_page_view.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/web/pdf_page_view.js b/web/pdf_page_view.js index 234f71ba8..47d6c39d7 100644 --- a/web/pdf_page_view.js +++ b/web/pdf_page_view.js @@ -616,6 +616,11 @@ class PDFPageView { hideTextLayer: postponeDrawing, }); + if (postponeDrawing) { + // The "pagerendered"-event will be dispatched once the actual + // rendering is done, hence don't dispatch it here as well. + return; + } this.eventBus.dispatch("pagerendered", { source: this, pageNumber: this.id, From a60bb5f93694ff7f8d3ff2079af8b8ebfe32d760 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 1 Jun 2023 18:46:50 +0200 Subject: [PATCH 2/2] Don't use partially rendered pages to generate thumbnails when `drawingDelay` is used (PR 15812 follow-up) While it's slightly difficult to trigger in practice, unless the `defaultZoomDelay`-value is increased, it's currently possible to generate thumbnails from *partially* rendered pages when doing *temporary* CSS-only zooming. --- web/pdf_page_view.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/web/pdf_page_view.js b/web/pdf_page_view.js index 47d6c39d7..e5f1e7eb0 100644 --- a/web/pdf_page_view.js +++ b/web/pdf_page_view.js @@ -125,6 +125,7 @@ class PDFPageView { #textLayerMode = TextLayerMode.ENABLE; #useThumbnailCanvas = { + directDrawing: true, initialOptionalContent: true, regularAnnotations: true, }; @@ -552,6 +553,7 @@ class PDFPageView { optionalContentConfig.hasInitialVisibility; }); } + this.#useThumbnailCanvas.directDrawing = true; const totalRotation = (this.rotation + this.pdfPageRotate) % 360; this.viewport = this.viewport.clone({ @@ -605,6 +607,9 @@ class PDFPageView { // the rendering state to INITIAL, hence the next call to // PDFViewer.update() will trigger a redraw (if it's mandatory). this.renderingState = RenderingStates.FINISHED; + // Ensure that the thumbnails won't become partially (or fully) blank, + // if the sidebar is opened before the actual rendering is done. + this.#useThumbnailCanvas.directDrawing = false; } this.cssTransform({ @@ -1033,9 +1038,11 @@ class PDFPageView { * @ignore */ get thumbnailCanvas() { - const { initialOptionalContent, regularAnnotations } = + const { directDrawing, initialOptionalContent, regularAnnotations } = this.#useThumbnailCanvas; - return initialOptionalContent && regularAnnotations ? this.canvas : null; + return directDrawing && initialOptionalContent && regularAnnotations + ? this.canvas + : null; } }