Bug 1354332 - Update the tab bar layout when the UI density changes. r=johannh
authorDão Gottwald <dao@mozilla.com>
Wed, 15 Nov 2017 13:04:49 +0100
changeset 392193 034443b19f2b70b45c382b0ae61fc52fddcc76cb
parent 392192 86f4338a514f364c5ec3cc385631b0f621862672
child 392194 54321e8fe9281d657430fe90d7ad6d1be12d5072
push id32915
push useraciure@mozilla.com
push dateFri, 17 Nov 2017 09:57:26 +0000
treeherdermozilla-central@249a8177ad91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh
bugs1354332
milestone59.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 1354332 - Update the tab bar layout when the UI density changes. r=johannh MozReview-Commit-ID: 1HGVirulaE3
browser/base/content/browser.js
browser/base/content/tabbrowser.xml
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -5690,16 +5690,17 @@ var gUIDensity = {
     if (tree) {
       // Tree items don't update their styles without changing some property on the
       // parent tree element, like background-color or border. See bug 1407399.
       tree.style.border = "1px";
       tree.style.border = "";
     }
 
     TabsInTitlebar.updateAppearance(true);
+    gBrowser.tabContainer.uiDensityChanged();
   },
 };
 
 var gHomeButton = {
   prefDomain: "browser.startup.homepage",
   observe(aSubject, aTopic, aPrefName) {
     if (aTopic != "nsPref:changed" || aPrefName != this.prefDomain)
       return;
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -6818,31 +6818,42 @@
 
           if (this.hasAttribute("using-closing-tabs-spacer")) {
             this.removeAttribute("using-closing-tabs-spacer");
             this._closingTabsSpacer.style.width = 0;
           }
         ]]></body>
       </method>
 
+      <method name="uiDensityChanged">
+        <body><![CDATA[
+          this._positionPinnedTabs();
+          this._updateCloseButtons();
+          this._handleTabSelect(true);
+        ]]></body>
+      </method>
+
       <field name="_lastNumPinned">0</field>
       <field name="_pinnedTabsLayoutCache">null</field>
       <method name="_positionPinnedTabs">
         <body><![CDATA[
           var numPinned = this.tabbrowser._numPinnedTabs;
           var doPosition = this.getAttribute("overflow") == "true" &&
                            numPinned > 0;
 
           if (doPosition) {
             this.setAttribute("positionpinnedtabs", "true");
 
             let layoutData = this._pinnedTabsLayoutCache;
-            if (!layoutData) {
+            let uiDensity = document.documentElement.getAttribute("uidensity");
+            if (!layoutData ||
+                layoutData.uiDensity != uiDensity) {
               let arrowScrollbox = this.arrowScrollbox;
               layoutData = this._pinnedTabsLayoutCache = {
+                uiDensity,
                 pinnedTabWidth: this.childNodes[0].getBoundingClientRect().width,
                 scrollButtonWidth: arrowScrollbox._scrollButtonDown.getBoundingClientRect().width
               };
             }
 
             let width = 0;
             for (let i = numPinned - 1; i >= 0; i--) {
               let tab = this.childNodes[i];