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.
This commit is contained in:
Jonas Jenwald 2023-06-01 18:46:50 +02:00
parent af8df207bb
commit a60bb5f936

View File

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