mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset 4e5999f39bb7 (bug 1082575) for bc1 orange on a CLOSED TREE
This commit is contained in:
parent
6a3f45dd69
commit
7b557e6569
@ -28,7 +28,7 @@
|
|||||||
oncommand="MailIntegration.sendLinkForWindow(window.content);"/>
|
oncommand="MailIntegration.sendLinkForWindow(window.content);"/>
|
||||||
|
|
||||||
<command id="cmd_pageSetup" oncommand="PrintUtils.showPageSetup();"/>
|
<command id="cmd_pageSetup" oncommand="PrintUtils.showPageSetup();"/>
|
||||||
<command id="cmd_print" oncommand="PrintUtils.print(window.gBrowser.selectedBrowser.contentWindowAsCPOW, window.gBrowser.selectedBrowser);"/>
|
<command id="cmd_print" oncommand="PrintUtils.print();"/>
|
||||||
<command id="cmd_printPreview" oncommand="PrintUtils.printPreview(PrintPreviewListener);"/>
|
<command id="cmd_printPreview" oncommand="PrintUtils.printPreview(PrintPreviewListener);"/>
|
||||||
<command id="cmd_close" oncommand="BrowserCloseTabOrWindow()"/>
|
<command id="cmd_close" oncommand="BrowserCloseTabOrWindow()"/>
|
||||||
<command id="cmd_closeWindow" oncommand="BrowserTryToCloseWindow()"/>
|
<command id="cmd_closeWindow" oncommand="BrowserTryToCloseWindow()"/>
|
||||||
|
@ -1663,8 +1663,7 @@ function HandleAppCommandEvent(evt) {
|
|||||||
BrowserOpenFileWindow();
|
BrowserOpenFileWindow();
|
||||||
break;
|
break;
|
||||||
case "Print":
|
case "Print":
|
||||||
PrintUtils.print(gBrowser.selectedBrowser.contentWindowAsCPOW,
|
PrintUtils.print();
|
||||||
gBrowser.selectedBrowser);
|
|
||||||
break;
|
break;
|
||||||
case "Save":
|
case "Save":
|
||||||
saveDocument(window.content.document);
|
saveDocument(window.content.document);
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
<content>
|
<content>
|
||||||
<xul:button label="&print.label;" accesskey="&print.accesskey;"
|
<xul:button label="&print.label;" accesskey="&print.accesskey;"
|
||||||
oncommand="this.parentNode.print();" icon="print"/>
|
oncommand="PrintUtils.print();" icon="print"/>
|
||||||
|
|
||||||
<xul:button label="&pageSetup.label;" accesskey="&pageSetup.accesskey;"
|
<xul:button label="&pageSetup.label;" accesskey="&pageSetup.accesskey;"
|
||||||
oncommand="this.parentNode.doPageSetup();"/>
|
oncommand="this.parentNode.doPageSetup();"/>
|
||||||
@ -93,7 +93,7 @@
|
|||||||
<xul:data value="&customPrompt.title;"/>
|
<xul:data value="&customPrompt.title;"/>
|
||||||
</content>
|
</content>
|
||||||
|
|
||||||
<implementation implements="nsIMessageListener">
|
<implementation>
|
||||||
<field name="mPrintButton">
|
<field name="mPrintButton">
|
||||||
document.getAnonymousNodes(this)[0]
|
document.getAnonymousNodes(this)[0]
|
||||||
</field>
|
</field>
|
||||||
@ -125,24 +125,16 @@
|
|||||||
</field>
|
</field>
|
||||||
<field name="mWebProgress">
|
<field name="mWebProgress">
|
||||||
</field>
|
</field>
|
||||||
<field name="mPPBrowser">
|
|
||||||
null
|
<constructor>
|
||||||
</field>
|
<![CDATA[
|
||||||
<field name="mMessageManager">
|
var print = PrintUtils.getPrintPreview();
|
||||||
null
|
this.mTotalPages.value = print.printPreviewNumPages;
|
||||||
</field>
|
this.mPageTextBox.max = print.printPreviewNumPages;
|
||||||
|
|
||||||
<method name="initialize">
|
this.updateToolbar();
|
||||||
<parameter name="aPPBrowser"/>
|
]]>
|
||||||
<body>
|
</constructor>
|
||||||
<![CDATA[
|
|
||||||
this.mPPBrowser = aPPBrowser;
|
|
||||||
this.mMessageManager = aPPBrowser.messageManager;
|
|
||||||
this.mMessageManager.addMessageListener("Printing:Preview:UpdatePageCount", this);
|
|
||||||
this.updateToolbar();
|
|
||||||
]]>
|
|
||||||
</body>
|
|
||||||
</method>
|
|
||||||
|
|
||||||
<method name="doPageSetup">
|
<method name="doPageSetup">
|
||||||
<body>
|
<body>
|
||||||
@ -164,47 +156,38 @@
|
|||||||
<parameter name="aPageNum"/>
|
<parameter name="aPageNum"/>
|
||||||
<parameter name="aHomeOrEnd"/>
|
<parameter name="aHomeOrEnd"/>
|
||||||
<body>
|
<body>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
const nsIWebBrowserPrint = Components.interfaces.nsIWebBrowserPrint;
|
var print = PrintUtils.getPrintPreview();
|
||||||
let navType, pageNum;
|
|
||||||
|
|
||||||
// we use only one of aHomeOrEnd, aDirection, or aPageNum
|
// we use only one of aHomeOrEnd, aDirection, or aPageNum
|
||||||
if (aHomeOrEnd) {
|
if (aHomeOrEnd)
|
||||||
// We're going to either the very first page ("home"), or the
|
{
|
||||||
// very last page ("end").
|
var homeOrEnd;
|
||||||
if (aHomeOrEnd == "home") {
|
if (aHomeOrEnd == "home")
|
||||||
navType = nsIWebBrowserPrint.PRINTPREVIEW_HOME;
|
{
|
||||||
this.mPageTextBox.value = 1;
|
homeOrEnd = print.PRINTPREVIEW_HOME;
|
||||||
} else {
|
this.mPageTextBox.value = 1;
|
||||||
navType = nsIWebBrowserPrint.PRINTPREVIEW_END;
|
|
||||||
this.mPageTextBox.value = this.mPageTextBox.max;
|
|
||||||
}
|
}
|
||||||
pageNum = 0;
|
else
|
||||||
} else if (aDirection) {
|
{
|
||||||
// aDirection is either +1 or -1, and allows us to increment
|
homeOrEnd = print.PRINTPREVIEW_END;
|
||||||
// or decrement our currently viewed page.
|
this.mPageTextBox.value = print.printPreviewNumPages;
|
||||||
this.mPageTextBox.valueNumber += aDirection;
|
}
|
||||||
navType = nsIWebBrowserPrint.PRINTPREVIEW_GOTO_PAGENUM;
|
|
||||||
pageNum = this.mPageTextBox.value; // TODO: back to valueNumber?
|
print.printPreviewNavigate(homeOrEnd, 0);
|
||||||
} else {
|
}
|
||||||
// We're going to a specific page (aPageNum)
|
else if (aDirection)
|
||||||
navType = nsIWebBrowserPrint.PRINTPREVIEW_GOTO_PAGENUM;
|
{
|
||||||
pageNum = aPageNum;
|
this.mPageTextBox.valueNumber += aDirection;
|
||||||
|
print.printPreviewNavigate(
|
||||||
|
print.PRINTPREVIEW_GOTO_PAGENUM,
|
||||||
|
this.mPageTextBox.valueNumber);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print.printPreviewNavigate(
|
||||||
|
print.PRINTPREVIEW_GOTO_PAGENUM, aPageNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mMessageManager.sendAsyncMessage("Printing:Preview:Navigate", {
|
|
||||||
navType: navType,
|
|
||||||
pageNum: pageNum,
|
|
||||||
});
|
|
||||||
]]>
|
|
||||||
</body>
|
|
||||||
</method>
|
|
||||||
|
|
||||||
<method name="print">
|
|
||||||
<body>
|
|
||||||
<![CDATA[
|
|
||||||
let contentWindow = this.mPPBrowser.contentWindowAsCPOW;
|
|
||||||
PrintUtils.print(contentWindow, this.mPPBrowser);
|
|
||||||
]]>
|
]]>
|
||||||
</body>
|
</body>
|
||||||
</method>
|
</method>
|
||||||
@ -307,6 +290,7 @@
|
|||||||
<method name="updateToolbar">
|
<method name="updateToolbar">
|
||||||
<body>
|
<body>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
|
var print = PrintUtils.getPrintPreview();
|
||||||
var settings = PrintUtils.getPrintSettings();
|
var settings = PrintUtils.getPrintSettings();
|
||||||
|
|
||||||
var isPortrait = settings.orientation == Components.interfaces.nsIPrintSettings.kPortraitOrientation;
|
var isPortrait = settings.orientation == Components.interfaces.nsIPrintSettings.kPortraitOrientation;
|
||||||
@ -320,9 +304,9 @@
|
|||||||
this.setScaleCombobox(settings.scaling);
|
this.setScaleCombobox(settings.scaling);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.mTotalPages.value = print.printPreviewNumPages;
|
||||||
|
this.mPageTextBox.max = print.printPreviewNumPages;
|
||||||
this.mPageTextBox.value = 1;
|
this.mPageTextBox.value = 1;
|
||||||
|
|
||||||
this.mMessageManager.sendAsyncMessage("Printing:Preview:UpdatePageCount");
|
|
||||||
]]>
|
]]>
|
||||||
</body>
|
</body>
|
||||||
</method>
|
</method>
|
||||||
@ -336,20 +320,6 @@
|
|||||||
PSSVC.savePrintSettingsToPrefs(settings, true, flags);
|
PSSVC.savePrintSettingsToPrefs(settings, true, flags);
|
||||||
]]></body>
|
]]></body>
|
||||||
</method>
|
</method>
|
||||||
|
|
||||||
<!-- nsIMessageListener -->
|
|
||||||
<method name="receiveMessage">
|
|
||||||
<parameter name="message"/>
|
|
||||||
<body>
|
|
||||||
<![CDATA[
|
|
||||||
if (message.name == "Printing:Preview:UpdatePageCount") {
|
|
||||||
let numPages = message.data.numPages;
|
|
||||||
this.mTotalPages.value = numPages;
|
|
||||||
this.mPageTextBox.max = numPages;
|
|
||||||
}
|
|
||||||
]]>
|
|
||||||
</body>
|
|
||||||
</method>
|
|
||||||
</implementation>
|
</implementation>
|
||||||
</binding>
|
</binding>
|
||||||
|
|
||||||
|
@ -1,93 +1,29 @@
|
|||||||
|
|
||||||
// -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*-
|
// -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*-
|
||||||
|
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
/**
|
|
||||||
* PrintUtils is a utility for front-end code to trigger common print
|
|
||||||
* operations (printing, show print preview, show page settings).
|
|
||||||
*
|
|
||||||
* Unfortunately, likely due to inconsistencies in how different operating
|
|
||||||
* systems do printing natively, our XPCOM-level printing interfaces
|
|
||||||
* are a bit confusing and the method by which we do something basic
|
|
||||||
* like printing a page is quite circuitous.
|
|
||||||
*
|
|
||||||
* To compound that, we need to support remote browsers, and that means
|
|
||||||
* kicking off the print jobs in the content process. This means we send
|
|
||||||
* messages back and forth to that process. browser-content.js contains
|
|
||||||
* the object that listens and responds to the messages that PrintUtils
|
|
||||||
* sends.
|
|
||||||
*
|
|
||||||
* PrintUtils sends messages at different points in its implementation, but
|
|
||||||
* their documentation is consolidated here for ease-of-access.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Messages sent:
|
|
||||||
*
|
|
||||||
* Printing:Print
|
|
||||||
* This message is sent to kick off a print job for a particular content
|
|
||||||
* window (which is passed along with the message). We also pass print
|
|
||||||
* settings with this message - though bug 1088070 will have us gather
|
|
||||||
* those settings from the content process instead.
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
* the target of the message is the browser that we'll be showing the
|
|
||||||
* preview in. We also pass print settings in this message, but
|
|
||||||
* bug 1088070 will have us gather those settings from the content process
|
|
||||||
* instead.
|
|
||||||
*
|
|
||||||
* Printing:Preview:Exit
|
|
||||||
* This message is sent to take content out of print preview mode.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Messages Received
|
|
||||||
*
|
|
||||||
* Printing:Preview:Entered
|
|
||||||
* This message is sent by the content process once it has completed
|
|
||||||
* putting the content into print preview mode. We must wait for that to
|
|
||||||
* to complete before switching the chrome UI to print preview mode,
|
|
||||||
* otherwise we have layout issues.
|
|
||||||
*
|
|
||||||
* Printing:Preview:StateChange, Printing:Preview:ProgressChange
|
|
||||||
* Due to a timing issue resulting in a main-process crash, we have to
|
|
||||||
* manually open the progress dialog for print preview. The progress
|
|
||||||
* dialog is opened here in PrintUtils, and then we listen for update
|
|
||||||
* messages from the child. Bug 1088061 has been filed to investigate
|
|
||||||
* other solutions.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
var gPrintSettingsAreGlobal = false;
|
var gPrintSettingsAreGlobal = false;
|
||||||
var gSavePrintSettings = false;
|
var gSavePrintSettings = false;
|
||||||
var gFocusedElement = null;
|
var gFocusedElement = null;
|
||||||
|
|
||||||
var PrintUtils = {
|
var PrintUtils = {
|
||||||
bailOut: function () {
|
bailOut: function () {
|
||||||
let pref = Components.classes["@mozilla.org/preferences-service;1"]
|
let remote = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||||
.getService(Components.interfaces.nsIPrefBranch);
|
.getInterface(Components.interfaces.nsIWebNavigation)
|
||||||
let allow_for_testing = false;
|
.QueryInterface(Components.interfaces.nsILoadContext)
|
||||||
try {
|
.useRemoteTabs;
|
||||||
allow_for_testing = pref.getBoolPref("print.enable_e10s_testing");
|
if (remote) {
|
||||||
} catch(e) {
|
|
||||||
// The pref wasn't set, so I guess we're not overriding.
|
|
||||||
}
|
|
||||||
if (this.usingRemoteTabs && !allow_for_testing) {
|
|
||||||
alert("e10s printing is not implemented yet. Bug 927188.");
|
alert("e10s printing is not implemented yet. Bug 927188.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
showPageSetup: function ()
|
||||||
* Shows the page setup dialog, and saves any settings changed in
|
{
|
||||||
* that dialog if print.save_print_settings is set to true.
|
|
||||||
*
|
|
||||||
* @return true on success, false on failure
|
|
||||||
*/
|
|
||||||
showPageSetup: function () {
|
|
||||||
if (this.bailOut()) {
|
if (this.bailOut()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -109,249 +45,102 @@ var PrintUtils = {
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
print: function (aWindow)
|
||||||
* Starts printing the contents of aWindow.
|
|
||||||
*
|
|
||||||
* @param aWindow
|
|
||||||
* An nsIDOMWindow to initiate the printing of. If the chrome window
|
|
||||||
* is not running with remote tabs, this defaults to window.content if
|
|
||||||
* omitted. If running with remote tabs, the caller must pass in the
|
|
||||||
* content window to be printed. This function throws if that invariant
|
|
||||||
* is violated.
|
|
||||||
* @param aBrowser (optional for non-remote browsers)
|
|
||||||
* The remote <xul:browser> that contains aWindow. This argument is
|
|
||||||
* not necessary if aWindow came from a non-remote browser, but is
|
|
||||||
* strictly required otherwise. This function will throw if aWindow
|
|
||||||
* comes from a remote browser and aBrowser is not provided.
|
|
||||||
*/
|
|
||||||
print: function (aWindow, aBrowser)
|
|
||||||
{
|
{
|
||||||
if (this.bailOut()) {
|
if (this.bailOut()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
var webBrowserPrint = this.getWebBrowserPrint(aWindow);
|
||||||
if (!aWindow) {
|
var printSettings = this.getPrintSettings();
|
||||||
// If we're using remote browsers, chances are that window.content will
|
try {
|
||||||
// not be defined.
|
webBrowserPrint.print(printSettings, null);
|
||||||
if (this.usingRemoteTabs) {
|
if (gPrintSettingsAreGlobal && gSavePrintSettings) {
|
||||||
throw new Error("Windows running with remote tabs must explicitly pass " +
|
var PSSVC = Components.classes["@mozilla.org/gfx/printsettings-service;1"]
|
||||||
"a content window to PrintUtils.print.");
|
.getService(Components.interfaces.nsIPrintSettingsService);
|
||||||
|
PSSVC.savePrintSettingsToPrefs(printSettings, true,
|
||||||
|
printSettings.kInitSaveAll);
|
||||||
|
PSSVC.savePrintSettingsToPrefs(printSettings, false,
|
||||||
|
printSettings.kInitSavePrinterName);
|
||||||
}
|
}
|
||||||
// Otherwise, we should have access to window.content.
|
} catch (e) {
|
||||||
aWindow = window.content;
|
// Pressing cancel is expressed as an NS_ERROR_ABORT return value,
|
||||||
|
// causing an exception to be thrown which we catch here.
|
||||||
|
// Unfortunately this will also consume helpful failures, so add a
|
||||||
|
// dump("print: "+e+"\n"); // if you need to debug
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Cu.isCrossProcessWrapper(aWindow)) {
|
|
||||||
if (!aBrowser) {
|
|
||||||
throw new Error("PrintUtils.print expects a remote browser passed as " +
|
|
||||||
"an argument if the content window is a CPOW.");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// For content windows coming from non-remote browsers, the browser can
|
|
||||||
// be resolved as the chromeEventHandler.
|
|
||||||
aBrowser = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
|
||||||
.getInterface(Ci.nsIWebNavigation)
|
|
||||||
.QueryInterface(Ci.nsIDocShell)
|
|
||||||
.chromeEventHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!aBrowser) {
|
|
||||||
throw new Error("PrintUtils.print could not resolve content window " +
|
|
||||||
"to a browser.");
|
|
||||||
}
|
|
||||||
|
|
||||||
let printSettings = this.getPrintSettings();
|
|
||||||
|
|
||||||
let mm = aBrowser.messageManager;
|
|
||||||
mm.sendAsyncMessage("Printing:Print", null, {
|
|
||||||
printSettings: printSettings,
|
|
||||||
contentWindow: aWindow,
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
// If aCallback is not null, it must be an object which has the following methods:
|
||||||
* Initializes print preview.
|
// getPrintPreviewBrowser(), getSourceBrowser(),
|
||||||
*
|
// getNavToolbox(), onEnter() and onExit().
|
||||||
* @param aListenerObj
|
// If aCallback is null, then printPreview must previously have been called with
|
||||||
* An object that defines the following functions:
|
// non-null aCallback and that object will be reused.
|
||||||
*
|
printPreview: function (aCallback)
|
||||||
* getPrintPreviewBrowser:
|
|
||||||
* Returns the <xul:browser> to display the print preview in.
|
|
||||||
*
|
|
||||||
* getSourceBrowser:
|
|
||||||
* Returns the <xul:browser> that contains the document being
|
|
||||||
* printed.
|
|
||||||
*
|
|
||||||
* getNavToolbox:
|
|
||||||
* Returns the primary toolbox for this window.
|
|
||||||
*
|
|
||||||
* onEnter:
|
|
||||||
* Called upon entering print preview.
|
|
||||||
*
|
|
||||||
* onExit:
|
|
||||||
* Called upon exiting print preview.
|
|
||||||
*
|
|
||||||
* These methods must be defined. printPreview can be called
|
|
||||||
* with aListenerObj as null iff this window is already displaying
|
|
||||||
* print preview (in which case, the previous aListenerObj passed
|
|
||||||
* to it will be used).
|
|
||||||
*/
|
|
||||||
printPreview: function (aListenerObj)
|
|
||||||
{
|
{
|
||||||
if (this.bailOut()) {
|
if (this.bailOut()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// if we're already in PP mode, don't set the listener; chances
|
// if we're already in PP mode, don't set the callback; chances
|
||||||
// are it is null because someone is calling printPreview() to
|
// are it is null because someone is calling printPreview() to
|
||||||
// get us to refresh the display.
|
// get us to refresh the display.
|
||||||
if (!this.inPrintPreview) {
|
if (!document.getElementById("print-preview-toolbar")) {
|
||||||
this._listener = aListenerObj;
|
this._callback = aCallback;
|
||||||
this._sourceBrowser = aListenerObj.getSourceBrowser();
|
this._sourceBrowser = aCallback.getSourceBrowser();
|
||||||
this._originalTitle = this._sourceBrowser.contentTitle;
|
this._originalTitle = this._sourceBrowser.contentDocument.title;
|
||||||
this._originalURL = this._sourceBrowser.currentURI.spec;
|
this._originalURL = this._sourceBrowser.currentURI.spec;
|
||||||
} else {
|
} else {
|
||||||
// collapse the browser here -- it will be shown in
|
// collapse the browser here -- it will be shown in
|
||||||
// enterPrintPreview; this forces a reflow which fixes display
|
// enterPrintPreview; this forces a reflow which fixes display
|
||||||
// issues in bug 267422.
|
// issues in bug 267422.
|
||||||
this._sourceBrowser = this._listener.getPrintPreviewBrowser();
|
this._sourceBrowser = this._callback.getPrintPreviewBrowser();
|
||||||
this._sourceBrowser.collapsed = true;
|
this._sourceBrowser.collapsed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._webProgressPP = {};
|
this._webProgressPP = {};
|
||||||
let ppParams = {};
|
var ppParams = {};
|
||||||
let notifyOnOpen = {};
|
var notifyOnOpen = {};
|
||||||
let printSettings = this.getPrintSettings();
|
var webBrowserPrint = this.getWebBrowserPrint();
|
||||||
|
var printSettings = this.getPrintSettings();
|
||||||
// Here we get the PrintingPromptService so we can display the PP Progress from script
|
// 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
|
// For the browser implemented via XUL with the PP toolbar we cannot let it be
|
||||||
// automatically opened from the print engine because the XUL scrollbars in the PP window
|
// automatically opened from the print engine because the XUL scrollbars in the PP window
|
||||||
// will layout before the content window and a crash will occur.
|
// will layout before the content window and a crash will occur.
|
||||||
// Doing it all from script, means it lays out before hand and we can let printing do its own thing
|
// Doing it all from script, means it lays out before hand and we can let printing do its own thing
|
||||||
let PPROMPTSVC = Components.classes["@mozilla.org/embedcomp/printingprompt-service;1"]
|
var PPROMPTSVC = Components.classes["@mozilla.org/embedcomp/printingprompt-service;1"]
|
||||||
.getService(Components.interfaces.nsIPrintingPromptService);
|
.getService(Components.interfaces.nsIPrintingPromptService);
|
||||||
// just in case we are already printing,
|
// just in case we are already printing,
|
||||||
// an error code could be returned if the Progress Dialog is already displayed
|
// an error code could be returned if the Prgress Dialog is already displayed
|
||||||
try {
|
try {
|
||||||
PPROMPTSVC.showProgress(window, null, printSettings, this._obsPP, false,
|
PPROMPTSVC.showProgress(window, webBrowserPrint, printSettings, this._obsPP, false,
|
||||||
this._webProgressPP, ppParams, notifyOnOpen);
|
this._webProgressPP, ppParams, notifyOnOpen);
|
||||||
if (ppParams.value) {
|
if (ppParams.value) {
|
||||||
ppParams.value.docTitle = this._originalTitle;
|
ppParams.value.docTitle = this._originalTitle;
|
||||||
ppParams.value.docURL = this._originalURL;
|
ppParams.value.docURL = this._originalURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this tells us whether we should continue on with PP or
|
// this tells us whether we should continue on with PP or
|
||||||
// wait for the callback via the observer
|
// wait for the callback via the observer
|
||||||
if (!notifyOnOpen.value.valueOf() || this._webProgressPP.value == null) {
|
if (!notifyOnOpen.value.valueOf() || this._webProgressPP.value == null)
|
||||||
this.enterPrintPreview();
|
this.enterPrintPreview();
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.enterPrintPreview();
|
this.enterPrintPreview();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the nsIWebBrowserPrint associated with some content window.
|
|
||||||
* This method is being kept here for compatibility reasons, but should not
|
|
||||||
* be called by code hoping to support e10s / remote browsers.
|
|
||||||
*
|
|
||||||
* @param aWindow
|
|
||||||
* The window from which to get the nsIWebBrowserPrint from.
|
|
||||||
* @return nsIWebBrowserPrint
|
|
||||||
*/
|
|
||||||
getWebBrowserPrint: function (aWindow)
|
getWebBrowserPrint: function (aWindow)
|
||||||
{
|
{
|
||||||
let Deprecated = Components.utils.import("resource://gre/modules/Deprecated.jsm", {}).Deprecated;
|
|
||||||
let text = "getWebBrowserPrint is now deprecated, and fully unsupported for " +
|
|
||||||
"multi-process browsers. Please use a frame script to get " +
|
|
||||||
"access to nsIWebBrowserPrint from content.";
|
|
||||||
let url = "https://developer.mozilla.org/en-US/docs/Printing_from_a_XUL_App";
|
|
||||||
Deprecated.warning(text, url);
|
|
||||||
|
|
||||||
if (this.usingRemoteTabs) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
var contentWindow = aWindow || window.content;
|
var contentWindow = aWindow || window.content;
|
||||||
return contentWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
return contentWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||||
.getInterface(Components.interfaces.nsIWebBrowserPrint);
|
.getInterface(Components.interfaces.nsIWebBrowserPrint);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the nsIWebBrowserPrint from the print preview browser's docShell.
|
|
||||||
* This method is being kept here for compatibility reasons, but should not
|
|
||||||
* be called by code hoping to support e10s / remote browsers.
|
|
||||||
*
|
|
||||||
* @return nsIWebBrowserPrint
|
|
||||||
*/
|
|
||||||
getPrintPreview: function() {
|
getPrintPreview: function() {
|
||||||
let Deprecated = Components.utils.import("resource://gre/modules/Deprecated.jsm", {}).Deprecated;
|
return this._callback.getPrintPreviewBrowser().docShell.printPreview;
|
||||||
let text = "getPrintPreview is now deprecated, and fully unsupported for " +
|
|
||||||
"multi-process browsers. Please use a frame script to get " +
|
|
||||||
"access to nsIWebBrowserPrint from content.";
|
|
||||||
let url = "https://developer.mozilla.org/en-US/docs/Printing_from_a_XUL_App";
|
|
||||||
Deprecated.warning(text, url);
|
|
||||||
|
|
||||||
if (this.usingRemoteTabs) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
return this._listener.getPrintPreviewBrowser().docShell.printPreview;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
get inPrintPreview() {
|
////////////////////////////////////////
|
||||||
return document.getElementById("print-preview-toolbar") != null;
|
// "private" methods. Don't use them. //
|
||||||
},
|
////////////////////////////////////////
|
||||||
|
|
||||||
////////////////////////////////////////////////////
|
|
||||||
// "private" methods and members. Don't use them. //
|
|
||||||
///////////////////////////////////////////////////
|
|
||||||
|
|
||||||
_listener: null,
|
|
||||||
_closeHandlerPP: null,
|
|
||||||
_webProgressPP: null,
|
|
||||||
_sourceBrowser: null,
|
|
||||||
_originalTitle: "",
|
|
||||||
_originalURL: "",
|
|
||||||
|
|
||||||
get usingRemoteTabs() {
|
|
||||||
// We memoize this, since it's highly unlikely to change over the lifetime
|
|
||||||
// of the window.
|
|
||||||
let usingRemoteTabs =
|
|
||||||
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
|
||||||
.getInterface(Components.interfaces.nsIWebNavigation)
|
|
||||||
.QueryInterface(Components.interfaces.nsILoadContext)
|
|
||||||
.useRemoteTabs;
|
|
||||||
delete this.usingRemoteTabs;
|
|
||||||
return this.usingRemoteTabs = usingRemoteTabs;
|
|
||||||
},
|
|
||||||
|
|
||||||
receiveMessage(aMessage) {
|
|
||||||
if (!this._webProgressPP.value) {
|
|
||||||
// We somehow didn't get a nsIWebProgressListener to be updated...
|
|
||||||
// I guess there's nothing to do.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let listener = this._webProgressPP.value;
|
|
||||||
let data = aMessage.data;
|
|
||||||
|
|
||||||
switch (aMessage.name) {
|
|
||||||
case "Printing:Preview:ProgressChange": {
|
|
||||||
return listener.onProgressChange(null, null,
|
|
||||||
data.curSelfProgress,
|
|
||||||
data.maxSelfProgress,
|
|
||||||
data.curTotalProgress,
|
|
||||||
data.maxTotalProgress);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case "Printing:Preview:StateChange": {
|
|
||||||
return listener.onStateChange(null, null,
|
|
||||||
data.stateFlags,
|
|
||||||
data.status);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
setPrinterDefaultsForSelectedPrinter: function (aPSSVC, aPrintSettings)
|
setPrinterDefaultsForSelectedPrinter: function (aPSSVC, aPrintSettings)
|
||||||
{
|
{
|
||||||
@ -389,8 +178,15 @@ var PrintUtils = {
|
|||||||
return printSettings;
|
return printSettings;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_closeHandlerPP: null,
|
||||||
|
_webProgressPP: null,
|
||||||
|
_callback: null,
|
||||||
|
_sourceBrowser: null,
|
||||||
|
_originalTitle: "",
|
||||||
|
_originalURL: "",
|
||||||
|
|
||||||
// This observer is called once the progress dialog has been "opened"
|
// This observer is called once the progress dialog has been "opened"
|
||||||
_obsPP:
|
_obsPP:
|
||||||
{
|
{
|
||||||
observe: function(aSubject, aTopic, aData)
|
observe: function(aSubject, aTopic, aData)
|
||||||
{
|
{
|
||||||
@ -403,89 +199,84 @@ var PrintUtils = {
|
|||||||
if (iid.equals(Components.interfaces.nsIObserver) ||
|
if (iid.equals(Components.interfaces.nsIObserver) ||
|
||||||
iid.equals(Components.interfaces.nsISupportsWeakReference) ||
|
iid.equals(Components.interfaces.nsISupportsWeakReference) ||
|
||||||
iid.equals(Components.interfaces.nsISupports))
|
iid.equals(Components.interfaces.nsISupports))
|
||||||
return this;
|
return this;
|
||||||
throw Components.results.NS_NOINTERFACE;
|
throw Components.results.NS_NOINTERFACE;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
enterPrintPreview: function ()
|
enterPrintPreview: function ()
|
||||||
{
|
{
|
||||||
// Send a message to the print preview browser to initialize
|
gFocusedElement = document.commandDispatcher.focusedElement;
|
||||||
// print preview. If we happen to have gotten a print preview
|
|
||||||
// progress listener from nsIPrintingPromptService.showProgress
|
|
||||||
// in printPreview, we add listeners to feed that progress
|
|
||||||
// listener.
|
|
||||||
let ppBrowser = this._listener.getPrintPreviewBrowser();
|
|
||||||
let mm = ppBrowser.messageManager;
|
|
||||||
let printSettings = this.getPrintSettings();
|
|
||||||
mm.sendAsyncMessage("Printing:Preview:Enter", null, {
|
|
||||||
printSettings: printSettings,
|
|
||||||
contentWindow: this._sourceBrowser.contentWindowAsCPOW,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (this._webProgressPP.value) {
|
var webBrowserPrint;
|
||||||
mm.addMessageListener("Printing:Preview:StateChange", this);
|
var printSettings = this.getPrintSettings();
|
||||||
mm.addMessageListener("Printing:Preview:ProgressChange", this);
|
var originalWindow = this._sourceBrowser.contentWindow;
|
||||||
|
|
||||||
|
try {
|
||||||
|
webBrowserPrint = this.getPrintPreview();
|
||||||
|
webBrowserPrint.printPreview(printSettings, originalWindow,
|
||||||
|
this._webProgressPP.value);
|
||||||
|
} catch (e) {
|
||||||
|
// Pressing cancel is expressed as an NS_ERROR_ABORT return value,
|
||||||
|
// causing an exception to be thrown which we catch here.
|
||||||
|
// Unfortunately this will also consume helpful failures, so add a
|
||||||
|
// dump(e); // if you need to debug
|
||||||
|
|
||||||
|
// Need to call enter and exit so that UI gets back to normal.
|
||||||
|
this._callback.onEnter();
|
||||||
|
this._callback.onExit();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let onEntered = (message) => {
|
var printPreviewTB = document.getElementById("print-preview-toolbar");
|
||||||
mm.removeMessageListener("Printing:PrintPreview:Entered", onEntered);
|
if (printPreviewTB) {
|
||||||
// Stash the focused element so that we can return to it after exiting
|
printPreviewTB.updateToolbar();
|
||||||
// print preview.
|
var browser = this._callback.getPrintPreviewBrowser();
|
||||||
gFocusedElement = document.commandDispatcher.focusedElement;
|
browser.collapsed = false;
|
||||||
|
browser.contentWindow.focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let printPreviewTB = document.getElementById("print-preview-toolbar");
|
// Set the original window as an active window so any mozPrintCallbacks can
|
||||||
if (printPreviewTB) {
|
// run without delayed setTimeouts.
|
||||||
printPreviewTB.updateToolbar();
|
var docShell = originalWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||||
ppBrowser.collapsed = false;
|
.getInterface(Components.interfaces.nsIWebNavigation)
|
||||||
ppBrowser.focus();
|
.QueryInterface(Components.interfaces.nsIDocShell);
|
||||||
return;
|
docShell.isActive = true;
|
||||||
}
|
|
||||||
|
|
||||||
// Set the original window as an active window so any mozPrintCallbacks can
|
// show the toolbar after we go into print preview mode so
|
||||||
// run without delayed setTimeouts.
|
// that we can initialize the toolbar with total num pages
|
||||||
this._sourceBrowser.docShellIsActive = true;
|
var XUL_NS =
|
||||||
|
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||||
|
printPreviewTB = document.createElementNS(XUL_NS, "toolbar");
|
||||||
|
printPreviewTB.setAttribute("printpreview", true);
|
||||||
|
printPreviewTB.id = "print-preview-toolbar";
|
||||||
|
printPreviewTB.className = "toolbar-primary";
|
||||||
|
|
||||||
// show the toolbar after we go into print preview mode so
|
var navToolbox = this._callback.getNavToolbox();
|
||||||
// that we can initialize the toolbar with total num pages
|
navToolbox.parentNode.insertBefore(printPreviewTB, navToolbox);
|
||||||
const XUL_NS =
|
|
||||||
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
|
||||||
printPreviewTB = document.createElementNS(XUL_NS, "toolbar");
|
|
||||||
printPreviewTB.setAttribute("printpreview", true);
|
|
||||||
printPreviewTB.id = "print-preview-toolbar";
|
|
||||||
printPreviewTB.className = "toolbar-primary";
|
|
||||||
|
|
||||||
let navToolbox = this._listener.getNavToolbox();
|
// copy the window close handler
|
||||||
navToolbox.parentNode.insertBefore(printPreviewTB, navToolbox);
|
if (document.documentElement.hasAttribute("onclose"))
|
||||||
printPreviewTB.initialize(ppBrowser);
|
this._closeHandlerPP = document.documentElement.getAttribute("onclose");
|
||||||
|
else
|
||||||
|
this._closeHandlerPP = null;
|
||||||
|
document.documentElement.setAttribute("onclose", "PrintUtils.exitPrintPreview(); return false;");
|
||||||
|
|
||||||
// copy the window close handler
|
// disable chrome shortcuts...
|
||||||
if (document.documentElement.hasAttribute("onclose"))
|
window.addEventListener("keydown", this.onKeyDownPP, true);
|
||||||
this._closeHandlerPP = document.documentElement.getAttribute("onclose");
|
window.addEventListener("keypress", this.onKeyPressPP, true);
|
||||||
else
|
|
||||||
this._closeHandlerPP = null;
|
|
||||||
document.documentElement.setAttribute("onclose", "PrintUtils.exitPrintPreview(); return false;");
|
|
||||||
|
|
||||||
// disable chrome shortcuts...
|
var browser = this._callback.getPrintPreviewBrowser();
|
||||||
window.addEventListener("keydown", this.onKeyDownPP, true);
|
browser.collapsed = false;
|
||||||
window.addEventListener("keypress", this.onKeyPressPP, true);
|
browser.contentWindow.focus();
|
||||||
|
|
||||||
ppBrowser.collapsed = false;
|
// on Enter PP Call back
|
||||||
ppBrowser.focus();
|
this._callback.onEnter();
|
||||||
// on Enter PP Call back
|
|
||||||
this._listener.onEnter();
|
|
||||||
};
|
|
||||||
|
|
||||||
mm.addMessageListener("Printing:Preview:Entered", onEntered);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
exitPrintPreview: function ()
|
exitPrintPreview: function ()
|
||||||
{
|
{
|
||||||
let ppBrowser = this._listener.getPrintPreviewBrowser();
|
|
||||||
let browserMM = ppBrowser.messageManager;
|
|
||||||
browserMM.sendAsyncMessage("Printing:Preview:Exit");
|
|
||||||
browserMM.removeMessageListener("Printing:Preview:StateChange", this);
|
|
||||||
browserMM.removeMessageListener("Printing:Preview:ProgressChange", this);
|
|
||||||
window.removeEventListener("keydown", this.onKeyDownPP, true);
|
window.removeEventListener("keydown", this.onKeyDownPP, true);
|
||||||
window.removeEventListener("keypress", this.onKeyPressPP, true);
|
window.removeEventListener("keypress", this.onKeyPressPP, true);
|
||||||
|
|
||||||
@ -493,11 +284,14 @@ var PrintUtils = {
|
|||||||
document.documentElement.setAttribute("onclose", this._closeHandlerPP);
|
document.documentElement.setAttribute("onclose", this._closeHandlerPP);
|
||||||
this._closeHandlerPP = null;
|
this._closeHandlerPP = null;
|
||||||
|
|
||||||
// remove the print preview toolbar
|
var webBrowserPrint = this.getPrintPreview();
|
||||||
let printPreviewTB = document.getElementById("print-preview-toolbar");
|
webBrowserPrint.exitPrintPreview();
|
||||||
this._listener.getNavToolbox().parentNode.removeChild(printPreviewTB);
|
|
||||||
|
|
||||||
let fm = Components.classes["@mozilla.org/focus-manager;1"]
|
// remove the print preview toolbar
|
||||||
|
var printPreviewTB = document.getElementById("print-preview-toolbar");
|
||||||
|
this._callback.getNavToolbox().parentNode.removeChild(printPreviewTB);
|
||||||
|
|
||||||
|
var fm = Components.classes["@mozilla.org/focus-manager;1"]
|
||||||
.getService(Components.interfaces.nsIFocusManager);
|
.getService(Components.interfaces.nsIFocusManager);
|
||||||
if (gFocusedElement)
|
if (gFocusedElement)
|
||||||
fm.setFocus(gFocusedElement, fm.FLAG_NOSCROLL);
|
fm.setFocus(gFocusedElement, fm.FLAG_NOSCROLL);
|
||||||
@ -505,7 +299,7 @@ var PrintUtils = {
|
|||||||
window.content.focus();
|
window.content.focus();
|
||||||
gFocusedElement = null;
|
gFocusedElement = null;
|
||||||
|
|
||||||
this._listener.onExit();
|
this._callback.onExit();
|
||||||
},
|
},
|
||||||
|
|
||||||
onKeyDownPP: function (aEvent)
|
onKeyDownPP: function (aEvent)
|
||||||
@ -535,7 +329,7 @@ var PrintUtils = {
|
|||||||
var printKey = document.getElementById("printKb").getAttribute("key").toUpperCase();
|
var printKey = document.getElementById("printKb").getAttribute("key").toUpperCase();
|
||||||
var pressedKey = String.fromCharCode(aEvent.charCode).toUpperCase();
|
var pressedKey = String.fromCharCode(aEvent.charCode).toUpperCase();
|
||||||
if (printKey == pressedKey) {
|
if (printKey == pressedKey) {
|
||||||
printPreviewTB.print();
|
PrintUtils.print();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// cancel shortkeys
|
// cancel shortkeys
|
||||||
|
@ -6,10 +6,8 @@
|
|||||||
let Cc = Components.classes;
|
let Cc = Components.classes;
|
||||||
let Ci = Components.interfaces;
|
let Ci = Components.interfaces;
|
||||||
let Cu = Components.utils;
|
let Cu = Components.utils;
|
||||||
let Cr = Components.results;
|
|
||||||
|
|
||||||
Cu.import("resource://gre/modules/Services.jsm");
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
||||||
|
|
||||||
var global = this;
|
var global = this;
|
||||||
|
|
||||||
@ -355,130 +353,3 @@ PopupBlocking.init();
|
|||||||
// Set up console.* for frame scripts.
|
// Set up console.* for frame scripts.
|
||||||
let Console = Components.utils.import("resource://gre/modules/devtools/Console.jsm", {});
|
let Console = Components.utils.import("resource://gre/modules/devtools/Console.jsm", {});
|
||||||
this.console = new Console.ConsoleAPI();
|
this.console = new Console.ConsoleAPI();
|
||||||
|
|
||||||
let Printing = {
|
|
||||||
// Bug 1088061: nsPrintEngine's DoCommonPrint currently expects the
|
|
||||||
// progress listener passed to it to QI to an nsIPrintingPromptService
|
|
||||||
// in order to know that a printing progress dialog has been shown. That's
|
|
||||||
// really all the interface is used for, hence the fact that I don't actually
|
|
||||||
// implement the interface here. Bug 1088061 has been filed to remove
|
|
||||||
// this hackery.
|
|
||||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
|
|
||||||
Ci.nsIPrintingPromptService]),
|
|
||||||
|
|
||||||
MESSAGES: [
|
|
||||||
"Printing:Preview:Enter",
|
|
||||||
"Printing:Preview:Exit",
|
|
||||||
"Printing:Preview:Navigate",
|
|
||||||
"Printing:Preview:UpdatePageCount",
|
|
||||||
"Printing:Print",
|
|
||||||
],
|
|
||||||
|
|
||||||
init() {
|
|
||||||
this.MESSAGES.forEach(msgName => addMessageListener(msgName, this));
|
|
||||||
},
|
|
||||||
|
|
||||||
receiveMessage(message) {
|
|
||||||
let objects = message.objects;
|
|
||||||
let data = message.data;
|
|
||||||
switch(message.name) {
|
|
||||||
case "Printing:Preview:Enter": {
|
|
||||||
this.enterPrintPreview(objects.printSettings, objects.contentWindow);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case "Printing:Preview:Exit": {
|
|
||||||
this.exitPrintPreview();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case "Printing:Preview:Navigate": {
|
|
||||||
this.navigate(data.navType, data.pageNum);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case "Printing:Preview:UpdatePageCount": {
|
|
||||||
this.updatePageCount();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case "Printing:Print": {
|
|
||||||
this.print(objects.printSettings, objects.contentWindow);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
enterPrintPreview(printSettings, contentWindow) {
|
|
||||||
// Bug 1088070 - we should instantiate nsIPrintSettings here in the
|
|
||||||
// content script instead of passing it down as a CPOW.
|
|
||||||
if (Cu.isCrossProcessWrapper(printSettings)) {
|
|
||||||
printSettings = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We have to wait for the print engine to finish reflowing all of the
|
|
||||||
// documents and subdocuments before we can tell the parent to flip to
|
|
||||||
// the print preview UI - otherwise, the print preview UI might ask for
|
|
||||||
// information (like the number of pages in the document) before we have
|
|
||||||
// our PresShells set up.
|
|
||||||
addEventListener("printPreviewUpdate", function onPrintPreviewReady() {
|
|
||||||
removeEventListener("printPreviewUpdate", onPrintPreviewReady);
|
|
||||||
sendAsyncMessage("Printing:Preview:Entered");
|
|
||||||
});
|
|
||||||
|
|
||||||
docShell.printPreview.printPreview(printSettings, contentWindow, this);
|
|
||||||
},
|
|
||||||
|
|
||||||
exitPrintPreview() {
|
|
||||||
docShell.printPreview.exitPrintPreview();
|
|
||||||
},
|
|
||||||
|
|
||||||
print(printSettings, contentWindow) {
|
|
||||||
// Bug 1088070 - we should instantiate nsIPrintSettings here in the
|
|
||||||
// content script instead of passing it down as a CPOW.
|
|
||||||
if (Cu.isCrossProcessWrapper(printSettings)) {
|
|
||||||
printSettings = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
let print = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
|
||||||
.getInterface(Ci.nsIWebBrowserPrint);
|
|
||||||
print.print(printSettings, null);
|
|
||||||
},
|
|
||||||
|
|
||||||
updatePageCount() {
|
|
||||||
let numPages = docShell.printPreview.printPreviewNumPages;
|
|
||||||
sendAsyncMessage("Printing:Preview:UpdatePageCount", {
|
|
||||||
numPages: numPages,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
navigate(navType, pageNum) {
|
|
||||||
docShell.printPreview.printPreviewNavigate(navType, pageNum);
|
|
||||||
},
|
|
||||||
|
|
||||||
/* nsIWebProgressListener for print preview */
|
|
||||||
|
|
||||||
onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) {
|
|
||||||
sendAsyncMessage("Printing:Preview:StateChange", {
|
|
||||||
stateFlags: aStateFlags,
|
|
||||||
status: aStatus,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
onProgressChange(aWebProgress, aRequest, aCurSelfProgress,
|
|
||||||
aMaxSelfProgress, aCurTotalProgress,
|
|
||||||
aMaxTotalProgress) {
|
|
||||||
sendAsyncMessage("Printing:Preview:ProgressChange", {
|
|
||||||
curSelfProgress: aCurSelfProgress,
|
|
||||||
maxSelfProgress: aMaxSelfProgress,
|
|
||||||
curTotalProgress: aCurTotalProgress,
|
|
||||||
maxTotalProgress: aMaxTotalProgress,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
onLocationChange(aWebProgress, aRequest, aLocation, aFlags) {},
|
|
||||||
onStatusChange(aWebProgress, aRequest, aStatus, aMessage) {},
|
|
||||||
onSecurityChange(aWebProgress, aRequest, aState) {},
|
|
||||||
}
|
|
||||||
Printing.init();
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user