Bug 1525762: Part 3d - Get rid of built-in LWT code. r=aswan
authorKris Maglione <maglione.k@gmail.com>
Fri, 08 Feb 2019 14:31:34 -0800
changeset 466978 9ad35a4e471750b50d76bc12c9e1fad00bf904d4
parent 466977 9b72a80ec78c1cf423c1fc9314df0bed0edd844a
child 466979 b7481329e0b7986283fbf9d443e19d575a841c9c
push id35789
push userbtara@mozilla.com
push dateSun, 31 Mar 2019 09:00:52 +0000
treeherdermozilla-central@c06dfc552c64 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan
bugs1525762
milestone68.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 1525762: Part 3d - Get rid of built-in LWT code. r=aswan
toolkit/mozapps/extensions/LightweightThemeManager.jsm
--- a/toolkit/mozapps/extensions/LightweightThemeManager.jsm
+++ b/toolkit/mozapps/extensions/LightweightThemeManager.jsm
@@ -49,39 +49,22 @@ var LightweightThemeManager = {
         _persistImages(_fallbackThemeData, () => {});
       }
     } else {
       _fallbackThemeData = null;
     }
     return _fallbackThemeData;
   },
 
-  // Themes that can be added for an application.  They can't be removed, and
-  // will always show up at the top of the list.
-  _builtInThemes: new Map(),
-
-  isBuiltIn(theme) {
-    return this._builtInThemes.has(theme.id);
-  },
-
-  get selectedThemeID() {
-    return _prefs.getStringPref("selectedThemeID") || DEFAULT_THEME_ID;
-  },
-
-  get defaultDarkThemeID() {
-    return _defaultDarkThemeID;
-  },
-
   get usedThemes() {
     let themes = [];
     try {
       themes = JSON.parse(_prefs.getStringPref("usedThemes"));
     } catch (e) { }
 
-    themes.push(...this._builtInThemes.values());
     return themes;
   },
 
   /*
    * Returns the currently active theme, but doesn't take a potentially
    * available fallback theme into account.
    *
    * This will always return the original theme data and not make use of
@@ -146,59 +129,27 @@ var LightweightThemeManager = {
       if (usedTheme.id == aId)
         return usedTheme;
     }
     return null;
   },
 
   forgetUsedTheme(aId) {
     let theme = this.getUsedTheme(aId);
-    if (!theme || LightweightThemeManager._builtInThemes.has(theme.id))
+    if (!theme)
       return;
 
     var currentTheme = this.currentTheme;
     if (currentTheme && currentTheme.id == aId) {
       this.themeChanged(null);
     }
 
     _updateUsedThemes(_usedThemesExceptId(aId));
   },
 
-  addBuiltInTheme(theme, { useInDarkMode } = {}) {
-    if (!theme || !theme.id || this.usedThemes.some(t => t.id == theme.id)) {
-      throw new Error("Trying to add invalid builtIn theme");
-    }
-
-    this._builtInThemes.set(theme.id, theme);
-
-    if (_prefs.getStringPref("selectedThemeID", DEFAULT_THEME_ID) == theme.id) {
-      this.currentTheme = theme;
-    }
-
-    if (useInDarkMode) {
-      _defaultDarkThemeID = theme.id;
-    }
-  },
-
-  forgetBuiltInTheme(id) {
-    if (!this._builtInThemes.has(id)) {
-      let currentTheme = this.currentTheme;
-      if (currentTheme && currentTheme.id == id) {
-        this.currentTheme = null;
-      }
-    }
-    return this._builtInThemes.delete(id);
-  },
-
-  clearBuiltInThemes() {
-    for (let id of this._builtInThemes.keys()) {
-      this.forgetBuiltInTheme(id);
-    }
-  },
-
   parseTheme(aString, aBaseURI) {
     try {
       return _sanitizeTheme(JSON.parse(aString), aBaseURI, false);
     } catch (e) {
       return null;
     }
   },
 
@@ -385,19 +336,16 @@ function _usedThemesExceptId(aId) {
     });
 }
 
 function _makeURI(aURL, aBaseURI) {
   return Services.io.newURI(aURL, null, aBaseURI);
 }
 
 function _updateUsedThemes(aList) {
-  // Remove app-specific themes before saving them to the usedThemes pref.
-  aList = aList.filter(theme => !LightweightThemeManager._builtInThemes.has(theme.id));
-
   _prefs.setStringPref("usedThemes", JSON.stringify(aList));
 
   Services.obs.notifyObservers(null, "lightweight-theme-list-changed");
 }
 
 function _notifyWindows(aThemeData) {
   Services.obs.notifyObservers(null, "lightweight-theme-styling-update",
                                JSON.stringify({theme: aThemeData}));