mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
Bug 1030716 - Prevent dark theme in sourceeditor for WebIDE. r=paul
This commit is contained in:
parent
1c728d5718
commit
aece09b5c6
@ -4,18 +4,19 @@
|
||||
|
||||
(function() {
|
||||
const DEVTOOLS_SKIN_URL = "chrome://browser/skin/devtools/";
|
||||
let documentElement = document.documentElement;
|
||||
|
||||
function forceStyle() {
|
||||
let computedStyle = window.getComputedStyle(document.documentElement);
|
||||
let computedStyle = window.getComputedStyle(documentElement);
|
||||
if (!computedStyle) {
|
||||
// Null when documentElement is not ready. This method is anyways not
|
||||
// required then as scrollbars would be in their state without flushing.
|
||||
return;
|
||||
}
|
||||
let display = computedStyle.display; // Save display value
|
||||
document.documentElement.style.display = "none";
|
||||
window.getComputedStyle(document.documentElement).display; // Flush
|
||||
document.documentElement.style.display = display; // Restore
|
||||
documentElement.style.display = "none";
|
||||
window.getComputedStyle(documentElement).display; // Flush
|
||||
documentElement.style.display = display; // Restore
|
||||
}
|
||||
|
||||
function switchTheme(newTheme, oldTheme) {
|
||||
@ -61,8 +62,8 @@
|
||||
forceStyle();
|
||||
}
|
||||
|
||||
document.documentElement.classList.remove("theme-" + oldTheme);
|
||||
document.documentElement.classList.add("theme-" + newTheme);
|
||||
documentElement.classList.remove("theme-" + oldTheme);
|
||||
documentElement.classList.add("theme-" + newTheme);
|
||||
}
|
||||
|
||||
function handlePrefChange(event, data) {
|
||||
@ -78,11 +79,14 @@
|
||||
const {devtools} = Components.utils.import("resource://gre/modules/devtools/Loader.jsm", {});
|
||||
const StylesheetUtils = devtools.require("sdk/stylesheet/utils");
|
||||
|
||||
let theme = Services.prefs.getCharPref("devtools.theme");
|
||||
switchTheme(theme);
|
||||
if (documentElement.hasAttribute("force-theme")) {
|
||||
switchTheme(documentElement.getAttribute("force-theme"));
|
||||
} else {
|
||||
switchTheme(Services.prefs.getCharPref("devtools.theme"));
|
||||
|
||||
gDevTools.on("pref-changed", handlePrefChange);
|
||||
window.addEventListener("unload", function() {
|
||||
gDevTools.off("pref-changed", handlePrefChange);
|
||||
});
|
||||
gDevTools.on("pref-changed", handlePrefChange);
|
||||
window.addEventListener("unload", function() {
|
||||
gDevTools.off("pref-changed", handlePrefChange);
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
@ -157,6 +157,7 @@ function Editor(config) {
|
||||
autoCloseBrackets: "()[]{}''\"\"",
|
||||
autoCloseEnabled: useAutoClose,
|
||||
theme: "mozilla",
|
||||
themeSwitching: true,
|
||||
autocomplete: false
|
||||
};
|
||||
|
||||
@ -258,6 +259,9 @@ Editor.prototype = {
|
||||
env.removeEventListener("load", onLoad, true);
|
||||
let win = env.contentWindow.wrappedJSObject;
|
||||
|
||||
if (!this.config.themeSwitching)
|
||||
win.document.documentElement.setAttribute("force-theme", "light");
|
||||
|
||||
CM_SCRIPTS.forEach((url) =>
|
||||
Services.scriptloader.loadSubScript(url, win, "utf8"));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user