diff --git a/browser/base/content/browser.css b/browser/base/content/browser.css index 2a04a2ac0c5..8a9bd968d64 100644 --- a/browser/base/content/browser.css +++ b/browser/base/content/browser.css @@ -9,10 +9,14 @@ searchbar { -moz-binding: url("chrome://browser/content/search/search.xml#searchbar"); } -#nav-bar { +toolbar[customizable="true"] { -moz-binding: url("chrome://browser/content/customizableui/toolbar.xml#toolbar"); } +#toolbar-menubar[autohide="true"] { + -moz-binding: url("chrome://browser/content/customizableui/toolbar.xml#toolbar-menubar-autohide"); +} + tabbrowser { -moz-binding: url("chrome://browser/content/tabbrowser.xml#tabbrowser"); } diff --git a/browser/base/content/browser.xul b/browser/base/content/browser.xul index 01abe7ad6fc..a47dff557ac 100644 --- a/browser/base/content/browser.xul +++ b/browser/base/content/browser.xul @@ -1186,7 +1186,6 @@ mode="icons" iconsize="small" defaulticonsize="small" lockiconsize="true" defaultset="addonbar-closebutton,spring,status-bar" - customizable="true" key="key_toggleAddonBar"> + + + + + + this._setInactive(); + + + null + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + diff --git a/browser/components/customizableui/src/CustomizableUI.jsm b/browser/components/customizableui/src/CustomizableUI.jsm index e078f08bd64..de9902497b4 100644 --- a/browser/components/customizableui/src/CustomizableUI.jsm +++ b/browser/components/customizableui/src/CustomizableUI.jsm @@ -223,6 +223,15 @@ let gFuturePlacements = new Map(); * placements to use. */ let gDefaultPlacements = new Map([ + ["toolbar-menubar", [ + "menubar-items", + ]], + ["TabsToolbar", [ + "tabbrowser-tabs", + "new-tab-button", + "alltabs-button", + "tabs-closebutton" + ]], ["nav-bar", [ "unified-back-forward-button", "urlbar-container", @@ -236,6 +245,9 @@ let gDefaultPlacements = new Map([ "social-toolbar-button", "share-page" ]], + ["PersonalToolbar", [ + "personal-bookmarks", + ]], ["PanelUI-contents", [ "new-window-button", "print-button", @@ -294,6 +306,9 @@ let CustomizableUIInternal = { this.registerArea(CustomizableUI.AREA_PANEL); this.registerArea(CustomizableUI.AREA_NAVBAR, ["legacy"]); + this.registerArea(CustomizableUI.AREA_MENUBAR, ["legacy"]); + this.registerArea(CustomizableUI.AREA_TABSTRIP, ["legacy"]); + this.registerArea(CustomizableUI.AREA_BOOKMARKS, ["legacy"]); }, _defineBuiltInWidgets: function() { @@ -347,7 +362,7 @@ let CustomizableUIInternal = { let area = aToolbar.id; if (!gAreas.has(area)) { - throw new Error("Unknown customization area"); + throw new Error("Unknown customization area: " + area); } if (this.isBuildAreaRegistered(area, aToolbar)) { @@ -361,12 +376,6 @@ let CustomizableUIInternal = { if (legacyState) { legacyState = legacyState.split(","); } - //XXXunf should the legacy attribute be purged? - // kinda messes up switching to older builds - //XXXmconley No, I don't think so - I think we want to make it easy to - // switch back and forth between builds until this thing hits - // release. - //aToolbar.removeAttribute("currentset"); // Manually restore the state here, so the legacy state can be converted. this.restoreStateForArea(area, legacyState); @@ -378,8 +387,8 @@ let CustomizableUIInternal = { this.buildArea(area, placements, aToolbar); aToolbar.setAttribute("currentset", placements.join(",")); - // We register this window to have its customization data cleaned up when - // unloading. + // We ensure that the window is registered to have its customization data + // cleaned up when unloading. this.registerBuildWindow(document.defaultView); }, @@ -395,6 +404,7 @@ let CustomizableUIInternal = { let currentNode = container.firstChild; for (let id of aPlacements) { if (currentNode && currentNode.id == id) { + this._addParentFlex(currentNode); currentNode = currentNode.nextSibling; continue; } @@ -483,6 +493,7 @@ let CustomizableUIInternal = { this.buildWidget(aDocument, null, widget) ]; } + LOG("Searching for " + aWidgetId + " in toolbox."); let node = this.findWidgetInToolbox(aWidgetId, aToolbox, aDocument); if (node) { return [ CustomizableUI.PROVIDER_XUL, node ]; @@ -815,7 +826,7 @@ let CustomizableUIInternal = { LOG("Iterating the actual nodes of the window palette"); for (let node of aWindowPalette.children) { LOG("In palette children: " + node.id); - if (!this.getPlacementOfWidget(node.id)) { + if (node.id && !this.getPlacementOfWidget(node.id)) { widgets.add(node.id); } } @@ -838,7 +849,7 @@ let CustomizableUIInternal = { addWidgetToArea: function(aWidgetId, aArea, aPosition) { if (!gAreas.has(aArea)) { - throw new Error("Unknown customization area"); + throw new Error("Unknown customization area: " + aArea); } // If this is a lazy area that hasn't been restored yet, we can't yet modify @@ -1465,6 +1476,9 @@ Object.freeze(CustomizableUIInternal); this.CustomizableUI = { get AREA_PANEL() "PanelUI-contents", get AREA_NAVBAR() "nav-bar", + get AREA_MENUBAR() "toolbar-menubar", + get AREA_TABSTRIP() "TabsToolbar", + get AREA_BOOKMARKS() "PersonalToolbar", get PROVIDER_XUL() "xul", get PROVIDER_API() "api", @@ -1525,7 +1539,7 @@ this.CustomizableUI = { }, getWidgetsInArea: function(aArea) { if (!gAreas.has(aArea)) { - throw new Error("Unknown customization area"); + throw new Error("Unknown customization area: " + aArea); } if (!gPlacements.has(aArea)) { throw new Error("Area not yet restored"); diff --git a/browser/components/customizableui/src/CustomizeMode.jsm b/browser/components/customizableui/src/CustomizeMode.jsm index 1578969949a..32981b1c755 100644 --- a/browser/components/customizableui/src/CustomizeMode.jsm +++ b/browser/components/customizableui/src/CustomizeMode.jsm @@ -12,6 +12,9 @@ const kPrefCustomizationDebug = "browser.uiCustomization.debug"; const kPaletteId = "customization-palette"; const kAboutURI = "about:customizing"; +Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource:///modules/CustomizableUI.jsm"); + let gDebug = false; try { gDebug = Services.prefs.getBoolPref(kPrefCustomizationDebug); @@ -19,15 +22,12 @@ try { function LOG(str) { if (gDebug) { - Services.console.logStringMessage(str); + Services.console.logStringMessage("[CustomizeMode] " + str); } } function ERROR(aMsg) Cu.reportError("[CustomizeMode] " + aMsg); -Cu.import("resource://gre/modules/Services.jsm"); -Cu.import("resource:///modules/CustomizableUI.jsm"); - function CustomizeMode(aWindow) { this.window = aWindow; this.document = aWindow.document; @@ -68,6 +68,10 @@ CustomizeMode.prototype = { }, enter: function() { + if (this._customizing) { + return; + } + let window = this.window; let document = this.document; @@ -124,7 +128,9 @@ CustomizeMode.prototype = { target.addEventListener("dragexit", self); target.addEventListener("drop", self); for (let child of target.children) { - self.wrapToolbarItem(child, getPlaceForItem(child)); + if (self.isCustomizableItem(child)) { + self.wrapToolbarItem(child, getPlaceForItem(child)); + } } self.areas.push(target); } @@ -142,6 +148,10 @@ CustomizeMode.prototype = { }, exit: function() { + if (!this._customizing) { + return; + } + CustomizableUI.removeListener(this); let deck = this.document.getElementById("tab-view-deck"); @@ -172,7 +182,9 @@ CustomizeMode.prototype = { for (let target of this.areas) { for (let toolbarItem of target.children) { - this.unwrapToolbarItem(toolbarItem); + if (this.isWrappedToolbarItem(toolbarItem)) { + this.unwrapToolbarItem(toolbarItem); + } } target.removeEventListener("dragstart", this); target.removeEventListener("dragover", this); @@ -280,6 +292,18 @@ CustomizeMode.prototype = { this.window.gNavToolbox.palette = this._stowedPalette; }, + isCustomizableItem: function(aNode) { + return aNode.localName == "toolbarbutton" || + aNode.localName == "toolbaritem" || + aNode.localName == "toolbarseparator" || + aNode.localName == "toolbarspring" || + aNode.localName == "toolbarspacer"; + }, + + isWrappedToolbarItem: function(aNode) { + return aNode.localName == "toolbarpaletteitem"; + }, + wrapToolbarItem: function(aNode, aPlace) { let wrapper = this.createWrapper(aNode, aPlace); // It's possible that this toolbar node is "mid-flight" and doesn't have @@ -370,17 +394,13 @@ CustomizeMode.prototype = { return toolbarItem; }, - //XXXjaws This doesn't handle custom toolbars. - //XXXmconley While CustomizableUI.jsm uses prefs to preserve state, we might - // also want to (try) persisting with currentset as well to make it - // less painful to switch to older builds. persistCurrentSets: function() { let document = this.document; - let toolbars = document.querySelectorAll("toolbar"); - + let toolbars = document.querySelectorAll("toolbar[customizable='true']"); for (let toolbar of toolbars) { - // Calculate currentset and store it in the attribute. - toolbar.setAttribute("currentset", toolbar.currentSet); + let set = toolbar.currentSet; + toolbar.setAttribute("currentset", set); + LOG("Setting currentset of " + toolbar.id + " as " + set); // Persist the currentset attribute directly on hardcoded toolbars. document.persist(toolbar.id, "currentset"); } diff --git a/browser/themes/windows/browser-aero.css b/browser/themes/windows/browser-aero.css index defe92dc86c..8c1b490fce1 100644 --- a/browser/themes/windows/browser-aero.css +++ b/browser/themes/windows/browser-aero.css @@ -257,7 +257,7 @@ #nav-bar[tabsontop=false], #nav-bar + #customToolbars + #PersonalToolbar[collapsed="true"] + #TabsToolbar[tabsontop="false"]:last-child, #navigator-toolbox > toolbar:not(#toolbar-menubar):-moz-lwtheme { - -moz-binding: url("chrome://global/content/bindings/toolbar.xml#toolbar-drag"); + -moz-binding: url("chrome://browser/content/customizableui/toolbar.xml#toolbar-drag"); } #appcontent:not(:-moz-lwtheme) {