From a60bb5f93694ff7f8d3ff2079af8b8ebfe32d760 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 1 Jun 2023 18:46:50 +0200 Subject: [PATCH] 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; } }