Bug 1308820 - Make sure to close the print progress dialog if print preview is exited. r?Gijs
MozReview-Commit-ID: 391bf9J2Qcf
--- 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();