Bug 1389744 - Stop repositioning pinned tabs when (un)selecting the Dark/Light theme. r?florian draft
authorDão Gottwald <dao@mozilla.com>
Sat, 12 Aug 2017 12:50:26 +0200
changeset 645277 43f7351a1621465b550f3a4d7eb56b495d08b81b
parent 645074 80ff3f300e05f38f96c385b03d1973a966a2bd35
child 725878 db4553027c5f499a6f174247dfab4018a0a29f06
push id73728
push userdgottwald@mozilla.com
push dateSat, 12 Aug 2017 10:51:17 +0000
reviewersflorian
bugs1389744
milestone57.0a1
Bug 1389744 - Stop repositioning pinned tabs when (un)selecting the Dark/Light theme. r?florian Dark/Light themes don't affect the tab strip layout anymore, so this entirely unnecessary work. MozReview-Commit-ID: C37VZsd8r2J
browser/base/content/browser-compacttheme.js
browser/base/content/tabbrowser.xml
--- a/browser/base/content/browser-compacttheme.js
+++ b/browser/base/content/browser-compacttheme.js
@@ -4,43 +4,40 @@
 
 /**
  * Listeners for the compact theme.  This adds an extra stylesheet
  * to browser.xul if a pref is set and no other themes are applied.
  */
 var CompactTheme = {
   styleSheetLocation: "chrome://browser/skin/compacttheme.css",
   styleSheet: null,
-  initialized: false,
 
   get isStyleSheetEnabled() {
     return this.styleSheet && !this.styleSheet.sheet.disabled;
   },
 
   get isThemeCurrentlyApplied() {
     let theme = LightweightThemeManager.currentTheme;
     return theme && (
            theme.id == "firefox-compact-dark@mozilla.org" ||
            theme.id == "firefox-compact-light@mozilla.org");
   },
 
   init() {
-    this.initialized = true;
     Services.obs.addObserver(this, "lightweight-theme-styling-update");
 
     if (this.isThemeCurrentlyApplied) {
       this._toggleStyleSheet(true);
     }
   },
 
   createStyleSheet() {
     let styleSheetAttr = `href="${this.styleSheetLocation}" type="text/css"`;
     this.styleSheet = document.createProcessingInstruction(
       "xml-stylesheet", styleSheetAttr);
-    this.styleSheet.addEventListener("load", this);
     document.insertBefore(this.styleSheet, document.documentElement);
     this.styleSheet.sheet.disabled = true;
   },
 
   observe(subject, topic, data) {
     if (topic == "lightweight-theme-styling-update") {
       let newTheme = JSON.parse(data);
       if (newTheme && (
@@ -51,52 +48,32 @@ var CompactTheme = {
         this._toggleStyleSheet(true);
       } else {
         this._toggleStyleSheet(false);
       }
 
     }
   },
 
-  handleEvent(e) {
-    if (e.type === "load") {
-      this.styleSheet.removeEventListener("load", this);
-      this.refreshBrowserDisplay();
-    }
-  },
-
-  refreshBrowserDisplay() {
-    // Don't touch things on the browser if gBrowserInit.onLoad hasn't
-    // yet fired.
-    if (this.initialized) {
-      gBrowser.tabContainer.themeLayoutChanged();
-    }
-  },
-
   _toggleStyleSheet(enabled) {
     let wasEnabled = this.isStyleSheetEnabled;
     if (enabled) {
       // The stylesheet may not have been created yet if it wasn't
       // needed on initial load.  Make it now.
       if (!this.styleSheet) {
         this.createStyleSheet();
       }
       this.styleSheet.sheet.disabled = false;
-      this.refreshBrowserDisplay();
     } else if (!enabled && wasEnabled) {
       this.styleSheet.sheet.disabled = true;
-      this.refreshBrowserDisplay();
     }
   },
 
   uninit() {
     Services.obs.removeObserver(this, "lightweight-theme-styling-update");
-    if (this.styleSheet) {
-      this.styleSheet.removeEventListener("load", this);
-    }
     this.styleSheet = null;
   }
 };
 
 // If the compact theme is going to be applied in gBrowserInit.onLoad,
 // then preload it now.  This prevents a flash of unstyled content where the
 // normal theme is applied while the compact theme stylesheet is loading.
 if (AppConstants.INSTALL_COMPACT_THEMES &&
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -6340,31 +6340,20 @@
 
           if (this.hasAttribute("using-closing-tabs-spacer")) {
             this.removeAttribute("using-closing-tabs-spacer");
             this._closingTabsSpacer.style.width = 0;
           }
         ]]></body>
       </method>
 
-      <method name="themeLayoutChanged">
-        <body><![CDATA[
-          this._positionPinnedTabs(true);
-        ]]></body>
-      </method>
-
       <field name="_lastNumPinned">0</field>
       <field name="_pinnedTabsLayoutCache">null</field>
       <method name="_positionPinnedTabs">
-        <parameter name="aThemeLayoutChanged"/>
         <body><![CDATA[
-          if (aThemeLayoutChanged) {
-            this._pinnedTabsLayoutCache = null;
-          }
-
           var numPinned = this.tabbrowser._numPinnedTabs;
           var doPosition = this.getAttribute("overflow") == "true" &&
                            numPinned > 0;
 
           if (doPosition) {
             this.setAttribute("positionpinnedtabs", "true");
 
             let layoutData = this._pinnedTabsLayoutCache;