Fix {PDFPageView, PDFThumbnailView}.cancelRendering
to avoid visual artifacts when called directly
Currently these methods are only used from the respective `reset` methods, and from `{BaseViewer, PDFThumbnailViewer}._cancelRendering` which only runs when the active document is closed. This patch changes `{PDFPageView, PDFThumbnailView}.cancelRendering` to *only* cancel any pending rendering operations, and doesn't attempt to reset e.g. the `renderingState`, since that causes visual glitches (duplicated canvases in the viewer) when called directly. Furthermore, unless you "know" what you're doing, the `{PDFPageView, PDFThumbnailView}.reset` methods are what *should* normally be used instead.
This commit is contained in:
parent
1ded729130
commit
599dcf5a44
@ -154,6 +154,7 @@ class PDFPageView {
|
||||
|
||||
reset(keepZoomLayer = false, keepAnnotations = false) {
|
||||
this.cancelRendering(keepAnnotations);
|
||||
this.renderingState = RenderingStates.INITIAL;
|
||||
|
||||
let div = this.div;
|
||||
div.style.width = Math.floor(this.viewport.width) + 'px';
|
||||
@ -258,12 +259,15 @@ class PDFPageView {
|
||||
this.reset(/* keepZoomLayer = */ true, /* keepAnnotations = */ true);
|
||||
}
|
||||
|
||||
/**
|
||||
* PLEASE NOTE: Most likely you want to use the `this.reset()` method,
|
||||
* rather than calling this one directly.
|
||||
*/
|
||||
cancelRendering(keepAnnotations = false) {
|
||||
if (this.paintTask) {
|
||||
this.paintTask.cancel();
|
||||
this.paintTask = null;
|
||||
}
|
||||
this.renderingState = RenderingStates.INITIAL;
|
||||
this.resume = null;
|
||||
|
||||
if (this.textLayer) {
|
||||
|
@ -152,6 +152,7 @@ class PDFThumbnailView {
|
||||
|
||||
reset() {
|
||||
this.cancelRendering();
|
||||
this.renderingState = RenderingStates.INITIAL;
|
||||
|
||||
this.pageWidth = this.viewport.width;
|
||||
this.pageHeight = this.viewport.height;
|
||||
@ -195,12 +196,15 @@ class PDFThumbnailView {
|
||||
this.reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* PLEASE NOTE: Most likely you want to use the `this.reset()` method,
|
||||
* rather than calling this one directly.
|
||||
*/
|
||||
cancelRendering() {
|
||||
if (this.renderTask) {
|
||||
this.renderTask.cancel();
|
||||
this.renderTask = null;
|
||||
}
|
||||
this.renderingState = RenderingStates.INITIAL;
|
||||
this.resume = null;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user