Bug 1237788 - Don't remove old devtools stylesheets until new ones are loaded to make theme switching faster;r=pbrosset

--HG--
extra : commitid : A7kE7Tiir11
This commit is contained in:
Brian Grinstead 2016-01-11 13:01:07 -08:00
parent 00e5805584
commit c5a7766531
2 changed files with 25 additions and 30 deletions

View File

@ -10,7 +10,7 @@ var toolbox;
add_task(function* themeRegistration() {
let tab = yield addTab("data:text/html,test");
let target = TargetFactory.forTab(tab);
toolbox = yield gDevTools.showToolbox(target);
toolbox = yield gDevTools.showToolbox(target, "options");
let themeId = yield new Promise(resolve => {
gDevTools.once("theme-registered", (e, themeId) => {
@ -31,9 +31,6 @@ add_task(function* themeRegistration() {
});
add_task(function* themeInOptionsPanel() {
yield toolbox.selectTool("options");
let panel = toolbox.getCurrentPanel();
let panelWin = toolbox.getCurrentPanel().panelWin;
let doc = panelWin.frameElement.contentDocument;

View File

@ -65,15 +65,6 @@
}
let oldThemeDef = gDevTools.getThemeDefinition(oldTheme);
// Unload all theme stylesheets related to the old theme.
if (oldThemeDef) {
for (let sheet of devtoolsStyleSheets.get(oldThemeDef) || []) {
sheet.remove();
}
}
// Load all stylesheets associated with the new theme.
let newThemeDef = gDevTools.getThemeDefinition(newTheme);
// The theme might not be available anymore (e.g. uninstalled)
@ -110,28 +101,35 @@
forceStyle();
}
if (oldThemeDef) {
for (let name of oldThemeDef.classList) {
documentElement.classList.remove(name);
Promise.all(loadEvents).then(() => {
// Unload all stylesheets and classes from the old theme.
if (oldThemeDef) {
for (let name of oldThemeDef.classList) {
documentElement.classList.remove(name);
}
for (let sheet of devtoolsStyleSheets.get(oldThemeDef) || []) {
sheet.remove();
}
if (oldThemeDef.onUnapply) {
oldThemeDef.onUnapply(window, newTheme);
}
}
if (oldThemeDef.onUnapply) {
oldThemeDef.onUnapply(window, newTheme);
// Load all stylesheets and classes from the new theme.
for (let name of newThemeDef.classList) {
documentElement.classList.add(name);
}
}
for (let name of newThemeDef.classList) {
documentElement.classList.add(name);
}
if (newThemeDef.onApply) {
newThemeDef.onApply(window, oldTheme);
}
if (newThemeDef.onApply) {
newThemeDef.onApply(window, oldTheme);
}
// Final notification for further theme-switching related logic.
gDevTools.emit("theme-switched", window, newTheme, oldTheme);
Promise.all(loadEvents).then(notifyWindow, console.error.bind(console));
// Final notification for further theme-switching related logic.
gDevTools.emit("theme-switched", window, newTheme, oldTheme);
notifyWindow();
}, console.error.bind(console));
}
function handlePrefChange(event, data) {