Bug 1331203 - Port Bug 1243643 ["Save Image As..." Not working] to SeaMonkey. r=IanN a=IanN DONTBUILD
authorFrank-Rainer Grahl <frgrahl@gmx.net>
Tue, 21 Mar 2017 20:06:05 +0100
changeset 31393 95cca2602d76e5be7c06a55c37521f3d8f07606e
parent 31392 44cfd725acc15f0abcd33dfc00dda54e889e1fb3
child 31394 a6e7681a0b0433fa027afd36606ddfad82756ef0
push id1
push userclokep@gmail.com
push dateMon, 07 May 2018 22:45:56 +0000
treeherdercomm-esr60@57eacde5ef40 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersIanN, IanN
bugs1331203, 1243643
Bug 1331203 - Port Bug 1243643 ["Save Image As..." Not working] to SeaMonkey. r=IanN a=IanN DONTBUILD
suite/common/nsContextMenu.js
suite/mailnews/mailContextMenus.js
suite/mailnews/mailWindowOverlay.xul
--- a/suite/common/nsContextMenu.js
+++ b/suite/common/nsContextMenu.js
@@ -950,17 +950,17 @@ nsContextMenu.prototype = {
     var canvas = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
     canvas.width = video.videoWidth;
     canvas.height = video.videoHeight;
     var ctxDraw = canvas.getContext("2d");
     ctxDraw.drawImage(video, 0, 0);
     saveImageURL(canvas.toDataURL("image/jpeg", ""), name, "SaveImageTitle",
                                   true, true,
                                   this.target.ownerDocument.documentURIObject,
-                                  this.target.ownerDocument);
+                                  null, null, null, (gPrivate ? true : false));
   },
 
   // Full screen video playback
   fullScreenVideo: function() {
     var isPaused = this.target.paused && this.target.currentTime > 0;
     this.target.pause();
 
     openDialog("chrome://communicator/content/fullscreen-video.xhtml",
@@ -1117,23 +1117,29 @@ nsContextMenu.prototype = {
 
     // kick off the channel with our proxy object as the listener
     channel.asyncOpen(new SaveAsListener(), null);
   },
 
   // Save URL of clicked-on image, video, or audio.
   saveMedia: function() {
     var doc = this.target.ownerDocument;
+    let referrerURI = doc.documentURIObject;
+
     if (this.onCanvas)
       // Bypass cache, since it's a data: URL.
       saveImageURL(this.target.toDataURL(), "canvas.png", "SaveImageTitle",
-                   true, true, null, doc);
-    else if (this.onImage)
-      saveImageURL(this.mediaURL, null, "SaveImageTitle", false, true,
-                   doc.documentURIObject, doc);
+                   true, false, referrerURI, null, null, null,
+                   (gPrivate ? true : false));
+    else if (this.onImage) {
+      saveImageURL(this.mediaURL, null, "SaveImageTitle", false,
+                   false, referrerURI, null, gContextMenuContentData.contentType,
+                   gContextMenuContentData.contentDisposition,
+                   (gPrivate ? true : false));
+    }
     else if (this.onVideo || this.onAudio) {
       var dialogTitle = this.onVideo ? "SaveVideoTitle" : "SaveAudioTitle";
       this.saveHelper(this.mediaURL, null, dialogTitle, false, doc);
     }
   },
 
   // Backwards-compatibility wrapper
   saveImage: function() {
--- a/suite/mailnews/mailContextMenus.js
+++ b/suite/mailnews/mailContextMenus.js
@@ -94,22 +94,28 @@ function InThreadPane(aTarget)
   return false;
 }
 
 /**
  * Function to set up the global nsContextMenu, and the mailnews overlay.
  * @param aTarget the target of the popup event
  * @return true always
  */
-function FillMailContextMenu(aTarget)
+function FillMailContextMenu(aTarget, aEvent)
 {
   var inThreadPane = InThreadPane(aTarget);
-  gContextMenu = new nsContextMenu(aTarget, getBrowser());
+  gContextMenu = new nsContextMenu(aTarget);
+
   // Need to call nsContextMenu's initItems to hide what is not used.
   gContextMenu.initItems();
+
+  // Initialize gContextMenuContentData.
+  if (aEvent)
+    gContextMenu.initContentData(aEvent);
+
   var numSelected = GetNumSelectedMessages();
   var oneOrMore = (numSelected > 0);
   var single = (numSelected == 1);
 
   var isNewsgroup = gFolderDisplay.selectedMessageIsNews;
 
   // Clear the global var used to keep track if a 'Delete Message' or 'Move
   // To' command has been triggered via the thread pane context menu.
--- a/suite/mailnews/mailWindowOverlay.xul
+++ b/suite/mailnews/mailWindowOverlay.xul
@@ -481,17 +481,17 @@
     <menuitem id="folderPaneContext-settings"
               label="&folderContextSettings.label;"
               accesskey="&folderContextSettings.accesskey;"
               oncommand="MsgFolderProperties();"/>
   </menupopup>
 
   <menupopup id="mailContext"
          onpopupshowing="return event.target != this ||
-                                FillMailContextMenu(this);"
+                                FillMailContextMenu(this, event);"
          onpopuphiding="if (event.target == this) MailContextOnPopupHiding(this);">
     <menuitem id="context-openlinkintab"
               label="&openLinkCmdInTab.label;"
               accesskey="&openLinkCmdInTab.accesskey;"
               oncommand="gContextMenu.openLinkInTab(event);"/>
     <menuitem id="context-openlink"
               label="&openLinkCmd.label;"
               accesskey="&openLinkCmd.accesskey;"