Bug 1466335: Automatically apply the dark theme on startup if the OS is in dark mode. r=dao
authorStephen A Pohl <spohl.mozilla.bugs@gmail.com>
Wed, 27 Jun 2018 13:59:40 -0400
changeset 479130 760705f94da446d77749544cd5bd8602cb7367a9
parent 479129 24fe98c45aae15108532297e7fceb70486888e24
child 479131 d07e9d2b54945f8344e56ab1063419afc22864e9
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdao
bugs1466335
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1466335: Automatically apply the dark theme on startup if the OS is in dark mode. r=dao
browser/base/content/browser-compacttheme.js
toolkit/mozapps/extensions/LightweightThemeManager.jsm
--- a/browser/base/content/browser-compacttheme.js
+++ b/browser/base/content/browser-compacttheme.js
@@ -17,17 +17,17 @@ var CompactTheme = {
     return this.styleSheet;
   },
 
   get isStyleSheetEnabled() {
     return this.styleSheet && !this.styleSheet.disabled;
   },
 
   get isThemeCurrentlyApplied() {
-    let theme = LightweightThemeManager.currentTheme;
+    let theme = LightweightThemeManager.currentThemeForDisplay;
     return theme && (
            theme.id == "firefox-compact-dark@mozilla.org" ||
            theme.id == "firefox-compact-light@mozilla.org");
   },
 
   init() {
     Services.obs.addObserver(this, "lightweight-theme-styling-update");
 
--- a/toolkit/mozapps/extensions/LightweightThemeManager.jsm
+++ b/toolkit/mozapps/extensions/LightweightThemeManager.jsm
@@ -135,18 +135,25 @@ var LightweightThemeManager = {
     if (selectedThemeID) {
       data = this.getUsedTheme(selectedThemeID);
     }
     return data;
   },
 
   get currentThemeForDisplay() {
     var data = this.currentTheme;
-    if ((!data || data.id == DEFAULT_THEME_ID) && _fallbackThemeData)
-      data = _fallbackThemeData;
+
+    if (!data || data.id == DEFAULT_THEME_ID) {
+      if (_fallbackThemeData) {
+        return _fallbackThemeData;
+      }
+      if (_defaultThemeIsInDarkMode) {
+        return this.getUsedTheme(DARK_THEME_ID);
+      }
+    }
 
     if (data && PERSIST_ENABLED) {
       for (let key in PERSIST_FILES) {
         try {
           if (data[key] && _prefs.getBoolPref("persisted." + key))
             data[key] = _getLocalImageURI(PERSIST_FILES[key]).spec
                         + "?" + data.id + ";" + _version(data);
         } catch (e) {}