Bug 1620950 - Port Bug 1602561. Make PrintUtils.printWindow() act on a BrowsingContext. r=Paenglab
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Tue, 10 Mar 2020 22:53:11 +0200
changeset 38464 d4e300e98f228b41d9ca84500f36e5d5cf2ec30b
parent 38463 05c780359ee8c86f765a2d9e3e3e86774aecd8a2
child 38465 09f75ac5b05969661e8738050e3f58691689d1a1
push id400
push userclokep@gmail.com
push dateMon, 04 May 2020 18:56:09 +0000
reviewersPaenglab
bugs1620950, 1602561
Bug 1620950 - Port Bug 1602561. Make PrintUtils.printWindow() act on a BrowsingContext. r=Paenglab Port of https://hg.mozilla.org/mozilla-central/rev/c78f989b17befffd3009ce9fea4103a759bbbd71
mail/base/content/specialTabs.js
mail/components/compose/content/ComposerCommands.js
mail/components/compose/content/MsgComposeCommands.js
--- a/mail/base/content/specialTabs.js
+++ b/mail/base/content/specialTabs.js
@@ -592,17 +592,17 @@ var contentTabBaseType = {
       case "cmd_findPrevious":
         aTab.findbar.onFindAgainCommand(true);
         break;
       case "cmd_printSetup":
         PrintUtils.showPageSetup();
         break;
       case "cmd_print":
         let browser = this.getBrowser(aTab);
-        PrintUtils.printWindow(browser.outerWindowID, browser);
+        PrintUtils.printWindow(browser.browsingContext);
         break;
       // XXX print preview not currently supported - bug 497994 to implement.
       // case "cmd_printpreview":
       //  PrintUtils.printPreview();
       //  break;
       case "cmd_stop":
         aTab.browser.stop();
         break;
@@ -1578,17 +1578,17 @@ var specialTabs = {
         case "cmd_fullZoomToggle":
           ZoomManager.toggleZoom();
           break;
         case "cmd_printSetup":
           PrintUtils.showPageSetup();
           break;
         case "cmd_print":
           let browser = this.getBrowser(aTab);
-          PrintUtils.printWindow(browser.outerWindowID, browser);
+          PrintUtils.printWindow(browser.browsingContext);
           break;
         // XXX print preview not currently supported - bug 497994 to implement.
         // case "cmd_printpreview":
         //  PrintUtils.printPreview();
         //  break;
       }
     },
     getBrowser(aTab) {
--- a/mail/components/compose/content/ComposerCommands.js
+++ b/mail/components/compose/content/ComposerCommands.js
@@ -2073,36 +2073,32 @@ var nsPrintCommand = {
   isCommandEnabled(aCommand, dummy) {
     return true; // we can always do this
   },
 
   getCommandStateParams(aCommand, aParams, aRefCon) {},
   doCommandParams(aCommand, aParams, aRefCon) {},
 
   doCommand(aCommand) {
-    try {
-      let browser = GetCurrentEditorElement();
-      PrintUtils.printWindow(browser.outerWindowID, browser);
-    } catch (e) {}
+    let browser = GetCurrentEditorElement();
+    PrintUtils.printWindow(browser.browsingContext);
   },
 };
 
 var nsPrintPreviewCommand = {
   isCommandEnabled(aCommand, dummy) {
     // We can always do this.
     return true;
   },
 
   getCommandStateParams(aCommand, aParams, aRefCon) {},
   doCommandParams(aCommand, aParams, aRefCon) {},
 
   doCommand(aCommand) {
-    try {
-      PrintUtils.printPreview(PrintPreviewListener);
-    } catch (e) {}
+    PrintUtils.printPreview(PrintPreviewListener);
   },
 };
 
 var nsPrintSetupCommand = {
   isCommandEnabled(aCommand, dummy) {
     return true; // we can always do this
   },
 
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -2404,30 +2404,22 @@ function DoCommandClose() {
     // This destroys the window for us.
     MsgComposeCloseWindow();
   }
 
   return false;
 }
 
 function DoCommandPrint() {
-  try {
-    let editor = GetCurrentEditorElement();
-    PrintUtils.printWindow(editor.outerWindowID, editor);
-  } catch (ex) {
-    dump("#PRINT ERROR: " + ex + "\n");
-  }
+  let browser = GetCurrentEditorElement();
+  PrintUtils.printWindow(browser.browsingContext);
 }
 
 function DoCommandPrintPreview() {
-  try {
-    PrintUtils.printPreview(PrintPreviewListener);
-  } catch (ex) {
-    Cu.reportError(ex);
-  }
+  PrintUtils.printPreview(PrintPreviewListener);
 }
 
 /**
  * Locks/Unlocks the window widgets while a message is being saved/sent.
  * Locking means to disable all possible items in the window so that
  * the user can't click/activate anything.
  *
  * @param aDisable  true = lock the window. false = unlock the window.