--- a/browser/base/content/nsContextMenu.js
+++ b/browser/base/content/nsContextMenu.js
@@ -1,13 +1,13 @@
/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ts=2 sw=2 sts=2 et tw=80: */
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Components.utils.import("resource://gre/modules/ContextualIdentityService.jsm");
Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
Components.utils.import("resource://gre/modules/InlineSpellChecker.jsm");
Components.utils.import("resource://gre/modules/LoginManagerContextMenu.jsm");
Components.utils.import("resource://gre/modules/BrowserUtils.jsm");
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
@@ -256,22 +256,24 @@ nsContextMenu.prototype = {
this.showItem("inspect-separator", showInspect);
this.showItem("context-inspect", showInspect);
this.showItem("context-sep-viewsource", shouldShow);
// Set as Desktop background depends on whether an image was clicked on,
// and only works if we have a shell service.
var haveSetDesktopBackground = false;
-#ifdef HAVE_SHELL_SERVICE
- // Only enable Set as Desktop Background if we can get the shell service.
- var shell = getShellService();
- if (shell)
- haveSetDesktopBackground = shell.canSetDesktopBackground;
-#endif
+
+ if (AppConstants.HAVE_SHELL_SERVICE) {
+ // Only enable Set as Desktop Background if we can get the shell service.
+ var shell = getShellService();
+ if (shell)
+ haveSetDesktopBackground = shell.canSetDesktopBackground;
+ }
+
this.showItem("context-setDesktopBackground",
haveSetDesktopBackground && this.onLoadedImage);
if (haveSetDesktopBackground && this.onLoadedImage) {
document.getElementById("context-setDesktopBackground")
.disabled = gContextMenuContentData.disableSetDesktopBackground;
}
@@ -442,20 +444,21 @@ nsContextMenu.prototype = {
// Copy email link depends on whether we're on an email link.
this.showItem("context-copyemail", this.onMailtoLink);
// Copy link location depends on whether we're on a non-mailto link.
this.showItem("context-copylink", this.onLink && !this.onMailtoLink);
this.showItem("context-sep-copylink", this.onLink &&
(this.onImage || this.onVideo || this.onAudio));
-#ifdef CONTEXT_COPY_IMAGE_CONTENTS
// Copy image contents depends on whether we're on an image.
+ // Note: the element doesn't exist on all platforms, but showItem() takes
+ // care of that by itself.
this.showItem("context-copyimage-contents", this.onImage);
-#endif
+
// Copy image location depends on whether we're on an image.
this.showItem("context-copyimage", this.onImage);
this.showItem("context-copyvideourl", this.onVideo);
this.showItem("context-copyaudiourl", this.onAudio);
this.setItemAttr("context-copyvideourl", "disabled", !this.mediaURL);
this.setItemAttr("context-copyaudiourl", "disabled", !this.mediaURL);
this.showItem("context-sep-copyimage", this.onImage ||
this.onVideo || this.onAudio);
@@ -1208,37 +1211,38 @@ nsContextMenu.prototype = {
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";
-#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 {
+
+ if (AppConstants.platform == "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.
openDialog(kDesktopBackgroundURL, "",
- "centerscreen,chrome,dialog=no,dependent,resizable=no",
+ "centerscreen,chrome,dialog,modal,dependent",
image);
}
-#else
- // On non-Mac platforms, the Set Wallpaper dialog is modal.
- openDialog(kDesktopBackgroundURL, "",
- "centerscreen,chrome,dialog,modal,dependent",
- image);
-#endif
};
mm.addMessageListener("ContextMenu:SetAsDesktopBackground:Result", onMessage);
},
// Save URL of clicked-on frame.
saveFrame: function () {
saveBrowser(this.browser, false, this.frameOuterWindowID);
@@ -1508,17 +1512,24 @@ nsContextMenu.prototype = {
getService(Ci.nsIClipboardHelper);
clipboard.copyString(linkURL);
},
///////////////
// Utilities //
///////////////
- // Show/hide one item (specified via name or the item element itself).
+ /**
+ * Show/hide one item (specified via name or the item element itself).
+ * If the element is not found, then this function finishes silently.
+ *
+ * @param {Element|String} aItemOrId The item element or the name of the element
+ * to show.
+ * @param {Boolean} aShow Set to true to show the item, false to hide it.
+ */
showItem: function(aItemOrId, aShow) {
var item = aItemOrId.constructor == String ?
document.getElementById(aItemOrId) : aItemOrId;
if (item)
item.hidden = !aShow;
},
// Set given attribute of specified context-menu item. If the
--- a/browser/base/moz.build
+++ b/browser/base/moz.build
@@ -36,17 +36,16 @@ BROWSER_CHROME_MANIFESTS += [
]
DEFINES['MOZ_APP_VERSION'] = CONFIG['MOZ_APP_VERSION']
DEFINES['MOZ_APP_VERSION_DISPLAY'] = CONFIG['MOZ_APP_VERSION_DISPLAY']
DEFINES['APP_LICENSE_BLOCK'] = '%s/content/overrides/app-license.html' % SRCDIR
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'gtk2', 'gtk3', 'cocoa'):
- DEFINES['HAVE_SHELL_SERVICE'] = 1
DEFINES['CONTEXT_COPY_IMAGE_CONTENTS'] = 1
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'cocoa'):
DEFINES['CAN_DRAW_IN_TITLEBAR'] = 1
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'gtk2', 'gtk3'):
DEFINES['MENUBAR_CAN_AUTOHIDE'] = 1