Bug 1308820 - Make sure to close the print progress dialog if print preview is exited. r?Gijs draft
authorMike Conley <mconley@mozilla.com>
Mon, 01 May 2017 12:53:31 -0400
changeset 571406 85fc4339937c6d986a98244be47980cfcf475eed
parent 570886 57b37213d81150642f5139764e7044b07b9dccc3
child 626749 8cc08b29f54a8c2490612772cf787a9450d935fc
push id56776
push usermconley@mozilla.com
push dateTue, 02 May 2017 15:05:30 +0000
reviewersGijs
bugs1308820
milestone55.0a1
Bug 1308820 - Make sure to close the print progress dialog if print preview is exited. r?Gijs MozReview-Commit-ID: 391bf9J2Qcf
toolkit/components/printing/content/printUtils.js
--- a/toolkit/components/printing/content/printUtils.js
+++ b/toolkit/components/printing/content/printUtils.js
@@ -220,20 +220,17 @@ var PrintUtils = {
       // issues in bug 267422.
       // We use the print preview browser as the source browser to avoid
       // re-initializing print preview with a document that might now have changed.
       this._sourceBrowser = this._listener.getPrintPreviewBrowser();
       this._sourceBrowser.collapsed = true;
 
       // If the user transits too quickly within preview and we have a pending
       // progress dialog, we will close it before opening a new one.
-      if (this._webProgressPP && this._webProgressPP.value) {
-        this._webProgressPP.value.onStateChange(null, null,
-          Components.interfaces.nsIWebProgressListener.STATE_STOP, 0);
-      }
+      this.ensureProgressDialogClosed();
     }
 
     this._webProgressPP = {};
     let ppParams        = {};
     let notifyOnOpen    = {};
     let printSettings   = this.getPrintSettings();
     // Here we get the PrintingPromptService so we can display the PP Progress from script
     // For the browser implemented via XUL with the PP toolbar we cannot let it be
@@ -652,16 +649,18 @@ var PrintUtils = {
     if (gFocusedElement)
       fm.setFocus(gFocusedElement, fm.FLAG_NOSCROLL);
     else
       this._sourceBrowser.focus();
     gFocusedElement = null;
 
     this.setSimplifiedMode(false);
 
+    this.ensureProgressDialogClosed();
+
     this._listener.onExit();
   },
 
   logTelemetry(ID) {
     let histogram = Services.telemetry.getHistogramById(ID);
     histogram.add(true);
   },
 
@@ -692,12 +691,23 @@ var PrintUtils = {
         printPreviewTB.print();
       }
     }
     // cancel shortkeys
     if (isModif) {
       aEvent.preventDefault();
       aEvent.stopPropagation();
     }
-  }
+  },
+
+  /**
+   * If there's a printing or print preview progress dialog displayed, force
+   * it to close now.
+   */
+  ensureProgressDialogClosed() {
+    if (this._webProgressPP && this._webProgressPP.value) {
+      this._webProgressPP.value.onStateChange(null, null,
+        Components.interfaces.nsIWebProgressListener.STATE_STOP, 0);
+    }
+  },
 }
 
 PrintUtils.init();