Bug 1188787 - Use AppConstants.jsm instead of preprocessing in browser/components/places. r=mak

This commit is contained in:
Muhsin Ali Steiman 2015-08-28 07:37:00 -04:00
parent d91e4371bc
commit 2154145232
7 changed files with 64 additions and 65 deletions

View File

@ -31,17 +31,11 @@ Cu.import("resource://gre/modules/PlacesUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PlacesTransactions",
"resource://gre/modules/PlacesTransactions.jsm");
#ifdef MOZ_SERVICES_CLOUDSYNC
XPCOMUtils.defineLazyModuleGetter(this, "CloudSync",
"resource://gre/modules/CloudSync.jsm");
#else
let CloudSync = null;
#endif
#ifdef MOZ_SERVICES_SYNC
XPCOMUtils.defineLazyModuleGetter(this, "Weave",
"resource://services-sync/main.js");
#endif
// copied from utilityOverlay.js
const TAB_DROP_TYPE = "application/x-moz-tabbrowser-tab";

View File

@ -2,6 +2,7 @@
* 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/AppConstants.jsm");
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
@ -355,12 +356,12 @@ PlacesViewBase.prototype = {
PlacesUtils.livemarks.getLivemark({ id: itemId })
.then(aLivemark => {
element.setAttribute("livemark", "true");
#ifdef XP_MACOSX
// OS X native menubar doesn't track list-style-images since
// it doesn't have a frame (bug 733415). Thus enforce updating.
element.setAttribute("image", "");
element.removeAttribute("image");
#endif
if (AppConstants.platform === "macosx") {
// OS X native menubar doesn't track list-style-images since
// it doesn't have a frame (bug 733415). Thus enforce updating.
element.setAttribute("image", "");
element.removeAttribute("image");
}
this.controller.cacheLivemarkInfo(aPlacesNode, aLivemark);
}, () => undefined);
}
@ -540,12 +541,12 @@ PlacesViewBase.prototype = {
let menu = elt.parentNode;
if (!menu.hasAttribute("livemark")) {
menu.setAttribute("livemark", "true");
#ifdef XP_MACOSX
// OS X native menubar doesn't track list-style-images since
// it doesn't have a frame (bug 733415). Thus enforce updating.
menu.setAttribute("image", "");
menu.removeAttribute("image");
#endif
if (AppConstants.platform === "macosx") {
// OS X native menubar doesn't track list-style-images since
// it doesn't have a frame (bug 733415). Thus enforce updating.
menu.setAttribute("image", "");
menu.removeAttribute("image");
}
}
PlacesUtils.livemarks.getLivemark({ id: aPlacesNode.itemId })
@ -1774,15 +1775,15 @@ function PlacesMenu(aPopupShowingEvent, aPlace, aOptions) {
this._addEventListeners(this._rootElt, ["popupshowing", "popuphidden"], true);
this._addEventListeners(window, ["unload"], false);
#ifdef XP_MACOSX
// Must walk up to support views in sub-menus, like Bookmarks Toolbar menu.
for (let elt = this._viewElt.parentNode; elt; elt = elt.parentNode) {
if (elt.localName == "menubar") {
this._nativeView = true;
break;
if (AppConstants.platform === "macosx") {
// Must walk up to support views in sub-menus, like Bookmarks Toolbar menu.
for (let elt = this._viewElt.parentNode; elt; elt = elt.parentNode) {
if (elt.localName == "menubar") {
this._nativeView = true;
break;
}
}
}
#endif
PlacesViewBase.call(this, aPlace, aOptions);
this._onPopupShowing(aPopupShowingEvent);

View File

@ -1,8 +1,8 @@
<?xml version="1.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/.
<!-- 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/. -->
<bindings id="placesMenuBindings"
xmlns="http://www.mozilla.org/xbl"
@ -26,6 +26,10 @@
<implementation>
<field name="AppConstants" readonly="true">
(Components.utils.import("resource://gre/modules/AppConstants.jsm", {})).AppConstants;
</field>
<field name="_indicatorBar">
document.getAnonymousElementByAttribute(this, "class",
"menupopup-drop-indicator-bar");
@ -304,18 +308,18 @@
if (elt.parentNode != this)
return;
#ifdef XP_MACOSX
// XXX: The following check is a temporary hack until bug 420033 is
// resolved.
let parentElt = elt.parent;
while (parentElt) {
if (parentElt.id == "bookmarksMenuPopup" ||
parentElt.id == "goPopup")
return;
if (this.AppConstants.platform === "macosx") {
// XXX: The following check is a temporary hack until bug 420033 is
// resolved.
let parentElt = elt.parent;
while (parentElt) {
if (parentElt.id == "bookmarksMenuPopup" ||
parentElt.id == "goPopup")
return;
parentElt = parentElt.parentNode;
parentElt = parentElt.parentNode;
}
}
#endif
if (window.XULBrowserWindow) {
let elt = event.target;

View File

@ -3,6 +3,7 @@
* 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/AppConstants.jsm");
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/TelemetryStopwatch.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "MigrationUtils",
@ -113,20 +114,21 @@ var PlacesOrganizer = {
PlacesSearchBox.init();
window.addEventListener("AppCommand", this, true);
#ifdef XP_MACOSX
// 1. Map Edit->Find command to OrganizerCommand_find:all. Need to map
// both the menuitem and the Find key.
var findMenuItem = document.getElementById("menu_find");
findMenuItem.setAttribute("command", "OrganizerCommand_find:all");
var findKey = document.getElementById("key_find");
findKey.setAttribute("command", "OrganizerCommand_find:all");
// 2. Disable some keybindings from browser.xul
var elements = ["cmd_handleBackspace", "cmd_handleShiftBackspace"];
for (var i=0; i < elements.length; i++) {
document.getElementById(elements[i]).setAttribute("disabled", "true");
if (AppConstants.platform === "macosx") {
// 1. Map Edit->Find command to OrganizerCommand_find:all. Need to map
// both the menuitem and the Find key.
let findMenuItem = document.getElementById("menu_find");
findMenuItem.setAttribute("command", "OrganizerCommand_find:all");
let findKey = document.getElementById("key_find");
findKey.setAttribute("command", "OrganizerCommand_find:all");
// 2. Disable some keybindings from browser.xul
let elements = ["cmd_handleBackspace", "cmd_handleShiftBackspace"];
for (let i = 0; i < elements.length; i++) {
document.getElementById(elements[i]).setAttribute("disabled", "true");
}
}
#endif
// remove the "Properties" context-menu item, we've our own details pane
document.getElementById("placesContext")

View File

@ -1,7 +1,8 @@
# -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
# 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/AppConstants.jsm");
var SidebarUtils = {
handleTreeClick: function SU_handleTreeClick(aTree, aEvent, aGutterSelect) {
@ -30,12 +31,9 @@ var SidebarUtils = {
mouseInGutter = aEvent.clientX < rect.x;
}
#ifdef XP_MACOSX
var modifKey = aEvent.metaKey || aEvent.shiftKey;
#else
var modifKey = aEvent.ctrlKey || aEvent.shiftKey;
#endif
var metaKey = AppConstants.platform === "macosx" ? aEvent.metaKey
: aEvent.ctrlKey;
var modifKey = metaKey || aEvent.shiftKey;
var isContainer = tbo.view.isContainer(cell.row);
var openInTabs = isContainer &&
(aEvent.button == 1 ||

View File

@ -8,17 +8,17 @@ browser.jar:
# attributes separately
content/browser/places/bookmarkProperties2.xul (content/bookmarkProperties.xul)
* content/browser/places/places.xul (content/places.xul)
* content/browser/places/places.js (content/places.js)
content/browser/places/places.js (content/places.js)
content/browser/places/places.css (content/places.css)
content/browser/places/organizer.css (content/organizer.css)
content/browser/places/bookmarkProperties.xul (content/bookmarkProperties.xul)
content/browser/places/bookmarkProperties.js (content/bookmarkProperties.js)
content/browser/places/placesOverlay.xul (content/placesOverlay.xul)
* content/browser/places/menu.xml (content/menu.xml)
content/browser/places/menu.xml (content/menu.xml)
content/browser/places/tree.xml (content/tree.xml)
content/browser/places/controller.js (content/controller.js)
content/browser/places/treeView.js (content/treeView.js)
* content/browser/places/browserPlacesViews.js (content/browserPlacesViews.js)
content/browser/places/browserPlacesViews.js (content/browserPlacesViews.js)
# keep the Places version of the history sidebar at history/history-panel.xul
# to prevent having to worry about between versions of the browser
* content/browser/history/history-panel.xul (content/history-panel.xul)
@ -26,7 +26,7 @@ browser.jar:
# ditto for the bookmarks sidebar
content/browser/bookmarks/bookmarksPanel.xul (content/bookmarksPanel.xul)
content/browser/bookmarks/bookmarksPanel.js (content/bookmarksPanel.js)
* content/browser/bookmarks/sidebarUtils.js (content/sidebarUtils.js)
content/browser/bookmarks/sidebarUtils.js (content/sidebarUtils.js)
content/browser/places/moveBookmarks.xul (content/moveBookmarks.xul)
content/browser/places/moveBookmarks.js (content/moveBookmarks.js)
content/browser/places/editBookmarkOverlay.xul (content/editBookmarkOverlay.xul)

View File

@ -10,7 +10,7 @@ BROWSER_CHROME_MANIFESTS += ['tests/browser/browser.ini']
JAR_MANIFESTS += ['jar.mn']
EXTRA_PP_JS_MODULES += [
EXTRA_JS_MODULES += [
'PlacesUIUtils.jsm',
]