Bug 1273094 - only trigger TabsInTitlebar.init() after the tabbrowser has updated the visibility of the tabs toolbar, r=mikedeboer
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 17 May 2016 17:18:55 +0100
changeset 297976 5a4cdb6dfb19b458229c60e0e19f083ba83d0f58
parent 297975 0ba8107314d6e579f881399cc2ec0a6478080a90
child 297977 128e727da49694a9ffd197b9dc96695b821df478
child 298115 029dcd1503478771cb4a6795a6e8f1fec802c0fd
push id30268
push userryanvm@gmail.com
push dateThu, 19 May 2016 13:34:05 +0000
treeherdermozilla-central@5a4cdb6dfb19 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs1273094
milestone49.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 1273094 - only trigger TabsInTitlebar.init() after the tabbrowser has updated the visibility of the tabs toolbar, r=mikedeboer MozReview-Commit-ID: 2NOPYqbq4Zp
browser/base/content/browser-tabsintitlebar.js
browser/base/content/browser.js
browser/base/content/tabbrowser.xml
--- a/browser/base/content/browser-tabsintitlebar.js
+++ b/browser/base/content/browser-tabsintitlebar.js
@@ -3,16 +3,19 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // Note: the file browser-tabsintitlebar-stub.js is used instead of
 // this one on platforms which don't have CAN_DRAW_IN_TITLEBAR defined.
 
 var TabsInTitlebar = {
   init: function () {
+    if (this._initialized) {
+      return;
+    }
     this._readPref();
     Services.prefs.addObserver(this._prefName, this, false);
 
     // We need to update the appearance of the titlebar when the menu changes
     // from the active to the inactive state. We can't, however, rely on
     // DOMMenuBarInactive, because the menu fires this event and then removes
     // the inactive attribute after an event-loop spin.
     //
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -985,17 +985,16 @@ var gBrowserInit = {
       gURLBar.setAttribute("enablehistory", "false");
       goSetCommandEnabled("cmd_newNavigatorTab", false);
     }
 
     // Misc. inits.
     TabletModeUpdater.init();
     CombinedStopReload.init();
     gPrivateBrowsingUI.init();
-    TabsInTitlebar.init();
 
     if (window.matchMedia("(-moz-os-version: windows-win8)").matches &&
         window.matchMedia("(-moz-windows-default-theme)").matches) {
       let windowFrameColor = Cu.import("resource:///modules/Windows8WindowFrameColor.jsm", {})
                                .Windows8WindowFrameColor.get();
 
       // Formula from W3C's WCAG 2.0 spec's color ratio and relative luminance,
       // section 1.3.4, http://www.w3.org/TR/WCAG20/ .
@@ -5094,22 +5093,25 @@ var TabletModeUpdater = {
     }
   },
 
   observe(subject, topic, data) {
     this.update(data == "tablet-mode");
   },
 
   update(isInTabletMode) {
+    let wasInTabletMode = document.documentElement.hasAttribute("tabletmode");
     if (isInTabletMode) {
       document.documentElement.setAttribute("tabletmode", "true");
     } else {
       document.documentElement.removeAttribute("tabletmode");
     }
-    TabsInTitlebar.updateAppearance(true);
+    if (wasInTabletMode != isInTabletMode) {
+      TabsInTitlebar.updateAppearance(true);
+    }
   },
 };
 
 var gTabletModePageCounter = {
   enabled: false,
   inc() {
     this.enabled = AppConstants.isPlatformAndVersionAtLeast("win", "10.0");
     if (!this.enabled) {
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -5359,16 +5359,17 @@
       </method>
 
       <method name="handleEvent">
         <parameter name="aEvent"/>
         <body><![CDATA[
           switch (aEvent.type) {
             case "load":
               this.updateVisibility();
+              TabsInTitlebar.init();
               break;
             case "resize":
               if (aEvent.target != window)
                 break;
 
               TabsInTitlebar.updateAppearance();
 
               var width = this.mTabstrip.boxObject.width;