mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1122525 - On right-click query in advance media related information from the image cache and forward this info to chrome with the contextmenu event. r=mconley
This commit is contained in:
parent
3374c51fa4
commit
2f07b05d92
@ -165,6 +165,26 @@ let handleContentContextMenu = function (event) {
|
||||
let referrer = doc.referrer;
|
||||
let referrerPolicy = doc.referrerPolicy;
|
||||
|
||||
// Media related cache info parent needs for saving
|
||||
let contentType = null;
|
||||
let contentDisposition = null;
|
||||
if (event.target.nodeType == Ci.nsIDOMNode.ELEMENT_NODE &&
|
||||
event.target instanceof Ci.nsIImageLoadingContent &&
|
||||
event.target.currentURI) {
|
||||
try {
|
||||
let imageCache = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools)
|
||||
.getImgCacheForDocument(doc);
|
||||
let props =
|
||||
imageCache.findEntryProperties(event.target.currentURI);
|
||||
if (props) {
|
||||
contentType = props.get("type", Ci.nsISupportsCString).data;
|
||||
contentDisposition = props.get("content-disposition", Ci.nsISupportsCString).data;
|
||||
}
|
||||
} catch (e) {
|
||||
Cu.reportError(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT) {
|
||||
let editFlags = SpellCheckHelper.isEditable(event.target, content);
|
||||
let spellInfo;
|
||||
@ -179,7 +199,7 @@ let handleContentContextMenu = function (event) {
|
||||
sendSyncMessage("contextmenu",
|
||||
{ editFlags, spellInfo, customMenuItems, addonInfo,
|
||||
principal, docLocation, charSet, baseURI, referrer,
|
||||
referrerPolicy },
|
||||
referrerPolicy, contentType, contentDisposition },
|
||||
{ event, popupNode: event.target });
|
||||
}
|
||||
else {
|
||||
@ -197,6 +217,8 @@ let handleContentContextMenu = function (event) {
|
||||
charSet: charSet,
|
||||
referrer: referrer,
|
||||
referrerPolicy: referrerPolicy,
|
||||
contentType: contentType,
|
||||
contentDisposition: contentDisposition,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1321,12 +1321,15 @@ nsContextMenu.prototype = {
|
||||
if (this.onCanvas) {
|
||||
// Bypass cache, since it's a data: URL.
|
||||
saveImageURL(this.target.toDataURL(), "canvas.png", "SaveImageTitle",
|
||||
true, false, BrowserUtils.makeURIFromCPOW(doc.documentURIObject), doc);
|
||||
true, false, gContextMenuContentData.documentURIObject,
|
||||
doc);
|
||||
}
|
||||
else if (this.onImage) {
|
||||
urlSecurityCheck(this.mediaURL, this.principal);
|
||||
let uri = gContextMenuContentData.documentURIObject;
|
||||
saveImageURL(this.mediaURL, null, "SaveImageTitle", false,
|
||||
false, BrowserUtils.makeURIFromCPOW(doc.documentURIObject), doc);
|
||||
false, uri, doc, gContextMenuContentData.contentType,
|
||||
gContextMenuContentData.contentDisposition);
|
||||
}
|
||||
else if (this.onVideo || this.onAudio) {
|
||||
urlSecurityCheck(this.mediaURL, this.principal);
|
||||
|
@ -3774,6 +3774,8 @@
|
||||
charSet: aMessage.data.charSet,
|
||||
referrer: aMessage.data.referrer,
|
||||
referrerPolicy: aMessage.data.referrerPolicy,
|
||||
contentType: aMessage.data.contentType,
|
||||
contentDisposition: aMessage.data.contentDisposition,
|
||||
};
|
||||
let popup = browser.ownerDocument.getElementById("contentAreaContextMenu");
|
||||
let event = gContextMenuContentData.event;
|
||||
|
@ -99,15 +99,14 @@ const imgICache = Components.interfaces.imgICache;
|
||||
const nsISupportsCString = Components.interfaces.nsISupportsCString;
|
||||
|
||||
function saveImageURL(aURL, aFileName, aFilePickerTitleKey, aShouldBypassCache,
|
||||
aSkipPrompt, aReferrer, aDoc)
|
||||
aSkipPrompt, aReferrer, aDoc, aContentType, aContentDisp)
|
||||
{
|
||||
forbidCPOW(aURL, "saveImageURL", "aURL");
|
||||
forbidCPOW(aReferrer, "saveImageURL", "aReferrer");
|
||||
// Allow aSourceDocument to be a CPOW.
|
||||
|
||||
var contentType = null;
|
||||
var contentDisposition = null;
|
||||
if (!aShouldBypassCache) {
|
||||
if (!aShouldBypassCache &&
|
||||
(!aContentType && !aContentDisp)) {
|
||||
try {
|
||||
var imageCache = Components.classes["@mozilla.org/image/tools;1"]
|
||||
.getService(Components.interfaces.imgITools)
|
||||
@ -115,15 +114,14 @@ function saveImageURL(aURL, aFileName, aFilePickerTitleKey, aShouldBypassCache,
|
||||
var props =
|
||||
imageCache.findEntryProperties(makeURI(aURL, getCharsetforSave(null)));
|
||||
if (props) {
|
||||
contentType = props.get("type", nsISupportsCString);
|
||||
contentDisposition = props.get("content-disposition",
|
||||
nsISupportsCString);
|
||||
aContentType = props.get("type", nsISupportsCString);
|
||||
aContentDisp = props.get("content-disposition", nsISupportsCString);
|
||||
}
|
||||
} catch (e) {
|
||||
// Failure to get type and content-disposition off the image is non-fatal
|
||||
}
|
||||
}
|
||||
internalSave(aURL, null, aFileName, contentDisposition, contentType,
|
||||
internalSave(aURL, null, aFileName, aContentDisp, aContentType,
|
||||
aShouldBypassCache, aFilePickerTitleKey, null, aReferrer,
|
||||
aDoc, aSkipPrompt, null);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user