Bug 1142997 - Cannot Print from Composer and other <editor> elements r=mossop a=sylvestre
authorPhilip Chee <philip.chee@gmail.com>
Tue, 24 Mar 2015 20:03:12 +0800
changeset 258240 e65f5a19d0e4
parent 258239 c481e8a84a6c
child 258241 0fce0415d8b4
push id4626
push userphilip.chee@gmail.com
push date2015-04-03 08:40 +0000
treeherdermozilla-beta@e65f5a19d0e4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop, sylvestre
bugs1142997
milestone38.0
Bug 1142997 - Cannot Print from Composer and other <editor> elements r=mossop a=sylvestre
toolkit/components/printing/content/printUtils.js
toolkit/content/widgets/editor.xml
--- a/toolkit/components/printing/content/printUtils.js
+++ b/toolkit/components/printing/content/printUtils.js
@@ -459,17 +459,18 @@ var PrintUtils = {
     // 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,
+      contentWindow: this._sourceBrowser.contentWindowAsCPOW ||
+                     this._sourceBrowser.contentWindow,
     });
 
     if (this._webProgressPP.value) {
       mm.addMessageListener("Printing:Preview:StateChange", this);
       mm.addMessageListener("Printing:Preview:ProgressChange", this);
     }
 
     let onEntered = (message) => {
--- a/toolkit/content/widgets/editor.xml
+++ b/toolkit/content/widgets/editor.xml
@@ -3,17 +3,17 @@
    - 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/. -->
 
 
 <bindings id="editorBindings"
    xmlns="http://www.mozilla.org/xbl"
    xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    xmlns:xbl="http://www.mozilla.org/xbl">
-  
+
   <binding id="editor" role="outerdoc">
     <implementation type="application/javascript">
       <constructor>
         <![CDATA[
           // Make window editable immediately only
           //   if the "editortype" attribute is supplied
           // This allows using same contentWindow for different editortypes,
           //   where the type is determined during the apps's window.onload handler.
@@ -138,16 +138,19 @@
                 onget="return this.boxObject.docShell;"
                 readonly="true"/>
       <property name="currentURI"
                 readonly="true"
                 onget="return this.webNavigation.currentURI;"/>
       <property name="contentWindow"
                 readonly="true"
                 onget="return this.docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindow);"/>
+      <property name="contentWindowAsCPOW"
+                readonly="true"
+                onget="return this.contentWindow;"/>
       <property name="webBrowserFind"
                 readonly="true"
                 onget="return this.docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIWebBrowserFind);"/>
       <property name="markupDocumentViewer"
                 readonly="true"
                 onget="return this.docShell.contentViewer;"/>
       <property name="editingSession"
                 readonly="true"
@@ -159,12 +162,24 @@
                 onget="return this.markupDocumentViewer.fullZoom;"
                 onset="this.markupDocumentViewer.fullZoom = val;"/>
       <property name="textZoom"
                 onget="return this.markupDocumentViewer.textZoom;"
                 onset="this.markupDocumentViewer.textZoom = val;"/>
       <property name="isSyntheticDocument"
                 onget="return this.contentDocument.isSyntheticDocument;"
                 readonly="true"/>
+      <property name="messageManager"
+                readonly="true">
+        <getter>
+          <![CDATA[
+            var owner = this.QueryInterface(Components.interfaces.nsIFrameLoaderOwner);
+            if (!owner.frameLoader) {
+              return null;
+            }
+            return owner.frameLoader.messageManager;
+          ]]>
+        </getter>
+      </property>
     </implementation>
   </binding>
 
 </bindings>