From 5df734e71053c06386dd19bd97f6f9527bed5575 Mon Sep 17 00:00:00 2001 From: Brian Grinstead Date: Mon, 30 Mar 2015 09:20:48 -0700 Subject: [PATCH] Bug 1094821 - Backout 01482cdccd72 for test failures in Aurora simulation;r=me;a=RyanVM --- browser/app/profile/firefox.js | 5 +- browser/base/content/browser-devedition.js | 59 +++++++++---- browser/base/content/browser.js | 2 - .../defaultthemes/devedition.header.png | Bin 95 -> 0 bytes .../content/defaultthemes/devedition.icon.png | Bin 2402 -> 0 bytes .../test/general/browser_devedition.js | 78 +++++++++++------- browser/base/jar.mn | 2 - .../customizableui/CustomizableUI.jsm | 15 +++- .../customizableui/CustomizeMode.jsm | 55 ++++++++++++ .../content/customizeMode.inc.xul | 7 ++ ...wser_1007336_lwthemes_in_customize_mode.js | 2 - .../browser_970511_undo_restore_default.js | 42 ++++++++++ browser/components/nsBrowserGlue.js | 54 ------------ browser/devtools/framework/test/browser.ini | 1 + .../browser_toolbox_options_devedition.js | 59 +++++++++++++ browser/devtools/framework/toolbox-options.js | 74 +++++++++++++++++ .../devtools/framework/toolbox-options.xul | 3 + .../framework/toolbox-process-window.js | 1 + .../locales/en-US/chrome/browser/browser.dtd | 1 + 19 files changed, 352 insertions(+), 108 deletions(-) delete mode 100644 browser/base/content/defaultthemes/devedition.header.png delete mode 100644 browser/base/content/defaultthemes/devedition.icon.png create mode 100644 browser/devtools/framework/test/browser_toolbox_options_devedition.js diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index ebce7d177ada..09e82f9d59e0 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -1328,8 +1328,11 @@ pref("services.sync.prefs.sync.xpinstall.whitelist.required", true); // Developer edition preferences #ifdef MOZ_DEV_EDITION -pref("lightweightThemes.selectedThemeID", "firefox-devedition@mozilla.org"); pref("browser.devedition.theme.enabled", true); +pref("browser.devedition.theme.showCustomizeButton", true); +#else +pref("browser.devedition.theme.enabled", false); +pref("browser.devedition.theme.showCustomizeButton", false); #endif // Developer edition promo preferences diff --git a/browser/base/content/browser-devedition.js b/browser/base/content/browser-devedition.js index 9a7f6453bfe3..934d70bd963d 100644 --- a/browser/base/content/browser-devedition.js +++ b/browser/base/content/browser-devedition.js @@ -7,37 +7,46 @@ * to browser.xul if a pref is set and no other themes are applied. */ let DevEdition = { + _prefName: "browser.devedition.theme.enabled", + _themePrefName: "general.skins.selectedSkin", + _lwThemePrefName: "lightweightThemes.selectedThemeID", _devtoolsThemePrefName: "devtools.theme", + styleSheetLocation: "chrome://browser/skin/devedition.css", styleSheet: null, - get isThemeCurrentlyApplied() { - let theme = LightweightThemeManager.currentTheme; - return theme && theme.id == "firefox-devedition@mozilla.org"; - }, - init: function () { + this._updateDevtoolsThemeAttribute(); + this._updateStyleSheetFromPrefs(); + + // Listen for changes to all prefs except for complete themes. + // No need for this since changing a complete theme requires a + // restart. + 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); - this._updateDevtoolsThemeAttribute(); - - if (this.isThemeCurrentlyApplied) { - this._toggleStyleSheet(true); - } }, observe: function (subject, topic, data) { if (topic == "lightweight-theme-styling-update") { let newTheme = JSON.parse(data); - if (newTheme && newTheme.id == "firefox-devedition@mozilla.org") { - this._toggleStyleSheet(true); + if (!newTheme) { + // 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" && data == this._devtoolsThemePrefName) { - this._updateDevtoolsThemeAttribute(); + if (topic == "nsPref:changed") { + if (data == this._devtoolsThemePrefName) { + this._updateDevtoolsThemeAttribute(); + } else { + this._updateStyleSheetFromPrefs(); + } } }, @@ -61,6 +70,24 @@ let DevEdition = { } document.documentElement.setAttribute("devtoolstheme", devtoolsTheme); this._inferBrightness(); + this._updateStyleSheetFromPrefs(); + }, + + _updateStyleSheetFromPrefs: function() { + let lightweightThemeSelected = false; + try { + lightweightThemeSelected = !!Services.prefs.getCharPref(this._lwThemePrefName); + } catch(e) {} + + let defaultThemeSelected = false; + try { + defaultThemeSelected = Services.prefs.getCharPref(this._themePrefName) == "classic/1.0"; + } catch(e) {} + + let deveditionThemeEnabled = Services.prefs.getBoolPref(this._prefName) && + !lightweightThemeSelected && defaultThemeSelected; + + this._toggleStyleSheet(deveditionThemeEnabled); }, handleEvent: function(e) { @@ -68,6 +95,7 @@ let DevEdition = { this.styleSheet.removeEventListener("load", this); gBrowser.tabContainer._positionPinnedTabs(); this._inferBrightness(); + Services.obs.notifyObservers(window, "devedition-theme-state-changed", true); } }, @@ -86,10 +114,13 @@ let DevEdition = { this.styleSheet = null; gBrowser.tabContainer._positionPinnedTabs(); this._inferBrightness(); + Services.obs.notifyObservers(window, "devedition-theme-state-changed", false); } }, uninit: function () { + 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); if (this.styleSheet) { diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index ed4254bcd2fc..315d03272076 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -45,8 +45,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "Favicons", XPCOMUtils.defineLazyServiceGetter(this, "gDNSService", "@mozilla.org/network/dns-service;1", "nsIDNSService"); -XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeManager", - "resource://gre/modules/LightweightThemeManager.jsm"); const nsIWebNavigation = Ci.nsIWebNavigation; diff --git a/browser/base/content/defaultthemes/devedition.header.png b/browser/base/content/defaultthemes/devedition.header.png deleted file mode 100644 index e4e8dcaa3b3cd01a1287359902561166d7f942ee..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 95 zcmeAS@N?(olHy`uVBq!ia0vp^j3CU&3?x-=hn)ga%mF?juK#@*VoWXSL2@NQe!&b5 m&u*jvIb5DDjv*Cul9PaJHU?%h^O_Yv7K5j&pUXO@geCw~dlW4I diff --git a/browser/base/content/defaultthemes/devedition.icon.png b/browser/base/content/defaultthemes/devedition.icon.png deleted file mode 100644 index 04cfba796dc6aa0bac6b3b368e929009bf01af52..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2402 zcmV-o37z(dP)ID{auY=ILjB72Yoqmj_8OZW6Pz4u+K>fTdl$@RTX!^lH2 z0Yg6c_@8?Ee&;(>9g6>N3GPt8_Ut8nWM<-#Sj!IuIAwEtzZ58hz`Njdq~DNIoVCuq z&@uk`Z$Es%{agTk^|?!-?()2%A1#2xjIjMZJq7yU0SUU&3d!{yh(FolXidIZnS8uZLqtx z#<|xoa{0_zRyxUC+nAT1_}8m1|K*R?PW-P&@aQw=pSrr;`PAKqCZ23=ZGClZVTpFv zkQvW-d6eqhQAWpWESSlw`>!FoIcn6&p(dZ}u!a0g`*?-U7B&SYtv>5Yl;dVDY zpM3TscYpu34gABaTk_J)#wQk5c4{lvR=yfK9ZHolwQ7a^hiA!;&2dc@*uHR`)wMdd zoe*+6uxmDvO5?V-vF#2a@8PYdGC9W4OKDCWE^a=kFl?*2pA{Znk^fvMbZ`RXdcIb;+emFmwJ6&FB71R)WP9Yn83?gXo^ zyvE|OU*MPuywu65SIgqs(#F%D``%*tX8;zqI<YjR6EWi_cO*nxGHNqNit&0kDpi(Ui`eW64WqBgt725yr=6&Svh@KLaqon;uD# zq}?2RfB*m+sX+w#4zx1EzIPnt$on7Q_yJ`Fo#WqAy8yF!FK@HkNU=c> z@|=*RgkBflY7%rr5DJ1vq#g3b>r@vOSnWBEM3UeG*7?)704&#&U%9!{K7n%x?-7Bw zc?eS(jX4}Fr)DRZ)qx9dT}F5ZKrn`=v5rhzkTe)V1Vom?;^JVvY8)JPWf{{}F%DkFH7FI?fxSI=Qh&H&n3gp~MV717#7NI}Rtc%`Wv zKSp8U5=8+m>p%#c^@yzZ^d3MtQorQ$oZuY{8u+P)YYIZ}&RUVVN)b^WVQXs#=^X;# zC$n#rbr4G9qasL!%rks1#g#_!AN(-y9*Kwo)Sc&GB)NKZ`PTt7Ks(8fdTa4$q#Ev8 zhCnIO=vcFVBtj(_E=|~{#W37i2q3IQIESvUfzk+@L$OSVM^K#xvQTDg_6XK`=3>o7 z*V*4$Xz zMHM2-V`Wru1e*_bEb|^BH-jdm%b{37n+)MC@#YOe2m~PzlxiNZO!q=qS!O3IdwO5joG2u8=rh**gMb^8X0l-CNKFthK{Wtdz(Q7>P9~ zNu(upS*H5XFB5fIMB`&@ON|u*Atcqi<|sY)_hgkxdbMc^>sJ|>J%m60E}XR_G6L(V zNI|=sQ;yUR_8J(kl)kA16e5kwb8O$vI(o(uE6GGLVkE$1tf|Hk(Y{H%)Qskqu-&9K zzW^`41f4d8tUYK4ABc~gAkQ7bdPIL}=P3hOWKKIADpbR z)lA9roJ@e$nlv?3Dn+tRMzfdW5d`lUD@4pJUZ(Zh8HCM|eS2LX>UIzkxc8kDMPMs4 zRJ@1W4;$`wUpwq%`n{_HtV8#U3|Ts?&UHR(+4J>eDmDJKTIuh zYId4F37=3IzosG*xZp=H>|#uF)?070#XRNI)=FL z-AiA7@K0|Gu=K;{vg059gEx9RJD<#r5iUR&IP6WOB*A-xr|&>%q`+9Yh(ZvYCrvV9 zDba&hI6_E4C--zRgM>4Z@X^+PK4WeR0I>4XbMyB;^4XhaXXhi{+?lTQY=CEdTk#$({U|#K#`{tIwuQ_w`O{ z3MPtiIz~p(&|0JVmP!pRB|?ay5g-NS$#Hr?;F}F%+xW`--+bm9K*HN3xxM6-fBe#S zyK6uGe6^yNM|&xSZi2{Ce41d>lsxIXKTYyerzv^2i^o%_mJmr3wRjD=HUIs7`17}9 z-9ZBaC^3euyYu2x z-vO3^I^g*~N&{oSaiQbi9zXr)H>W@R<+BGLdunI$k*_r-KmH9r_1M#H>_cDKsD1EH z=4%gs?#$S4{N6K#d*1i^z)4^Vi1|550;9k*a3Anq-~$NxAaEKu0n7qrKyioqFVKt_ UJkx%vwEzGB07*qoM6N<$f}8H2SpWb4 diff --git a/browser/base/content/test/general/browser_devedition.js b/browser/base/content/test/general/browser_devedition.js index 677bb13af2cf..c6c044318447 100644 --- a/browser/base/content/test/general/browser_devedition.js +++ b/browser/base/content/test/general/browser_devedition.js @@ -5,56 +5,63 @@ * are applied. */ +const PREF_DEVEDITION_THEME = "browser.devedition.theme.enabled"; +const PREF_LWTHEME = "lightweightThemes.selectedThemeID"; const PREF_LWTHEME_USED_THEMES = "lightweightThemes.usedThemes"; const PREF_DEVTOOLS_THEME = "devtools.theme"; const {LightweightThemeManager} = Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm", {}); -LightweightThemeManager.clearBuiltInThemes(); -LightweightThemeManager.addBuiltInTheme(dummyLightweightTheme("firefox-devedition@mozilla.org")); - registerCleanupFunction(() => { // Set preferences back to their original values LightweightThemeManager.currentTheme = null; + Services.prefs.clearUserPref(PREF_DEVEDITION_THEME); + Services.prefs.clearUserPref(PREF_LWTHEME); Services.prefs.clearUserPref(PREF_DEVTOOLS_THEME); Services.prefs.clearUserPref(PREF_LWTHEME_USED_THEMES); - - LightweightThemeManager.currentTheme = null; - LightweightThemeManager.clearBuiltInThemes(); }); add_task(function* startTests() { Services.prefs.setCharPref(PREF_DEVTOOLS_THEME, "dark"); - info ("Setting the current theme to null"); - LightweightThemeManager.currentTheme = null; - ok (!DevEdition.styleSheet, "There is no devedition style sheet when no lw theme is applied."); + info ("Setting browser.devedition.theme.enabled to false."); + Services.prefs.setBoolPref(PREF_DEVEDITION_THEME, false); + ok (!DevEdition.styleSheet, "There is no devedition style sheet when the pref is false."); + + info ("Setting browser.devedition.theme.enabled to true."); + Services.prefs.setBoolPref(PREF_DEVEDITION_THEME, true); + ok (DevEdition.styleSheet, "There is a devedition stylesheet when no themes are applied and pref is set."); info ("Adding a lightweight theme."); LightweightThemeManager.currentTheme = dummyLightweightTheme("preview0"); ok (!DevEdition.styleSheet, "The devedition stylesheet has been removed when a lightweight theme is applied."); - info ("Applying the devedition lightweight theme."); + info ("Removing a lightweight theme."); let onAttributeAdded = waitForBrightTitlebarAttribute(); - LightweightThemeManager.currentTheme = LightweightThemeManager.getUsedTheme("firefox-devedition@mozilla.org"); - ok (DevEdition.styleSheet, "The devedition stylesheet has been added when the devedition lightweight theme is applied"); + LightweightThemeManager.currentTheme = null; + ok (DevEdition.styleSheet, "The devedition stylesheet has been added when a lightweight theme is removed."); yield onAttributeAdded; + is (document.documentElement.getAttribute("brighttitlebarforeground"), "true", "The brighttitlebarforeground attribute is set on the window."); - info ("Unapplying all themes."); - LightweightThemeManager.currentTheme = null; - ok (!DevEdition.styleSheet, "There is no devedition style sheet when no lw theme is applied."); + info ("Setting browser.devedition.theme.enabled to false."); + Services.prefs.setBoolPref(PREF_DEVEDITION_THEME, false); + ok (!DevEdition.styleSheet, "The devedition stylesheet has been removed."); - info ("Applying the devedition lightweight theme."); - onAttributeAdded = waitForBrightTitlebarAttribute(); - LightweightThemeManager.currentTheme = LightweightThemeManager.getUsedTheme("firefox-devedition@mozilla.org"); - ok (DevEdition.styleSheet, "The devedition stylesheet has been added when the devedition lightweight theme is applied"); - yield onAttributeAdded; - ok (document.documentElement.hasAttribute("brighttitlebarforeground"), - "The brighttitlebarforeground attribute is set on the window with dark devtools theme."); + ok (!document.documentElement.hasAttribute("brighttitlebarforeground"), + "The brighttitlebarforeground attribute is not set on the window after devedition.theme is false."); }); add_task(function* testDevtoolsTheme() { + info ("Checking that Australis is shown when the light devtools theme is applied."); + + let onAttributeAdded = waitForBrightTitlebarAttribute(); + Services.prefs.setBoolPref(PREF_DEVEDITION_THEME, true); + ok (DevEdition.styleSheet, "The devedition stylesheet exists."); + yield onAttributeAdded; + ok (document.documentElement.hasAttribute("brighttitlebarforeground"), + "The brighttitlebarforeground attribute is set on the window with dark devtools theme."); + info ("Checking stylesheet and :root attributes based on devtools theme."); Services.prefs.setCharPref(PREF_DEVTOOLS_THEME, "light"); is (document.documentElement.getAttribute("devtoolstheme"), "light", @@ -82,16 +89,16 @@ function dummyLightweightTheme(id) { return { id: id, name: id, - headerURL: "resource:///chrome/browser/content/browser/defaultthemes/devedition.header.png", - iconURL: "resource:///chrome/browser/content/browser/defaultthemes/devedition.icon.png", + headerURL: "resource:///chrome/browser/content/browser/defaultthemes/1.header.jpg", + iconURL: "resource:///chrome/browser/content/browser/defaultthemes/1.icon.jpg", textcolor: "red", accentcolor: "blue" }; } add_task(function* testLightweightThemePreview() { - info ("Setting devedition to current and the previewing others"); - LightweightThemeManager.currentTheme = LightweightThemeManager.getUsedTheme("firefox-devedition@mozilla.org"); + 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."); @@ -100,15 +107,24 @@ add_task(function* testLightweightThemePreview() { 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."); - LightweightThemeManager.currentTheme = null; - ok (!DevEdition.styleSheet, "The devedition stylesheet is gone after removing the current theme."); - info ("Previewing the devedition theme"); - LightweightThemeManager.previewTheme(LightweightThemeManager.getUsedTheme("firefox-devedition@mozilla.org")); + 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 now disabled after resetting the preview."); + 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(null); + 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."); }); // Use a mutation observer to wait for the brighttitlebarforeground diff --git a/browser/base/jar.mn b/browser/base/jar.mn index 2ee1be017336..90a5295734e2 100644 --- a/browser/base/jar.mn +++ b/browser/base/jar.mn @@ -98,8 +98,6 @@ browser.jar: content/browser/defaultthemes/5.header.png (content/defaultthemes/5.header.png) content/browser/defaultthemes/5.icon.jpg (content/defaultthemes/5.icon.jpg) content/browser/defaultthemes/5.preview.jpg (content/defaultthemes/5.preview.jpg) - content/browser/defaultthemes/devedition.header.png (content/defaultthemes/devedition.header.png) - content/browser/defaultthemes/devedition.icon.png (content/defaultthemes/devedition.icon.png) content/browser/newtab/newTab.xul (content/newtab/newTab.xul) * content/browser/newtab/newTab.js (content/newtab/newTab.js) content/browser/newtab/newTab.css (content/newtab/newTab.css) diff --git a/browser/components/customizableui/CustomizableUI.jsm b/browser/components/customizableui/CustomizableUI.jsm index 246983f802c3..54c2edefd07c 100644 --- a/browser/components/customizableui/CustomizableUI.jsm +++ b/browser/components/customizableui/CustomizableUI.jsm @@ -37,6 +37,7 @@ const kPrefCustomizationState = "browser.uiCustomization.state"; const kPrefCustomizationAutoAdd = "browser.uiCustomization.autoAdd"; const kPrefCustomizationDebug = "browser.uiCustomization.debug"; const kPrefDrawInTitlebar = "browser.tabs.drawInTitlebar"; +const kPrefDeveditionTheme = "browser.devedition.theme.enabled"; const kPrefWebIDEInNavbar = "devtools.webide.widget.inNavbarByDefault"; /** @@ -2331,6 +2332,7 @@ let CustomizableUIInternal = { _resetUIState: function() { try { gUIStateBeforeReset.drawInTitlebar = Services.prefs.getBoolPref(kPrefDrawInTitlebar); + gUIStateBeforeReset.deveditionTheme = Services.prefs.getBoolPref(kPrefDeveditionTheme); gUIStateBeforeReset.uiCustomizationState = Services.prefs.getCharPref(kPrefCustomizationState); } catch(e) { } @@ -2338,6 +2340,7 @@ let CustomizableUIInternal = { Services.prefs.clearUserPref(kPrefCustomizationState); Services.prefs.clearUserPref(kPrefDrawInTitlebar); + Services.prefs.clearUserPref(kPrefDeveditionTheme); LOG("State reset"); // Reset placements to make restoring default placements possible. @@ -2399,13 +2402,15 @@ let CustomizableUIInternal = { */ undoReset: function() { if (gUIStateBeforeReset.uiCustomizationState == null || - gUIStateBeforeReset.drawInTitlebar == null) { + gUIStateBeforeReset.drawInTitlebar == null || + gUIStateBeforeReset.deveditionTheme == null) { return; } gUndoResetting = true; let uiCustomizationState = gUIStateBeforeReset.uiCustomizationState; let drawInTitlebar = gUIStateBeforeReset.drawInTitlebar; + let deveditionTheme = gUIStateBeforeReset.deveditionTheme; // Need to clear the previous state before setting the prefs // because pref observers may check if there is a previous UI state. @@ -2413,6 +2418,7 @@ let CustomizableUIInternal = { Services.prefs.setCharPref(kPrefCustomizationState, uiCustomizationState); Services.prefs.setBoolPref(kPrefDrawInTitlebar, drawInTitlebar); + Services.prefs.setBoolPref(kPrefDeveditionTheme, deveditionTheme); this.loadSavedState(); // If the user just customizes toolbar/titlebar visibility, gSavedState will be null // and we don't need to do anything else here: @@ -2590,6 +2596,10 @@ let CustomizableUIInternal = { LOG(kPrefDrawInTitlebar + " pref is non-default"); return false; } + if (Services.prefs.prefHasUserValue(kPrefDeveditionTheme)) { + LOG(kPrefDeveditionTheme + " pref is non-default"); + return false; + } return true; }, @@ -3290,7 +3300,8 @@ this.CustomizableUI = { */ get canUndoReset() { return gUIStateBeforeReset.uiCustomizationState != null || - gUIStateBeforeReset.drawInTitlebar != null; + gUIStateBeforeReset.drawInTitlebar != null || + gUIStateBeforeReset.deveditionTheme != null; }, /** diff --git a/browser/components/customizableui/CustomizeMode.jsm b/browser/components/customizableui/CustomizeMode.jsm index af9f3c012b7c..1eb63b856b0e 100644 --- a/browser/components/customizableui/CustomizeMode.jsm +++ b/browser/components/customizableui/CustomizeMode.jsm @@ -17,6 +17,9 @@ const kPlaceholderClass = "panel-customization-placeholder"; const kSkipSourceNodePref = "browser.uiCustomization.skipSourceNodeCheck"; const kToolbarVisibilityBtn = "customization-toolbar-visibility-button"; const kDrawInTitlebarPref = "browser.tabs.drawInTitlebar"; +const kDeveditionThemePref = "browser.devedition.theme.enabled"; +const kDeveditionButtonPref = "browser.devedition.theme.showCustomizeButton"; +const kDeveditionChangedNotification = "devedition-theme-state-changed"; const kMaxTransitionDurationMs = 2000; const kPanelItemContextMenu = "customizationPanelItemContextMenu"; @@ -64,12 +67,17 @@ function CustomizeMode(aWindow) { this.tipPanel = this.document.getElementById("customization-tipPanel"); if (Services.prefs.getCharPref("general.skins.selectedSkin") != "classic/1.0") { let lwthemeButton = this.document.getElementById("customization-lwtheme-button"); + let deveditionButton = this.document.getElementById("customization-devedition-theme-button"); lwthemeButton.setAttribute("hidden", "true"); + deveditionButton.setAttribute("hidden", "true"); } #ifdef CAN_DRAW_IN_TITLEBAR this._updateTitlebarButton(); Services.prefs.addObserver(kDrawInTitlebarPref, this, false); #endif + this._updateDevEditionThemeButton(); + Services.prefs.addObserver(kDeveditionButtonPref, this, false); + Services.obs.addObserver(this, kDeveditionChangedNotification, false); this.window.addEventListener("unload", this); }; @@ -105,6 +113,8 @@ CustomizeMode.prototype = { #ifdef CAN_DRAW_IN_TITLEBAR Services.prefs.removeObserver(kDrawInTitlebarPref, this); #endif + Services.prefs.removeObserver(kDeveditionButtonPref, this); + Services.obs.removeObserver(this, kDeveditionChangedNotification); }, toggle: function() { @@ -1497,6 +1507,13 @@ CustomizeMode.prototype = { } } break; + case kDeveditionChangedNotification: + if (aSubject == this.window) { + this._updateDevEditionThemeButton(); + this._updateResetButton(); + this._updateUndoResetButton(); + } + break; } }, @@ -1521,6 +1538,44 @@ CustomizeMode.prototype = { }, #endif + _updateDevEditionThemeButton: function() { + let button = this.document.getElementById("customization-devedition-theme-button"); + + let themeEnabled = !!this.window.DevEdition.styleSheet; + if (themeEnabled) { + button.setAttribute("checked", "true"); + } else { + button.removeAttribute("checked"); + } + + let buttonVisible = Services.prefs.getBoolPref(kDeveditionButtonPref); + if (buttonVisible) { + button.removeAttribute("hidden"); + } else { + button.setAttribute("hidden", "true"); + } + }, + + toggleDevEditionTheme: function(shouldEnable) { + const DEFAULT_THEME_ID = "{972ce4c6-7e08-4474-a285-3208198ce6fd}"; + + Services.prefs.setBoolPref(kDeveditionThemePref, shouldEnable); + + let currentLWT = LightweightThemeManager.currentTheme; + if (currentLWT && shouldEnable) { + this._lastLightweightTheme = currentLWT; + AddonManager.getAddonByID(DEFAULT_THEME_ID, function(aDefaultTheme) { + // Theoretically, this could race if people are /very/ quick in switching + // something else here, so doublecheck: + if (Services.prefs.getBoolPref(kDeveditionThemePref)) { + aDefaultTheme.userDisabled = false; + } + }); + } else if (!currentLWT && !shouldEnable && this._lastLightweightTheme) { + LightweightThemeManager.currentTheme = this._lastLightweightTheme; + } + }, + _onDragStart: function(aEvent) { __dumpDragData(aEvent); let item = aEvent.target; diff --git a/browser/components/customizableui/content/customizeMode.inc.xul b/browser/components/customizableui/content/customizeMode.inc.xul index 232d4b0ee6d7..cc411df29a1c 100644 --- a/browser/components/customizableui/content/customizeMode.inc.xul +++ b/browser/components/customizableui/content/customizeMode.inc.xul @@ -53,6 +53,13 @@ +