Bug 1444530 - Set --tab-min-width in the tabs binding rather than gBrowser.init. r=gijs draft
authorDão Gottwald <dao@mozilla.com>
Sat, 10 Mar 2018 12:13:47 +0100
changeset 765865 855124553cb2962b451269c303d98069be01ad21
parent 765857 0817a733d45a48800e68c9e2a5035fd17bfcdee2
push id102164
push userdgottwald@mozilla.com
push dateSat, 10 Mar 2018 11:14:15 +0000
reviewersgijs
bugs1444530
milestone60.0a1
Bug 1444530 - Set --tab-min-width in the tabs binding rather than gBrowser.init. r=gijs MozReview-Commit-ID: E4EJKerJAng
browser/base/content/tabbrowser.js
browser/base/content/tabbrowser.xml
--- a/browser/base/content/tabbrowser.js
+++ b/browser/base/content/tabbrowser.js
@@ -140,18 +140,16 @@ window._gBrowser = {
     /**
      * List of browsers whose docshells must be active in order for print preview
      * to work.
      */
     this._printPreviewBrowsers = new Set();
 
     this._switcher = null;
 
-    this._tabMinWidthLimit = 50;
-
     this._soundPlayingAttrRemovalTimer = 0;
 
     this._hoverTabTimer = null;
 
     this.mCurrentBrowser = this.initialBrowser;
     this.mCurrentBrowser.permanentKey = {};
 
     Services.obs.addObserver(this, "contextual-identity-updated");
@@ -235,23 +233,16 @@ window._gBrowser = {
     XPCOMUtils.defineLazyPreferenceGetter(this, "schedulePressureDefaultCount",
       "browser.schedulePressure.defaultCount", 3);
     XPCOMUtils.defineLazyPreferenceGetter(this, "tabWarmingEnabled",
       "browser.tabs.remote.warmup.enabled", false);
     XPCOMUtils.defineLazyPreferenceGetter(this, "tabWarmingMax",
       "browser.tabs.remote.warmup.maxTabs", 3);
     XPCOMUtils.defineLazyPreferenceGetter(this, "tabWarmingUnloadDelay" /* ms */,
       "browser.tabs.remote.warmup.unloadDelayMs", 2000);
-    XPCOMUtils.defineLazyPreferenceGetter(this, "tabMinWidthPref",
-      "browser.tabs.tabMinWidth", this._tabMinWidthLimit,
-      (pref, prevValue, newValue) => this.tabMinWidth = newValue,
-      newValue => Math.max(newValue, this._tabMinWidthLimit),
-    );
-
-    this.tabMinWidth = this.tabMinWidthPref;
 
     this._setupEventListeners();
   },
 
   get visibleTabs() {
     if (!this._visibleTabs)
       this._visibleTabs = Array.filter(this.tabs,
         tab => !tab.hidden && !tab.closing);
@@ -447,21 +438,16 @@ window._gBrowser = {
   set userTypedValue(val) {
     return this.mCurrentBrowser.userTypedValue = val;
   },
 
   get userTypedValue() {
     return this.mCurrentBrowser.userTypedValue;
   },
 
-  set tabMinWidth(val) {
-    this.tabContainer.style.setProperty("--tab-min-width", val + "px");
-    return val;
-  },
-
   isFindBarInitialized(aTab) {
     return (aTab || this.selectedTab)._findBar != undefined;
   },
 
   getFindBar(aTab) {
     if (!aTab)
       aTab = this.selectedTab;
 
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -120,16 +120,27 @@
           tab.setAttribute("onerror", "this.removeAttribute('image');");
 
           window.addEventListener("resize", this);
           window.addEventListener("DOMContentLoaded", this);
 
           Services.prefs.addObserver("privacy.userContext", this);
           this.observe(null, "nsPref:changed", "privacy.userContext.enabled");
 
+          XPCOMUtils.defineLazyPreferenceGetter(this, "_tabMinWidthPref",
+            "browser.tabs.tabMinWidth", null,
+            (pref, prevValue, newValue) => this._tabMinWidth = newValue,
+            newValue => {
+              const LIMIT = 50;
+              return Math.max(newValue, LIMIT);
+            },
+          );
+
+          this._tabMinWidth = this._tabMinWidthPref;
+
           this._setPositionalAttributes();
 
           CustomizableUI.addListener(this);
           this._updateNewTabVisibility();
         ]]>
       </constructor>
 
       <destructor>
@@ -167,16 +178,23 @@
       </field>
 
       <property name="tabbrowser" readonly="true">
         <getter>
           return window.gBrowser;
         </getter>
       </property>
 
+      <property name="_tabMinWidth">
+        <setter>
+          this.style.setProperty("--tab-min-width", val + "px");
+          return val;
+        </setter>
+      </property>
+
       <property name="restoreTabsButtonWrapperWidth" readonly="true">
         <getter>
           if (!this._restoreTabsButtonWrapperWidth) {
             this._restoreTabsButtonWrapperWidth = this.windowUtils
               .getBoundsWithoutFlushing(this.restoreTabsButton.parentNode)
               .width;
           }
           return this._restoreTabsButtonWrapperWidth;