Bug 939955 - move widgets to palette in Australis if add-on bar was hidden pre-Australis, r=mconley
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 26 Nov 2013 23:26:34 +0100
changeset 157723 6f55de7392337a47fa333e8b261a2b193c370f45
parent 157722 a1c1679379fdc0bb3fda6e4c7742f94a2919e4c1
child 157724 e1214a4d199bff4717fb4d8a0078893b54385622
push id25721
push usercbook@mozilla.com
push dateWed, 27 Nov 2013 10:02:03 +0000
treeherdermozilla-central@6ecf0c4dfcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs939955
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 939955 - move widgets to palette in Australis if add-on bar was hidden pre-Australis, r=mconley
browser/components/customizableui/content/toolbar.xml
--- a/browser/components/customizableui/content/toolbar.xml
+++ b/browser/components/customizableui/content/toolbar.xml
@@ -373,16 +373,17 @@
 
 <!-- This is a peculiar binding. It is here to deal with overlayed/inserted add-on content,
       and immediately direct such content elsewhere. -->
   <binding id="addonbar-delegating">
     <implementation>
       <constructor><![CDATA[
           // Reading these immediately so nobody messes with them anymore:
           this._delegatingToolbar = this.getAttribute("toolbar-delegate");
+          this._wasCollapsed = this.getAttribute("collapsed");
           // Leaving those in here to unbreak some code:
           if (document.readyState == "complete") {
             this._init();
           } else {
             // Need to wait until XUL overlays are loaded. See bug 554279.
             let self = this;
             document.addEventListener("readystatechange", function onReadyStateChange() {
               if (document.readyState != "complete")
@@ -450,30 +451,38 @@
         <parameter name="aNode"/>
         <body>
         <![CDATA[
           if (this._whiteListed.has(aNode.id) || CustomizableUI.isSpecialWidget(aNode.id)) {
             return;
           }
           const kItemMaxWidth = 100;
           let oldParent = aNode.parentNode;
-
-          try {
-            aNode.setAttribute("removable", "true");
+          aNode.setAttribute("removable", "true");
 
-            let nodeWidth = aNode.getBoundingClientRect().width;
-            if (nodeWidth == 0 || nodeWidth > kItemMaxWidth) {
-              throw new Error(aNode.id + " is too big (" + nodeWidth +
-                              "px wide), moving to the palette");
+          let movedOut = false;
+          if (!this._wasCollapsed) {
+            try {
+              let nodeWidth = aNode.getBoundingClientRect().width;
+              if (nodeWidth == 0 || nodeWidth > kItemMaxWidth) {
+                throw new Error(aNode.id + " is too big (" + nodeWidth +
+                                "px wide), moving to the palette");
+              }
+              CustomizableUI.addWidgetToArea(aNode.id, this._delegatingToolbar);
+              movedOut = true;
+            } catch (ex) {
+              // This will throw if the node is too big, or can't be moved there for
+              // some reason. Report this:
+              Cu.reportError(ex);
             }
-            CustomizableUI.addWidgetToArea(aNode.id, this._delegatingToolbar);
-          } catch (ex) {
-            Cu.reportError(ex);
-            // This will throw if the node is too big, or can't be moved there for
-            // some reason. Try to remove it anyway:
+          }
+
+          /* We won't have moved the widget if either the add-on bar was collapsed,
+           * or if it was too wide to be inserted into the navbar. */
+          if (!movedOut) {
             try {
               CustomizableUI.removeWidgetFromArea(aNode.id);
             } catch (ex) {
               Cu.reportError(ex);
               aNode.remove();
             }
           }