Bug 972822 - Australis - persist the currentset attribute correctly when appending tabgroups button, r=dao
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 20 Feb 2014 17:27:15 +0000
changeset 170819 cf82ac9f81410023b6c76fd8c36f2dd88bf42030
parent 170818 0f152676a9f184fe63743a269498744e795ad337
child 170820 aacb9513c0b55cd9e8c792cd1a919f4af1837394
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersdao
bugs972822
milestone30.0a1
Bug 972822 - Australis - persist the currentset attribute correctly when appending tabgroups button, r=dao
browser/base/content/browser-tabview.js
--- a/browser/base/content/browser-tabview.js
+++ b/browser/base/content/browser-tabview.js
@@ -416,28 +416,26 @@ let TabView = {
   },
 
   // ----------
   // Function: _addToolbarButton
   // Adds the TabView button to the TabsToolbar.
   _addToolbarButton: function TabView__addToolbarButton() {
     let buttonId = "tabview-button";
 
-    if (document.getElementById(buttonId))
+    if (CustomizableUI.getPlacementOfWidget(buttonId))
       return;
 
-    let toolbar = document.getElementById("TabsToolbar");
-    let currentSet = toolbar.currentSet.split(",");
-    let alltabsPos = currentSet.indexOf("alltabs-button");
-    if (-1 == alltabsPos)
-      return;
-
-    let allTabsBtn = document.getElementById("alltabs-button");
-    let nextItem = allTabsBtn.nextSibling;
-    toolbar.insertItem(buttonId, nextItem);
+    let allTabsBtnPlacement = CustomizableUI.getPlacementOfWidget("alltabs-button");
+    // allTabsBtnPlacement can never be null because the button isn't removable
+    let desiredPosition = allTabsBtnPlacement.position + 1;
+    CustomizableUI.addWidgetToArea(buttonId, "TabsToolbar", desiredPosition);
+    // NB: this is for backwards compatibility, and should be removed by
+    // https://bugzilla.mozilla.org/show_bug.cgi?id=976041
+    document.persist("TabsToolbar", "currentset");
   },
 
   // ----------
   // Function: updateGroupNumberBroadcaster
   // Updates the group number broadcaster.
   updateGroupNumberBroadcaster: function TabView_updateGroupNumberBroadcaster(number) {
     let groupsNumber = document.getElementById("tabviewGroupsNumber");
     groupsNumber.setAttribute("groups", number);