Backed out changeset db927eedd355 (bug 1504766) for multiple failures e.g browser_ext_management_themes.js. CLOSED TREE
authorCsoregi Natalia <ncsoregi@mozilla.com>
Wed, 20 Feb 2019 08:55:36 +0200
changeset 517908 5bd82b961200389233b8579eed5713fc3cc649cd
parent 517907 2c10e071b8dec0b4442695583caff26b0ddaec06
child 517909 9327a3eb37326b8c53d138cd4083b0d71ed826fa
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1504766
milestone67.0a1
backs outdb927eedd3559216703d4978f8c6180cf2105733
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
Backed out changeset db927eedd355 (bug 1504766) for multiple failures e.g browser_ext_management_themes.js. CLOSED TREE
browser/themes/windows/browser-aero.css
browser/themes/windows/compacttheme.css
toolkit/modules/LightweightThemeConsumer.jsm
toolkit/mozapps/extensions/LightweightThemeManager.jsm
--- a/browser/themes/windows/browser-aero.css
+++ b/browser/themes/windows/browser-aero.css
@@ -65,25 +65,20 @@
             color: hsl(240,9%,98%);
           }
         }
 
         @media (-moz-windows-accent-color-in-titlebar) {
           :root[sizemode=normal][tabsintitlebar] {
             border-top: 1px solid -moz-win-accentcolor;
           }
-          :root[tabsintitlebar]:not(:-moz-window-inactive):not(:-moz-lwtheme),
-          :root[tabsintitlebar]:not(:-moz-window-inactive)[lwt-default-theme-in-dark-mode] {
+          :root[tabsintitlebar]:not(:-moz-window-inactive):not(:-moz-lwtheme) {
             background-color: -moz-win-accentcolor;
             color: -moz-win-accentcolortext;
           }
-          :root[tabsintitlebar][lwt-default-theme-in-dark-mode] #titlebar {
-            --lwt-toolbarbutton-icon-fill: currentColor;
-            --toolbarbutton-icon-fill-opacity: .7;
-          }
         }
 
         :root[sizemode=normal][tabsintitlebar]:-moz-window-inactive {
           border-top-color: rgba(0,0,0,.3);
         }
 
         :root[tabsintitlebar] .tab-label:-moz-window-inactive {
           /* Calculated to match the opacity change of Windows Explorer
--- a/browser/themes/windows/compacttheme.css
+++ b/browser/themes/windows/compacttheme.css
@@ -1,14 +1,25 @@
 % This Source Code Form is subject to the terms of the Mozilla Public
 % License, v. 2.0. If a copy of the MPL was not distributed with this
 % file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 %include ../shared/compacttheme.inc.css
 
+@media (-moz-windows-default-theme) and (-moz-windows-accent-color-in-titlebar) {
+  :root[tabsintitlebar]:not(:-moz-window-inactive) {
+    background-color: -moz-win-accentcolor;
+    color: -moz-win-accentcolortext;
+  }
+  :root[tabsintitlebar] #titlebar {
+    --lwt-toolbarbutton-icon-fill: currentColor;
+    --toolbarbutton-icon-fill-opacity: .7;
+  }
+}
+
 /* The window background is white due to no accentcolor in the lightweight
    theme. It can't be changed to transparent when there is no compositor
    (Win 7 in classic / basic theme), or else dragging and focus become
    broken. So instead just show the normal titlebar in that case, and override
    the window color as transparent when the compositor is available. */
 @media (-moz-windows-compositor: 0) {
   :root[tabsintitlebar]:not([inDOMFullscreen]) > #navigator-toolbox > #titlebar:-moz-lwtheme {
     visibility: visible;
--- a/toolkit/modules/LightweightThemeConsumer.jsm
+++ b/toolkit/modules/LightweightThemeConsumer.jsm
@@ -124,26 +124,26 @@ ChromeUtils.defineModuleGetter(this, "Li
 
 function LightweightThemeConsumer(aDocument) {
   this._doc = aDocument;
   this._win = aDocument.defaultView;
   this._winId = this._win.windowUtils.outerWindowID;
 
   Services.obs.addObserver(this, "lightweight-theme-styling-update");
 
-  ChromeUtils.import("resource://gre/modules/LightweightThemeManager.jsm", this);
-
-  this._darkThemeMediaQuery = this._win.matchMedia("(-moz-system-dark-theme)");
-  this._darkThemeMediaQuery.addListener(this.LightweightThemeManager);
-  this.LightweightThemeManager.systemThemeChanged(this._darkThemeMediaQuery);
-
-  this._update(this.LightweightThemeManager.currentThemeWithPersistedData);
+  var temp = {};
+  ChromeUtils.import("resource://gre/modules/LightweightThemeManager.jsm", temp);
+  this._update(temp.LightweightThemeManager.currentThemeWithPersistedData);
 
   this._win.addEventListener("resolutionchange", this);
   this._win.addEventListener("unload", this, { once: true });
+
+  let darkThemeMediaQuery = this._win.matchMedia("(-moz-system-dark-theme)");
+  darkThemeMediaQuery.addListener(temp.LightweightThemeManager);
+  temp.LightweightThemeManager.systemThemeChanged(darkThemeMediaQuery);
 }
 
 LightweightThemeConsumer.prototype = {
   _lastData: null,
   // Whether a lightweight theme is enabled.
   _active: false,
 
   observe(aSubject, aTopic, aData) {
@@ -168,43 +168,33 @@ LightweightThemeConsumer.prototype = {
         if (this._active) {
           this._update(this._lastData);
         }
         break;
       case "unload":
         Services.obs.removeObserver(this, "lightweight-theme-styling-update");
         Services.ppmm.sharedData.delete(`theme/${this._winId}`);
         this._win.removeEventListener("resolutionchange", this);
-        this._darkThemeMediaQuery.removeListener(this.LightweightThemeManager);
-        this._win = this._doc = this._darkThemeMediaQuery = null;
+        this._win = this._doc = null;
         break;
     }
   },
 
   _update(theme, experiment) {
     this._lastData = theme;
     if (theme) {
       theme = LightweightThemeImageOptimizer.optimize(theme, this._win.screen);
     }
+
+    let active = this._active = theme && theme.id !== DEFAULT_THEME_ID;
+
     if (!theme) {
       theme = {};
     }
 
-    let active = this._active = (theme.id != DEFAULT_THEME_ID);
-
-    // The theme we're switching to can be different from the user-selected
-    // theme. E.g. if the default theme is selected and the OS is in dark mode,
-    // we'd silently activate the dark theme if available. We set an attribute
-    // in that case so stylesheets can differentiate this from the dark theme
-    // being selected explicitly by the user.
-    let isDefaultThemeInDarkMode =
-      theme.id == this.LightweightThemeManager.defaultDarkThemeID &&
-      this.LightweightThemeManager.selectedThemeID == DEFAULT_THEME_ID &&
-      this._darkThemeMediaQuery.matches;
-
     let root = this._doc.documentElement;
 
     if (active && theme.headerURL) {
       root.setAttribute("lwtheme-image", "true");
     } else {
       root.removeAttribute("lwtheme-image");
     }
 
@@ -226,21 +216,16 @@ LightweightThemeConsumer.prototype = {
     _setProperties(root, active, theme);
 
     if (active) {
       root.setAttribute("lwtheme", "true");
     } else {
       root.removeAttribute("lwtheme");
       root.removeAttribute("lwthemetextcolor");
     }
-    if (isDefaultThemeInDarkMode) {
-      root.setAttribute("lwt-default-theme-in-dark-mode", "true");
-    } else {
-      root.removeAttribute("lwt-default-theme-in-dark-mode");
-    }
 
     let contentThemeData = _getContentProperties(this._doc, active, theme);
     Services.ppmm.sharedData.set(`theme/${this._winId}`, contentThemeData);
   },
 
   _setExperiment(active, experiment, properties) {
     const root = this._doc.documentElement;
     if (this._lastExperimentData) {
--- a/toolkit/mozapps/extensions/LightweightThemeManager.jsm
+++ b/toolkit/mozapps/extensions/LightweightThemeManager.jsm
@@ -97,24 +97,16 @@ var LightweightThemeManager = {
   // 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;
@@ -123,18 +115,19 @@ var LightweightThemeManager = {
   /*
    * 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
    * locally persisted resources.
    */
   get currentTheme() {
+    let selectedThemeID = _prefs.getStringPref("selectedThemeID", DEFAULT_THEME_ID);
+
     let data = null;
-    let selectedThemeID = this.selectedThemeID;
     if (selectedThemeID) {
       data = this.getUsedTheme(selectedThemeID);
     }
     return data;
   },
 
   /*
    * Returns the currently active theme, taking the fallback theme into account
@@ -208,17 +201,17 @@ var LightweightThemeManager = {
 
   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 (this.selectedThemeID == theme.id) {
+    if (_prefs.getStringPref("selectedThemeID", DEFAULT_THEME_ID) == theme.id) {
       this.currentTheme = theme;
     }
 
     if (useInDarkMode) {
       _defaultDarkThemeID = theme.id;
     }
   },
 
@@ -370,17 +363,17 @@ var LightweightThemeManager = {
 
     let allThemes;
     try {
       allThemes = JSON.parse(_prefs.getStringPref("usedThemes"));
     } catch (e) {
       return;
     }
 
-    let selectedID = this.selectedThemeID;
+    let selectedID = _prefs.getStringPref("selectedThemeID", DEFAULT_THEME_ID);
     let newThemes = await Promise.all(allThemes.map(
       t => this._updateOneTheme(t, t.id == selectedID).catch(err => {})));
     newThemes = newThemes.filter(t => t);
     _prefs.setStringPref("usedThemes", JSON.stringify(newThemes));
   },
 
   /**
    * Switches to a new lightweight theme.
@@ -503,17 +496,17 @@ var LightweightThemeManager = {
     } else if (!aEvent.matches && _defaultThemeIsInDarkMode) {
       themeToSwitchTo = this.getUsedTheme(DEFAULT_THEME_ID);
       _defaultThemeIsInDarkMode = false;
     } else {
       // We are already set to the correct mode. Bail out early.
       return;
     }
 
-    if (this.selectedThemeID != DEFAULT_THEME_ID) {
+    if (_prefs.getStringPref("selectedThemeID", "") != DEFAULT_THEME_ID) {
       return;
     }
 
     if (themeToSwitchTo) {
       let usedThemes = _usedThemesExceptId(themeToSwitchTo.id);
       usedThemes.unshift(themeToSwitchTo);
       _updateUsedThemes(usedThemes);
       if (LightweightThemePersister.persistEnabled) {