Bug 1273094 - only trigger TabsInTitlebar.init() after the tabbrowser has updated the visibility of the tabs toolbar, r=mikedeboer
MozReview-Commit-ID: 2NOPYqbq4Zp
--- 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;