Backed out changeset 2a114efdfc3f (bug 1135933) for making browser_addKeywordSearch.js permafail.

CLOSED TREE
This commit is contained in:
Ryan VanderMeulen
2015-05-29 12:25:09 -04:00
parent dd4904d1a0
commit 8647b4ec2d
3 changed files with 50 additions and 91 deletions

View File

@@ -101,7 +101,6 @@ let handleContentContextMenu = function (event) {
let frameOuterWindowID = doc.defaultView.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils)
.outerWindowID;
let disableSetDesktopBg = disableSetDesktopBackground(event.target);
// Media related cache info parent needs for saving
let contentType = null;
@@ -149,7 +148,7 @@ let handleContentContextMenu = function (event) {
{ editFlags, spellInfo, customMenuItems, addonInfo,
principal, docLocation, charSet, baseURI, referrer,
referrerPolicy, contentType, contentDisposition,
frameOuterWindowID, selectionInfo, disableSetDesktopBg },
frameOuterWindowID, selectionInfo },
{ event, popupNode: event.target });
}
else {
@@ -170,7 +169,6 @@ let handleContentContextMenu = function (event) {
contentType: contentType,
contentDisposition: contentDisposition,
selectionInfo: selectionInfo,
disableSetDesktopBackground: disableSetDesktopBg,
};
}
}
@@ -736,52 +734,3 @@ addMessageListener("ContextMenu:SearchFieldBookmarkData", (message) => {
sendAsyncMessage("ContextMenu:SearchFieldBookmarkData:Result",
{ spec, title, description, postData, charset });
});
function disableSetDesktopBackground(aTarget) {
// Disable the Set as Desktop Background menu item if we're still trying
// to load the image or the load failed.
if (!(aTarget instanceof Ci.nsIImageLoadingContent))
return true;
if (("complete" in aTarget) && !aTarget.complete)
return true;
if (aTarget.currentURI.schemeIs("javascript"))
return true;
let request = aTarget.QueryInterface(Ci.nsIImageLoadingContent)
.getRequest(Ci.nsIImageLoadingContent.CURRENT_REQUEST);
if (!request)
return true;
return false;
}
addMessageListener("ContextMenu:SetAsDesktopBackground", (message) => {
let target = message.objects.target;
// Paranoia: check disableSetDesktopBackground again, in case the
// image changed since the context menu was initiated.
let disable = disableSetDesktopBackground(target);
if (!disable) {
try {
BrowserUtils.urlSecurityCheck(target.currentURI.spec, target.ownerDocument.nodePrincipal);
let canvas = content.document.createElement("canvas");
canvas.width = target.naturalWidth;
canvas.height = target.naturalHeight;
let ctx = canvas.getContext("2d");
ctx.drawImage(target, 0, 0);
let dataUrl = canvas.toDataURL();
sendAsyncMessage("ContextMenu:SetAsDesktopBackground:Result",
{ dataUrl });
}
catch (e) {
Cu.reportError(e);
disable = true;
}
}
if (disable)
sendAsyncMessage("ContextMenu:SetAsDesktopBackground:Result", { disable });
});

View File

@@ -260,7 +260,7 @@ nsContextMenu.prototype = {
if (haveSetDesktopBackground && this.onLoadedImage) {
document.getElementById("context-setDesktopBackground")
.disabled = gContextMenuContentData.disableSetDesktopBackground;
.disabled = this.disableSetDesktopBackground();
}
// Reload image depends on an image that's not fully loaded
@@ -1149,49 +1149,60 @@ nsContextMenu.prototype = {
referrerURI: gContextMenuContentData.documentURIObject });
},
disableSetDesktopBackground: function() {
// Disable the Set as Desktop Background menu item if we're still trying
// to load the image or the load failed.
if (!(this.target instanceof Ci.nsIImageLoadingContent))
return true;
if (("complete" in this.target) && !this.target.complete)
return true;
if (this.target.currentURI.schemeIs("javascript"))
return true;
var request = this.target
.QueryInterface(Ci.nsIImageLoadingContent)
.getRequest(Ci.nsIImageLoadingContent.CURRENT_REQUEST);
if (!request)
return true;
return false;
},
setDesktopBackground: function() {
let mm = this.browser.messageManager;
// Paranoia: check disableSetDesktopBackground again, in case the
// image changed since the context menu was initiated.
if (this.disableSetDesktopBackground())
return;
mm.sendAsyncMessage("ContextMenu:SetAsDesktopBackground", null,
{ target: this.target });
var doc = this.target.ownerDocument;
urlSecurityCheck(this.target.currentURI.spec, this.principal);
let onMessage = (message) => {
mm.removeMessageListener("ContextMenu:SetAsDesktopBackground:Result",
onMessage);
if (message.data.disable)
return;
let image = document.createElementNS('http://www.w3.org/1999/xhtml', 'img');
image.src = message.data.dataUrl;
// Confirm since it's annoying if you hit this accidentally.
const kDesktopBackgroundURL =
"chrome://browser/content/setDesktopBackground.xul";
// Confirm since it's annoying if you hit this accidentally.
const kDesktopBackgroundURL =
"chrome://browser/content/setDesktopBackground.xul";
#ifdef XP_MACOSX
// On Mac, the Set Desktop Background window is not modal.
// Don't open more than one Set Desktop Background window.
const wm = Cc["@mozilla.org/appshell/window-mediator;1"].
getService(Ci.nsIWindowMediator);
let dbWin = wm.getMostRecentWindow("Shell:SetDesktopBackground");
if (dbWin) {
dbWin.gSetBackground.init(image);
dbWin.focus();
}
else {
openDialog(kDesktopBackgroundURL, "",
"centerscreen,chrome,dialog=no,dependent,resizable=no",
image);
}
#else
// On non-Mac platforms, the Set Wallpaper dialog is modal.
// On Mac, the Set Desktop Background window is not modal.
// Don't open more than one Set Desktop Background window.
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var dbWin = wm.getMostRecentWindow("Shell:SetDesktopBackground");
if (dbWin) {
dbWin.gSetBackground.init(this.target);
dbWin.focus();
}
else {
openDialog(kDesktopBackgroundURL, "",
"centerscreen,chrome,dialog,modal,dependent",
image);
"centerscreen,chrome,dialog=no,dependent,resizable=no",
this.target);
}
#else
// On non-Mac platforms, the Set Wallpaper dialog is modal.
openDialog(kDesktopBackgroundURL, "",
"centerscreen,chrome,dialog,modal,dependent",
this.target);
#endif
};
mm.addMessageListener("ContextMenu:SetAsDesktopBackground:Result", onMessage);
},
// Save URL of clicked-on frame.

View File

@@ -3847,7 +3847,6 @@
contentDisposition: aMessage.data.contentDisposition,
frameOuterWindowID: aMessage.data.frameOuterWindowID,
selectionInfo: aMessage.data.selectionInfo,
disableSetDesktopBackground: aMessage.data.disableSetDesktopBg,
};
let popup = browser.ownerDocument.getElementById("contentAreaContextMenu");
let event = gContextMenuContentData.event;