Bug 1308820 - Make sure to close the print progress dialog if print preview is exited. r=Gijs, a=gchang
authorMike Conley <mconley@mozilla.com>
Mon, 01 May 2017 12:53:31 -0400
changeset 396195 cabb7ee3222b458bbe09a0e4204b2b569df3e163
parent 396194 3d786fe34df613fbbd42c7f7542651bddd5aac58
child 396196 f50c53dd88a2662cff13d53442ffeccf189b2da0
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, gchang
bugs1308820
milestone54.0
Bug 1308820 - Make sure to close the print progress dialog if print preview is exited. r=Gijs, a=gchang 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();