Bug 1273094 - only trigger TabsInTitlebar.init() after the tabbrowser has updated the visibility of the tabs toolbar, r?mikedeboer draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 17 May 2016 17:18:55 +0100
changeset 368321 45d47c121eb5a4434ffb5f9b10e38b7267f785f5
parent 367899 c331e892afc78f9fa1556d6e00fc23ecf4b223e4
child 521216 fef55663e5c2349c69f3dcace3672eb03605be93
push id18477
push usergijskruitbosch@gmail.com
push dateWed, 18 May 2016 12:50:11 +0000
reviewersmikedeboer
bugs1273094
milestone49.0a1
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.js
browser/base/content/tabbrowser.xml
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -984,17 +984,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/ .
@@ -5080,22 +5079,26 @@ var TabletModeUpdater = {
     }
   },
 
   observe(subject, topic, data) {
     this.update(data == "tablet-mode");
   },
 
   update(isInTabletMode) {
+    let wasInTabletMode =
+      document.documentElement.getAttribute("tabletmode") == "true";
     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;