Bug 1331203 - Port
Bug 1243643 ["Save Image As..." Not working] to SeaMonkey. r=IanN
--- a/suite/common/nsContextMenu.js
+++ b/suite/common/nsContextMenu.js
@@ -939,17 +939,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",
@@ -1106,23 +1106,29 @@ nsContextMenu.prototype = {
// kick off the channel with our proxy object as the listener
channel.asyncOpen2(new SaveAsListener());
},
// 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;"