Bug 1354332 - Update the tab bar layout when the UI density changes. r=johannh a=gchang
authorDão Gottwald <dao@mozilla.com>
Wed, 15 Nov 2017 13:04:49 +0100
changeset 444834 6302eed651dbfc2813dad4da922294ac3ff09a11
parent 444833 1703a61d3d22dfe1ccc852e5260180fea5064b11
child 444835 18de3e3278b73739ad8d023dcac9f2899d4b0fed
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh, gchang
bugs1354332
milestone58.0
Bug 1354332 - Update the tab bar layout when the UI density changes. r=johannh a=gchang 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
@@ -5695,16 +5695,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
@@ -6822,31 +6822,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];