mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset c0f433bceae7 (bug 1053434) for frequent windows 7 debug memory leaks
This commit is contained in:
parent
23438e81ff
commit
9f46b54ba7
@ -14,11 +14,10 @@ let DevEdition = {
|
||||
|
||||
styleSheetLocation: "chrome://browser/skin/devedition.css",
|
||||
styleSheet: null,
|
||||
defaultThemeID: "{972ce4c6-7e08-4474-a285-3208198ce6fd}",
|
||||
|
||||
init: function () {
|
||||
this._updateDevtoolsThemeAttribute();
|
||||
this._updateStyleSheetFromPrefs();
|
||||
this._updateStyleSheet();
|
||||
|
||||
// Listen for changes to all prefs except for complete themes.
|
||||
// No need for this since changing a complete theme requires a
|
||||
@ -26,27 +25,14 @@ let DevEdition = {
|
||||
Services.prefs.addObserver(this._lwThemePrefName, this, false);
|
||||
Services.prefs.addObserver(this._prefName, this, false);
|
||||
Services.prefs.addObserver(this._devtoolsThemePrefName, this, false);
|
||||
Services.obs.addObserver(this, "lightweight-theme-styling-update", false);
|
||||
},
|
||||
|
||||
observe: function (subject, topic, data) {
|
||||
if (topic == "lightweight-theme-styling-update") {
|
||||
let newTheme = JSON.parse(data);
|
||||
if (!newTheme || newTheme.id === this.defaultThemeID) {
|
||||
// A lightweight theme has been unapplied, so just re-read prefs.
|
||||
this._updateStyleSheetFromPrefs();
|
||||
} else {
|
||||
// A lightweight theme has been applied, but the pref may not be
|
||||
// set yet if this happened from customize menu or addons page.
|
||||
this._toggleStyleSheet(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (topic == "nsPref:changed") {
|
||||
if (data == this._devtoolsThemePrefName) {
|
||||
this._updateDevtoolsThemeAttribute();
|
||||
} else {
|
||||
this._updateStyleSheetFromPrefs();
|
||||
this._updateStyleSheet();
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -56,12 +42,11 @@ let DevEdition = {
|
||||
// to change colors based on the selected devtools theme.
|
||||
document.documentElement.setAttribute("devtoolstheme",
|
||||
Services.prefs.getCharPref(this._devtoolsThemePrefName));
|
||||
if (this.styleSheet) {
|
||||
ToolbarIconColor.inferFromText();
|
||||
}
|
||||
},
|
||||
|
||||
_updateStyleSheetFromPrefs: function() {
|
||||
_updateStyleSheet: function() {
|
||||
// Only try to apply the dev edition theme if it is preffered
|
||||
// on and there are no other themes applied.
|
||||
let lightweightThemeSelected = false;
|
||||
try {
|
||||
lightweightThemeSelected = Services.prefs.getBoolPref(this._lwThemePrefName);
|
||||
@ -75,24 +60,18 @@ let DevEdition = {
|
||||
let deveditionThemeEnabled = Services.prefs.getBoolPref(this._prefName) &&
|
||||
!lightweightThemeSelected && defaultThemeSelected;
|
||||
|
||||
this._toggleStyleSheet(deveditionThemeEnabled);
|
||||
},
|
||||
|
||||
_toggleStyleSheet: function(deveditionThemeEnabled) {
|
||||
if (deveditionThemeEnabled && !this.styleSheet) {
|
||||
let styleSheetAttr = `href="${this.styleSheetLocation}" type="text/css"`;
|
||||
let styleSheet = this.styleSheet = document.createProcessingInstruction(
|
||||
'xml-stylesheet', styleSheetAttr);
|
||||
this.styleSheet.addEventListener("load", function onLoad() {
|
||||
styleSheet.removeEventListener("load", onLoad);
|
||||
gBrowser.tabContainer._positionPinnedTabs();
|
||||
ToolbarIconColor.inferFromText();
|
||||
});
|
||||
document.insertBefore(this.styleSheet, document.documentElement);
|
||||
} else if (!deveditionThemeEnabled && this.styleSheet) {
|
||||
this.styleSheet.remove();
|
||||
this.styleSheet = null;
|
||||
gBrowser.tabContainer._positionPinnedTabs();
|
||||
ToolbarIconColor.inferFromText();
|
||||
}
|
||||
},
|
||||
@ -101,7 +80,6 @@ let DevEdition = {
|
||||
Services.prefs.removeObserver(this._lwThemePrefName, this);
|
||||
Services.prefs.removeObserver(this._prefName, this);
|
||||
Services.prefs.removeObserver(this._devtoolsThemePrefName, this);
|
||||
Services.obs.removeObserver(this, "lightweight-theme-styling-update", false);
|
||||
this.styleSheet = null;
|
||||
}
|
||||
};
|
||||
|
@ -65,49 +65,5 @@ function startTests() {
|
||||
is (document.documentElement.getAttribute("devtoolstheme"), "light",
|
||||
"The documentElement has an attribute based on devtools theme.");
|
||||
|
||||
testLightweightThemePreview();
|
||||
finish();
|
||||
}
|
||||
|
||||
function dummyLightweightTheme(id) {
|
||||
return {
|
||||
id: id,
|
||||
name: id,
|
||||
headerURL: "http://lwttest.invalid/a.png",
|
||||
footerURL: "http://lwttest.invalid/b.png",
|
||||
textcolor: "red",
|
||||
accentcolor: "blue"
|
||||
};
|
||||
}
|
||||
|
||||
function testLightweightThemePreview() {
|
||||
let {LightweightThemeManager} = Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm", {});
|
||||
|
||||
info ("Turning the pref on, then previewing lightweight themes");
|
||||
Services.prefs.setBoolPref(PREF_DEVEDITION_THEME, true);
|
||||
ok (DevEdition.styleSheet, "The devedition stylesheet is enabled.");
|
||||
LightweightThemeManager.previewTheme(dummyLightweightTheme("preview0"));
|
||||
ok (!DevEdition.styleSheet, "The devedition stylesheet is not enabled after a lightweight theme preview.");
|
||||
LightweightThemeManager.previewTheme(dummyLightweightTheme("preview1"));
|
||||
ok (!DevEdition.styleSheet, "The devedition stylesheet is not enabled after a second lightweight theme preview.");
|
||||
LightweightThemeManager.resetPreview();
|
||||
ok (DevEdition.styleSheet, "The devedition stylesheet is enabled again after resetting the preview.");
|
||||
|
||||
info ("Turning the pref on, then previewing a theme, turning it off and resetting the preview");
|
||||
Services.prefs.setBoolPref(PREF_DEVEDITION_THEME, true);
|
||||
ok (DevEdition.styleSheet, "The devedition stylesheet is enabled.");
|
||||
LightweightThemeManager.previewTheme(dummyLightweightTheme("preview2"));
|
||||
ok (!DevEdition.styleSheet, "The devedition stylesheet is not enabled after a lightweight theme preview.");
|
||||
Services.prefs.setBoolPref(PREF_DEVEDITION_THEME, false);
|
||||
ok (!DevEdition.styleSheet, "The devedition stylesheet is not enabled after pref is turned off.");
|
||||
LightweightThemeManager.resetPreview();
|
||||
ok (!DevEdition.styleSheet, "The devedition stylesheet is still disabled after resetting the preview.");
|
||||
|
||||
info ("Turning the pref on, then previewing the default theme, turning it off and resetting the preview");
|
||||
Services.prefs.setBoolPref(PREF_DEVEDITION_THEME, true);
|
||||
ok (DevEdition.styleSheet, "The devedition stylesheet is enabled.");
|
||||
LightweightThemeManager.previewTheme(dummyLightweightTheme("{972ce4c6-7e08-4474-a285-3208198ce6fd}"));
|
||||
ok (DevEdition.styleSheet, "The devedition stylesheet is still enabled after the default theme is applied.");
|
||||
LightweightThemeManager.resetPreview();
|
||||
ok (DevEdition.styleSheet, "The devedition stylesheet is still enabled after resetting the preview.");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user