diff --git a/browser/base/content/browser-context.inc b/browser/base/content/browser-context.inc index f9893ddc3527..442d5b1bd147 100644 --- a/browser/base/content/browser-context.inc +++ b/browser/base/content/browser-context.inc @@ -184,7 +184,7 @@ diff --git a/browser/base/content/nsContextMenu.js b/browser/base/content/nsContextMenu.js index f61348999f18..7c912bb4e5d3 100644 --- a/browser/base/content/nsContextMenu.js +++ b/browser/base/content/nsContextMenu.js @@ -4,22 +4,20 @@ Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm"); -function nsContextMenu(aXulMenu, aBrowser, aIsShift) { +function nsContextMenu(aXulMenu, aIsShift) { this.shouldDisplay = true; - this.initMenu(aBrowser, aXulMenu, aIsShift); + this.initMenu(aXulMenu, aIsShift); } // Prototype for nsContextMenu "class." nsContextMenu.prototype = { - initMenu: function CM_initMenu(aBrowser, aXulMenu, aIsShift) { + initMenu: function CM_initMenu(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, @@ -154,13 +152,20 @@ nsContextMenu.prototype = { initNavigationItems: function CM_initNavigationItems() { var shouldShow = !(this.isContentSelected || this.onLink || this.onImage || this.onCanvas || this.onVideo || this.onAudio || - this.onTextInput); + this.onTextInput || this.onSocial); this.showItem("context-back", shouldShow); this.showItem("context-forward", shouldShow); - 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); + + 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); // XXX: Stop is determined in browser.js; the canStop broadcaster is broken //this.setItemAttrFromNode( "context-stop", "disabled", "canStop" ); @@ -211,7 +216,7 @@ nsContextMenu.prototype = { this.onImage || this.onCanvas || this.onVideo || this.onAudio || this.onLink || this.onTextInput); - var showInspect = gPrefService.getBoolPref("devtools.inspector.enabled"); + var showInspect = !this.onSocial && gPrefService.getBoolPref("devtools.inspector.enabled"); this.showItem("context-viewsource", shouldShow); this.showItem("context-viewinfo", shouldShow); this.showItem("inspect-separator", showInspect); @@ -268,8 +273,9 @@ 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.showItem("context-bookmarklink", (this.onLink && !this.onMailtoLink) || this.onPlainTextLink); + this.onImage || this.onVideo || this.onAudio || this.onSocial)); + this.showItem("context-bookmarklink", (this.onLink && !this.onMailtoLink && + !this.onSocial) || this.onPlainTextLink); this.showItem("context-searchselect", isTextSelected); this.showItem("context-keywordfield", this.onTextInput && this.onKeywordField); @@ -474,6 +480,13 @@ 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. @@ -763,6 +776,18 @@ 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; diff --git a/browser/base/content/socialchat.xml b/browser/base/content/socialchat.xml index 0ba411b64b8f..8db77735ac56 100644 --- a/browser/base/content/socialchat.xml +++ b/browser/base/content/socialchat.xml @@ -15,6 +15,7 @@ oncommand="document.getBindingParent(this).close();"/> diff --git a/browser/base/content/test/browser_bug417483.js b/browser/base/content/test/browser_bug417483.js index 9144e0c910e3..ab6d73ae500b 100644 --- a/browser/base/content/test/browser_bug417483.js +++ b/browser/base/content/test/browser_bug417483.js @@ -19,7 +19,7 @@ function onPageShow() { document.popupNode = frame.document.body; var contentAreaContextMenu = document.getElementById("contentAreaContextMenu"); - var contextMenu = new nsContextMenu(contentAreaContextMenu, gBrowser); + var contextMenu = new nsContextMenu(contentAreaContextMenu); ok(document.getElementById("frame-sep").hidden, "'frame-sep' should be hidden if the selection contains only spaces"); finish(); diff --git a/browser/base/content/test/browser_bug423833.js b/browser/base/content/test/browser_bug423833.js index 04c9024615e1..d4069338b792 100644 --- a/browser/base/content/test/browser_bug423833.js +++ b/browser/base/content/test/browser_bug423833.js @@ -32,7 +32,7 @@ function test1Setup() { document.popupNode = badFrame.document.firstChild; var contentAreaContextMenu = document.getElementById("contentAreaContextMenu"); - var contextMenu = new nsContextMenu(contentAreaContextMenu, gBrowser); + var contextMenu = new nsContextMenu(contentAreaContextMenu); // 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, gBrowser); + var contextMenu = new nsContextMenu(contentAreaContextMenu); 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, gBrowser); + var contextMenu = new nsContextMenu(contentAreaContextMenu); Services.ww.registerNotification(function (aSubject, aTopic, aData) { if (aTopic == "domwindowopened") diff --git a/browser/base/content/test/browser_bug424101.js b/browser/base/content/test/browser_bug424101.js index f66f04af3102..7c9599e69d97 100644 --- a/browser/base/content/test/browser_bug424101.js +++ b/browser/base/content/test/browser_bug424101.js @@ -16,7 +16,7 @@ function test() { document.popupNode = element; let contentAreaContextMenu = document.getElementById("contentAreaContextMenu"); - let contextMenu = new nsContextMenu(contentAreaContextMenu, gBrowser); + let contextMenu = new nsContextMenu(contentAreaContextMenu); is(contextMenu.shouldDisplay, expected, "context menu behavior for is wrong"); }; @@ -26,7 +26,7 @@ function test() { document.popupNode = element; let contentAreaContextMenu = document.getElementById("contentAreaContextMenu"); - let contextMenu = new nsContextMenu(contentAreaContextMenu, gBrowser); + let contextMenu = new nsContextMenu(contentAreaContextMenu); is(contextMenu.shouldDisplay, expected, "context menu behavior for <" + tag + "> is wrong"); }; diff --git a/browser/base/content/test/browser_bug734076.js b/browser/base/content/test/browser_bug734076.js index f9962f857d45..3e1cae71693a 100644 --- a/browser/base/content/test/browser_bug734076.js +++ b/browser/base/content/test/browser_bug734076.js @@ -102,6 +102,6 @@ function test() { function initContextMenu(aNode) { document.popupNode = aNode; let contentAreaContextMenu = document.getElementById("contentAreaContextMenu"); - let contextMenu = new nsContextMenu(contentAreaContextMenu, gBrowser); + let contextMenu = new nsContextMenu(contentAreaContextMenu); return contextMenu; } diff --git a/browser/base/content/test/browser_plainTextLinks.js b/browser/base/content/test/browser_plainTextLinks.js index 8b48adcd6c7e..4c7c8ee981ec 100644 --- a/browser/base/content/test/browser_plainTextLinks.js +++ b/browser/base/content/test/browser_plainTextLinks.js @@ -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, gBrowser); + let contextMenu = new nsContextMenu(contentAreaContextMenu); return contextMenu; } diff --git a/browser/base/content/web-panels.xul b/browser/base/content/web-panels.xul index e23f5b4df276..581b5792747a 100644 --- a/browser/base/content/web-panels.xul +++ b/browser/base/content/web-panels.xul @@ -50,7 +50,7 @@