From f85f5799711dfb6122170bcc43bbc1c7669ffa38 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 23 Jul 2021 14:14:42 +0200 Subject: [PATCH] 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. --- web/pdf_page_view.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/web/pdf_page_view.js b/web/pdf_page_view.js index 65e7e680e..50ea128e9 100644 --- a/web/pdf_page_view.js +++ b/web/pdf_page_view.js @@ -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; }