Reduce unnecessary duplication when cancelling annotationLayer/xfaLayer rendering

There's no good reason, as far as I can tell, to have `PDFPageView.reset` attempt to cancel `annotationLayer`/`xfaLayer` rendering in one special-case (this is mostly a leftover from older code). Previously cancelling was moved into the separate `PDFPageView.cancelRendering`-method, and by slightly tweaking the conditions there we're able to remove a bit of now unnecessary code from the `PDFPageView.reset`-method.
This commit is contained in:
Jonas Jenwald 2021-07-23 14:14:42 +02:00
parent d22ffbbc0a
commit f85f579971

View File

@ -240,18 +240,11 @@ class PDFPageView {
// Hide the annotation layer until all elements are resized
// so they are not displayed on the already resized page.
this.annotationLayer.hide();
} else if (this.annotationLayer) {
this.annotationLayer.cancel();
this.annotationLayer = null;
}
if (xfaLayerNode) {
// Hide the XFA layer until all elements are resized
// so they are not displayed on the already resized page.
this.xfaLayer.hide();
} else if (this.xfaLayer) {
this.xfaLayer.cancel();
this.xfaLayer = null;
}
if (!zoomLayerNode) {
@ -374,11 +367,14 @@ class PDFPageView {
this.textLayer.cancel();
this.textLayer = null;
}
if (!keepAnnotationLayer && this.annotationLayer) {
if (
this.annotationLayer &&
(!keepAnnotationLayer || !this.annotationLayer.div)
) {
this.annotationLayer.cancel();
this.annotationLayer = null;
}
if (!keepXfaLayer && this.xfaLayer) {
if (this.xfaLayer && (!keepXfaLayer || !this.xfaLayer.div)) {
this.xfaLayer.cancel();
this.xfaLayer = null;
}