From e07cb8638e8a441d06c8d21eba518c25ca504bbf Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 8 Mar 2017 17:29:50 +0100 Subject: [PATCH 1/2] Get rid of `element.removeChild(element.firstChild)` usage (bug 1345253) Instead of just upstreaming the changes from [bug 1345253](https://bugzilla.mozilla.org/show_bug.cgi?id=1345253) as-is, it seemed better to simply get rid of the loops altogether and use the same approach as in `PDFViewer`/`PDFThumbnailViewer`. --- web/pdf_attachment_viewer.js | 6 ++---- web/pdf_outline_viewer.js | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/web/pdf_attachment_viewer.js b/web/pdf_attachment_viewer.js index 4b3e16f28..ad05b0f3a 100644 --- a/web/pdf_attachment_viewer.js +++ b/web/pdf_attachment_viewer.js @@ -61,10 +61,8 @@ var PDFAttachmentViewer = (function PDFAttachmentViewerClosure() { reset: function PDFAttachmentViewer_reset(keepRenderedCapability) { this.attachments = null; - var container = this.container; - while (container.firstChild) { - container.removeChild(container.firstChild); - } + // Remove the attachments from the DOM. + this.container.textContent = ''; if (!keepRenderedCapability) { // NOTE: The *only* situation in which the `_renderedCapability` should diff --git a/web/pdf_outline_viewer.js b/web/pdf_outline_viewer.js index 84f9c28c1..5b656ba69 100644 --- a/web/pdf_outline_viewer.js +++ b/web/pdf_outline_viewer.js @@ -63,10 +63,8 @@ var PDFOutlineViewer = (function PDFOutlineViewerClosure() { this.outline = null; this.lastToggleIsShow = true; - var container = this.container; - while (container.firstChild) { - container.removeChild(container.firstChild); - } + // Remove the outline from the DOM. + this.container.textContent = ''; }, /** From 468ed1b9a1b13d22601a316236fa23c726c82865 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 8 Mar 2017 17:41:11 +0100 Subject: [PATCH 2/2] Ensure that the `outlineWithDeepNesting` CSS class is removed when resetting `PDFOutlineViewer`, to prevent incorrect alignment if a new document is opened --- web/pdf_outline_viewer.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/web/pdf_outline_viewer.js b/web/pdf_outline_viewer.js index 5b656ba69..0d080bdc0 100644 --- a/web/pdf_outline_viewer.js +++ b/web/pdf_outline_viewer.js @@ -65,6 +65,9 @@ var PDFOutlineViewer = (function PDFOutlineViewerClosure() { // Remove the outline from the DOM. this.container.textContent = ''; + // Ensure that the left (right in RTL locales) margin is always reset, + // to prevent incorrect outline alignment if a new document is opened. + this.container.classList.remove('outlineWithDeepNesting'); }, /**