Bug 1445728 - fix new tab button adjacency logic to deal with titlebar placeholders and/or indicators appearing in the middle, r=johannh
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 25 Apr 2018 18:07:05 +0100
changeset 472420 dc916a5c4dc81b31f7906df23762e43bca76feef
parent 472419 951b5d2844931ba037eb7d2b21ba4d7af0d82d3f
child 472421 f2e2f5d4f04574ca9838d86a2a70be7ccb709db2
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh
bugs1445728
milestone61.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 1445728 - fix new tab button adjacency logic to deal with titlebar placeholders and/or indicators appearing in the middle, r=johannh MozReview-Commit-ID: J0Pc9afJI5X
browser/base/content/tabbrowser.xml
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -859,20 +859,31 @@
       </method>
 
       <method name="_updateNewTabVisibility">
         <body><![CDATA[
           // Helper functions to help deal with customize mode wrapping some items
           let wrap = n => n.parentNode.localName == "toolbarpaletteitem" ? n.parentNode : n;
           let unwrap = n => n && n.localName == "toolbarpaletteitem" ? n.firstElementChild : n;
 
+          // Starting from the tabs element, find the next sibling that:
+          // - isn't hidden; and
+          // - isn't one of the titlebar placeholder elements; and
+          // - isn't the all-tabs button.
+          // If it's the new tab button, consider the new tab button adjacent to the tabs.
+          // If the new tab button is marked as adjacent and the tabstrip doesn't
+          // overflow, we'll display the 'new tab' button inline in the tabstrip.
+          // In all other cases, the separate new tab button is displayed in its
+          // customized location.
           let sib = this;
           do {
             sib = unwrap(wrap(sib).nextElementSibling);
-          } while (sib && sib.hidden);
+          } while (sib && (sib.hidden ||
+                           sib.getAttribute("skipintoolbarset") == "true" ||
+                           sib.id == "alltabs-button"));
 
           const kAttr = "hasadjacentnewtabbutton";
           if (sib && sib.id == "new-tab-button") {
             this.setAttribute(kAttr, "true");
           } else {
             this.removeAttribute(kAttr);
           }
         ]]></body>