[AnnotationEditorLayerBuilder] Inline the destroy code in the cancel method

It doesn't seem necessary to have a *separate* `destroy` method given that the `cancel` method always invokes it unconditionally.
In the `PDFPageView.reset` method we currently attempt to call `destroy` directly, however that'll never actually happen since either:
 - We're keeping the annotationEditorLayer, in which case we're just hiding the layer and nothing more (and the relevant branch is never entered).
 - We're removing the annotationEditorLayer, in which case the `PDFPageView.cancelRendering` method has already cancelled *and* nulled it (and there's thus nothing left to `destroy` here).

*Please note:* Hopefully I'm not overlooking something obvious here, since both reading through the code *and* also adding `console.log(this.annotationEditorLayer);` [before this line](9d4aadbf7a/web/pdf_page_view.js (L438)) suggests that it's indeed unnecessary.
This commit is contained in:
Jonas Jenwald 2022-12-09 23:24:18 +01:00
parent 9d4aadbf7a
commit bed1a1baa1
2 changed files with 7 additions and 14 deletions

View File

@ -98,7 +98,13 @@ class AnnotationEditorLayerBuilder {
cancel() { cancel() {
this._cancelled = true; this._cancelled = true;
this.destroy();
if (!this.div) {
return;
}
this.pageDiv = null;
this.annotationEditorLayer.destroy();
this.div.remove();
} }
hide() { hide() {
@ -114,15 +120,6 @@ class AnnotationEditorLayerBuilder {
} }
this.div.hidden = false; this.div.hidden = false;
} }
destroy() {
if (!this.div) {
return;
}
this.pageDiv = null;
this.annotationEditorLayer.destroy();
this.div.remove();
}
} }
export { AnnotationEditorLayerBuilder }; export { AnnotationEditorLayerBuilder };

View File

@ -431,18 +431,14 @@ class PDFPageView {
// so they are not displayed on the already resized page. // so they are not displayed on the already resized page.
this.annotationLayer.hide(); this.annotationLayer.hide();
} }
if (annotationEditorLayerNode) { if (annotationEditorLayerNode) {
this.annotationEditorLayer.hide(); this.annotationEditorLayer.hide();
} else {
this.annotationEditorLayer?.destroy();
} }
if (xfaLayerNode) { if (xfaLayerNode) {
// Hide the XFA layer until all elements are resized // Hide the XFA layer until all elements are resized
// so they are not displayed on the already resized page. // so they are not displayed on the already resized page.
this.xfaLayer.hide(); this.xfaLayer.hide();
} }
if (textLayerNode) { if (textLayerNode) {
this.textLayer.hide(); this.textLayer.hide();
} }