Skip to content

Commit

Permalink
Reduce unnecessary duplication when cancelling annotationLayer/`xfa…
Browse files Browse the repository at this point in the history
…Layer` 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.
  • Loading branch information
Snuffleupagus committed Jul 23, 2021
1 parent d22ffbb commit f85f579
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions web/pdf_page_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit f85f579

Please sign in to comment.