Bug 1273094 - only trigger TabsInTitlebar.init() after the tabbrowser has updated the visibility of the tabs toolbar, r=mikedeboer, a=sylvestre
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 17 May 2016 17:18:55 +0100
changeset 333130 1fc21edf1ee519d8bd0f4d69a7926c9808e3d0f8
parent 333129 bdadf0cd4efb548760b14f147b397e0dc84b461a
child 333131 66c39e2030d819d3e2e59dc0288593a8b9f465b8
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer, sylvestre
bugs1273094
milestone48.0a2
Bug 1273094 - only trigger TabsInTitlebar.init() after the tabbrowser has updated the visibility of the tabs toolbar, r=mikedeboer, a=sylvestre 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
@@ -991,17 +991,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/ .
@@ -5074,22 +5073,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
@@ -5349,16 +5349,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;