Backed out changeset e9795d97ccf6 (bug 782850) for M1 failures.

This commit is contained in:
Ryan VanderMeulen 2013-01-26 21:19:21 -05:00
parent e3bc654973
commit 6598de3904
11 changed files with 25 additions and 51 deletions

View File

@ -184,7 +184,7 @@
<menuitem id="context-reload"
label="&reloadCmd.label;"
accesskey="&reloadCmd.accesskey;"
oncommand="gContextMenu.reload(event);"
command="Browser:ReloadOrDuplicate"
onclick="checkForMiddleClick(this, event);"/>
<menuitem id="context-stop"
label="&stopCmd.label;"

View File

@ -1107,7 +1107,6 @@
persist="width">
<browser id="social-sidebar-browser"
type="content"
context="contentAreaContextMenu"
disableglobalhistory="true"
flex="1"
style="min-width: 14em; width: 18em; max-width: 36em;"/>

View File

@ -4,20 +4,22 @@
Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
function nsContextMenu(aXulMenu, aIsShift) {
function nsContextMenu(aXulMenu, aBrowser, aIsShift) {
this.shouldDisplay = true;
this.initMenu(aXulMenu, aIsShift);
this.initMenu(aBrowser, aXulMenu, aIsShift);
}
// Prototype for nsContextMenu "class."
nsContextMenu.prototype = {
initMenu: function CM_initMenu(aXulMenu, aIsShift) {
initMenu: function CM_initMenu(aBrowser, aXulMenu, aIsShift) {
// Get contextual info.
this.setTarget(document.popupNode, document.popupRangeParent,
document.popupRangeOffset);
if (!this.shouldDisplay)
return;
this.browser = aBrowser;
this.hasPageMenu = false;
if (!aIsShift) {
this.hasPageMenu = PageMenu.maybeBuildAndAttachMenu(this.target,
@ -152,20 +154,13 @@ nsContextMenu.prototype = {
initNavigationItems: function CM_initNavigationItems() {
var shouldShow = !(this.isContentSelected || this.onLink || this.onImage ||
this.onCanvas || this.onVideo || this.onAudio ||
this.onTextInput || this.onSocial);
this.onTextInput);
this.showItem("context-back", shouldShow);
this.showItem("context-forward", shouldShow);
let stopped = XULBrowserWindow.stopCommand.getAttribute("disabled") == "true";
let stopReloadItem = "";
if (shouldShow || this.onSocial) {
stopReloadItem = (stopped || this.onSocial) ? "reload" : "stop";
}
this.showItem("context-reload", stopReloadItem == "reload");
this.showItem("context-stop", stopReloadItem == "stop");
this.showItem("context-sep-stop", !!stopReloadItem);
var shouldShowReload = XULBrowserWindow.stopCommand.getAttribute("disabled") == "true";
this.showItem("context-reload", shouldShow && shouldShowReload);
this.showItem("context-stop", shouldShow && !shouldShowReload);
this.showItem("context-sep-stop", shouldShow);
// XXX: Stop is determined in browser.js; the canStop broadcaster is broken
//this.setItemAttrFromNode( "context-stop", "disabled", "canStop" );
@ -216,7 +211,7 @@ nsContextMenu.prototype = {
this.onImage || this.onCanvas ||
this.onVideo || this.onAudio ||
this.onLink || this.onTextInput);
var showInspect = !this.onSocial && gPrefService.getBoolPref("devtools.inspector.enabled");
var showInspect = gPrefService.getBoolPref("devtools.inspector.enabled");
this.showItem("context-viewsource", shouldShow);
this.showItem("context-viewinfo", shouldShow);
this.showItem("inspect-separator", showInspect);
@ -273,9 +268,8 @@ nsContextMenu.prototype = {
// Use "Bookmark This Link" if on a link.
this.showItem("context-bookmarkpage",
!(this.isContentSelected || this.onTextInput || this.onLink ||
this.onImage || this.onVideo || this.onAudio || this.onSocial));
this.showItem("context-bookmarklink", (this.onLink && !this.onMailtoLink &&
!this.onSocial) || this.onPlainTextLink);
this.onImage || this.onVideo || this.onAudio));
this.showItem("context-bookmarklink", (this.onLink && !this.onMailtoLink) || this.onPlainTextLink);
this.showItem("context-searchselect", isTextSelected);
this.showItem("context-keywordfield",
this.onTextInput && this.onKeywordField);
@ -480,13 +474,6 @@ nsContextMenu.prototype = {
// Remember the node that was clicked.
this.target = aNode;
this.browser = this.target.ownerDocument.defaultView
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShell)
.chromeEventHandler;
this.onSocial = !!this.browser.getAttribute("origin");
// Check if we are in a synthetic document (stand alone image, video, etc.).
this.inSyntheticDoc = this.target.ownerDocument.mozSyntheticDocument;
// First, do checks for nodes that never have children.
@ -776,18 +763,6 @@ nsContextMenu.prototype = {
referrerURI: referrer ? makeURI(referrer) : null });
},
reload: function(event) {
if (this.onSocial) {
// full reload of social provider
Social.enabled = false;
Services.tm.mainThread.dispatch(function() {
Social.enabled = true;
}, Components.interfaces.nsIThread.DISPATCH_NORMAL);
} else {
BrowserReloadOrDuplicate(event);
}
},
// View Partial Source
viewPartialSource: function(aContext) {
var focusedWindow = document.commandDispatcher.focusedWindow;

View File

@ -15,7 +15,6 @@
oncommand="document.getBindingParent(this).close();"/>
</xul:hbox>
<xul:iframe anonid="iframe" class="chat-frame" flex="1"
context="contentAreaContextMenu"
xbl:inherits="src,origin,collapsed=minimized" type="content"/>
</content>

View File

@ -19,7 +19,7 @@ function onPageShow() {
document.popupNode = frame.document.body;
var contentAreaContextMenu = document.getElementById("contentAreaContextMenu");
var contextMenu = new nsContextMenu(contentAreaContextMenu);
var contextMenu = new nsContextMenu(contentAreaContextMenu, gBrowser);
ok(document.getElementById("frame-sep").hidden, "'frame-sep' should be hidden if the selection contains only spaces");
finish();

View File

@ -32,7 +32,7 @@ function test1Setup() {
document.popupNode = badFrame.document.firstChild;
var contentAreaContextMenu = document.getElementById("contentAreaContextMenu");
var contextMenu = new nsContextMenu(contentAreaContextMenu);
var contextMenu = new nsContextMenu(contentAreaContextMenu, gBrowser);
// We'd like to use another load listener here, but error pages don't fire load events
contextMenu.showOnlyThisFrame();
@ -69,7 +69,7 @@ function test2Setup() {
document.popupNode = badFrame.document.firstChild;
var contentAreaContextMenu = document.getElementById("contentAreaContextMenu");
var contextMenu = new nsContextMenu(contentAreaContextMenu);
var contextMenu = new nsContextMenu(contentAreaContextMenu, gBrowser);
gBrowser.tabContainer.addEventListener("TabOpen", function (event) {
test2tab = event.target;
@ -105,7 +105,7 @@ function test3Setup() {
document.popupNode = badFrame.document.firstChild;
var contentAreaContextMenu = document.getElementById("contentAreaContextMenu");
var contextMenu = new nsContextMenu(contentAreaContextMenu);
var contextMenu = new nsContextMenu(contentAreaContextMenu, gBrowser);
Services.ww.registerNotification(function (aSubject, aTopic, aData) {
if (aTopic == "domwindowopened")

View File

@ -16,7 +16,7 @@ function test() {
document.popupNode = element;
let contentAreaContextMenu = document.getElementById("contentAreaContextMenu");
let contextMenu = new nsContextMenu(contentAreaContextMenu);
let contextMenu = new nsContextMenu(contentAreaContextMenu, gBrowser);
is(contextMenu.shouldDisplay, expected, "context menu behavior for <input type=" + type + "> is wrong");
};
@ -26,7 +26,7 @@ function test() {
document.popupNode = element;
let contentAreaContextMenu = document.getElementById("contentAreaContextMenu");
let contextMenu = new nsContextMenu(contentAreaContextMenu);
let contextMenu = new nsContextMenu(contentAreaContextMenu, gBrowser);
is(contextMenu.shouldDisplay, expected, "context menu behavior for <" + tag + "> is wrong");
};

View File

@ -102,6 +102,6 @@ function test() {
function initContextMenu(aNode) {
document.popupNode = aNode;
let contentAreaContextMenu = document.getElementById("contentAreaContextMenu");
let contextMenu = new nsContextMenu(contentAreaContextMenu);
let contextMenu = new nsContextMenu(contentAreaContextMenu, gBrowser);
return contextMenu;
}

View File

@ -14,7 +14,7 @@ function setSelection(el1, el2, index1, index2) {
function initContextMenu(aNode) {
document.popupNode = aNode;
let contentAreaContextMenu = document.getElementById("contentAreaContextMenu");
let contextMenu = new nsContextMenu(contentAreaContextMenu);
let contextMenu = new nsContextMenu(contentAreaContextMenu, gBrowser);
return contextMenu;
}

View File

@ -50,7 +50,7 @@
<menupopup id="contentAreaContextMenu" pagemenu="start"
onpopupshowing="if (event.target != this)
return true;
gContextMenu = new nsContextMenu(this, event.shiftKey);
gContextMenu = new nsContextMenu(this, getPanelBrowser(), event.shiftKey);
if (gContextMenu.shouldDisplay)
document.popupNode = this.triggerNode;
return gContextMenu.shouldDisplay;"

View File

@ -92,7 +92,7 @@ function testBreadcrumbs(node)
function _clickOnInspectMenuItem(node) {
document.popupNode = node;
var contentAreaContextMenu = document.getElementById("contentAreaContextMenu");
var contextMenu = new nsContextMenu(contentAreaContextMenu);
var contextMenu = new nsContextMenu(contentAreaContextMenu, gBrowser);
return contextMenu.inspectNode();
}
@ -142,3 +142,4 @@ function test()
content.location = "data:text/html,basic tests for inspector";
}