Bug 1389744 - Stop repositioning pinned tabs when (un)selecting the Dark/Light theme. r=florian
authorDão Gottwald <dao@mozilla.com>
Sat, 12 Aug 2017 12:50:26 +0200
changeset 374425 3485d5e1261245b23fc2f778d492370ff11334dc
parent 374424 d319322e33cce23f77e180cb8089122926535b1f
child 374426 9d576871fd33bed006dcdccfba880a4ed591f870
push id93678
push userarchaeopteryx@coole-files.de
push dateSat, 12 Aug 2017 23:17:05 +0000
treeherdermozilla-inbound@a79ccbfacad8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian
bugs1389744
milestone57.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 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;