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
--- 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;