mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-28 13:40:17 -10:00
Bug 1636803. Stop using message passing to initiate printing. r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D74574
This commit is contained in:
1 parent
abd97b669f
commit
13563869db
3 files changed
+20
-55
No files matched your search
@@ -108,15 +108,6 @@ class PrintingChild extends ActorChild {
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
case "Printing:Print": {
|
||||
this.print(
|
||||
Services.wm.getOuterWindowWithId(data.windowID),
|
||||
data.simplifiedMode,
|
||||
data.lastUsedPrinterName
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -379,37 +370,6 @@ class PrintingChild extends ActorChild {
|
||||
this.docShell.initOrReusePrintPreviewViewer().exitPrintPreview();
|
||||
}
|
||||
|
||||
print(contentWindow, simplifiedMode, lastUsedPrinterName) {
|
||||
let printSettings = this.getPrintSettings(lastUsedPrinterName);
|
||||
// Set the title so that the print dialog can pick it up and
|
||||
// use it to generate the filename for save-to-PDF.
|
||||
printSettings.title = contentWindow.document.title;
|
||||
|
||||
// If we happen to be on simplified mode, we need to set docURL in order
|
||||
// to generate header/footer content correctly, since simplified tab has
|
||||
// "about:blank" as its URI.
|
||||
if (printSettings && simplifiedMode) {
|
||||
printSettings.docURL = contentWindow.document.baseURI;
|
||||
}
|
||||
|
||||
try {
|
||||
contentWindow
|
||||
.getInterface(Ci.nsIWebBrowserPrint)
|
||||
.print(printSettings, null);
|
||||
} catch (e) {
|
||||
// Pressing cancel is expressed as an NS_ERROR_ABORT return value,
|
||||
// causing an exception to be thrown which we catch here.
|
||||
if (e.result != Cr.NS_ERROR_ABORT) {
|
||||
Cu.reportError(`In Printing:Print:Done handler, got unexpected rv
|
||||
${e.result}.`);
|
||||
this.mm.sendAsyncMessage("Printing:Error", {
|
||||
isPrinting: true,
|
||||
nsresult: e.result,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updatePageCount() {
|
||||
let numPages = this.docShell.initOrReusePrintPreviewViewer()
|
||||
.printPreviewNumPages;
|
||||
|
||||
@@ -31,10 +31,6 @@
|
||||
*
|
||||
* Messages sent:
|
||||
*
|
||||
* Printing:Print
|
||||
* Kick off a print job for a nsIDOMWindow, passing the outer window ID as
|
||||
* windowID.
|
||||
*
|
||||
* Printing:Preview:Enter
|
||||
* This message is sent to put content into print preview mode. We pass
|
||||
* the content window of the browser we're showing the preview of, and
|
||||
@@ -130,11 +126,20 @@ var PrintUtils = {
|
||||
this._logKeyedTelemetry("PRINT_DIALOG_OPENED_COUNT", "FROM_PAGE");
|
||||
}
|
||||
|
||||
topBrowser.messageManager.sendAsyncMessage("Printing:Print", {
|
||||
windowID,
|
||||
simplifiedMode: this._shouldSimplify,
|
||||
lastUsedPrinterName: this._getLastUsedPrinterName(),
|
||||
});
|
||||
let printSettings = this.getPrintSettings();
|
||||
|
||||
// Set the title so that the print dialog can pick it up and
|
||||
// use it to generate the filename for save-to-PDF.
|
||||
printSettings.title = this._originalTitle;
|
||||
|
||||
if (this._shouldSimplify) {
|
||||
// The generated document for simplified print preview has "about:blank"
|
||||
// as its URL. We need to set docURL here so that the print header/footer
|
||||
// can be given the original document's URL.
|
||||
printSettings.docURL = this._originalURL;
|
||||
}
|
||||
|
||||
topBrowser.print(windowID, printSettings);
|
||||
|
||||
if (printPreviewIsOpen) {
|
||||
if (this._shouldSimplify) {
|
||||
@@ -329,6 +334,12 @@ var PrintUtils = {
|
||||
);
|
||||
|
||||
Services.prompt.alert(window, title, msg);
|
||||
|
||||
Services.telemetry.keyedScalarAdd(
|
||||
"printing.error",
|
||||
this._getErrorCodeForNSResult(nsresult),
|
||||
1
|
||||
);
|
||||
},
|
||||
|
||||
receiveMessage(aMessage) {
|
||||
@@ -337,11 +348,6 @@ var PrintUtils = {
|
||||
aMessage.data.nsresult,
|
||||
aMessage.data.isPrinting
|
||||
);
|
||||
Services.telemetry.keyedScalarAdd(
|
||||
"printing.error",
|
||||
this._getErrorCodeForNSResult(aMessage.data.nsresult),
|
||||
1
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
@@ -559,7 +559,6 @@ let LEGACY_ACTORS = {
|
||||
"Printing:Preview:Exit",
|
||||
"Printing:Preview:Navigate",
|
||||
"Printing:Preview:ParseDocument",
|
||||
"Printing:Print",
|
||||
],
|
||||
},
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user