зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1550090 - Fix theme active check. r=dao
Differential Revision: https://phabricator.services.mozilla.com/D30396 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
a9816040e9
Коммит
d2bb43bab6
|
@ -45,20 +45,11 @@ class Theme {
|
|||
if (startupData && startupData.lwtData) {
|
||||
Object.assign(this, startupData);
|
||||
} else {
|
||||
// TODO(ntim): clean this in bug 1550090
|
||||
this.lwtStyles = {};
|
||||
this.lwtDarkStyles = null;
|
||||
if (darkDetails) {
|
||||
this.lwtDarkStyles = {};
|
||||
}
|
||||
|
||||
if (experiment) {
|
||||
if (extension.experimentsAllowed) {
|
||||
this.lwtStyles.experimental = {
|
||||
colors: {},
|
||||
images: {},
|
||||
properties: {},
|
||||
};
|
||||
const {baseURI} = this.extension;
|
||||
if (experiment.stylesheet) {
|
||||
experiment.stylesheet = baseURI.resolve(experiment.stylesheet);
|
||||
|
@ -91,6 +82,8 @@ class Theme {
|
|||
this.lwtData = {
|
||||
theme: this.lwtStyles,
|
||||
darkTheme: this.lwtDarkStyles,
|
||||
id: this.extension.id,
|
||||
version: this.extension.version,
|
||||
};
|
||||
|
||||
if (this.experiment) {
|
||||
|
@ -126,6 +119,14 @@ class Theme {
|
|||
* @param {Object} styles Styles object in which to store the colors.
|
||||
*/
|
||||
loadDetails(details, styles) {
|
||||
if (this.experiment) {
|
||||
styles.experimental = {
|
||||
colors: {},
|
||||
images: {},
|
||||
properties: {},
|
||||
};
|
||||
}
|
||||
|
||||
if (details.colors) {
|
||||
this.loadColors(details.colors, styles);
|
||||
}
|
||||
|
@ -137,8 +138,6 @@ class Theme {
|
|||
if (details.properties) {
|
||||
this.loadProperties(details.properties, styles);
|
||||
}
|
||||
|
||||
this.loadMetadata(this.extension, styles);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -337,21 +336,10 @@ class Theme {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method for loading extension metadata required by downstream
|
||||
* consumers.
|
||||
*
|
||||
* @param {Object} extension Extension object.
|
||||
* @param {Object} styles Styles object in which to store the colors.
|
||||
*/
|
||||
loadMetadata(extension, styles) {
|
||||
styles.id = extension.id;
|
||||
styles.version = extension.version;
|
||||
}
|
||||
|
||||
static unload(windowId) {
|
||||
let lwtData = {
|
||||
theme: null,
|
||||
theme: {},
|
||||
darkTheme: {},
|
||||
};
|
||||
|
||||
if (windowId) {
|
||||
|
|
|
@ -189,12 +189,9 @@ LightweightThemeConsumer.prototype = {
|
|||
this._lastData = themeData;
|
||||
|
||||
let theme = themeData.theme;
|
||||
if (themeData.darkTheme && this.darkMode) {
|
||||
if (Object.keys(themeData.darkTheme).length && this.darkMode) {
|
||||
theme = themeData.darkTheme;
|
||||
}
|
||||
if (!theme) {
|
||||
theme = { id: DEFAULT_THEME_ID };
|
||||
}
|
||||
|
||||
let active = this._active = Object.keys(theme).length;
|
||||
|
||||
|
@ -206,8 +203,6 @@ LightweightThemeConsumer.prototype = {
|
|||
root.removeAttribute("lwtheme-image");
|
||||
}
|
||||
|
||||
this._setExperiment(active, themeData.experiment, theme.experimental);
|
||||
|
||||
if (theme.headerImage) {
|
||||
this._doc.mozSetImageElement("lwt-header-image", theme.headerImage);
|
||||
root.style.setProperty("--lwt-header-image", "-moz-element(#lwt-header-image)");
|
||||
|
@ -218,14 +213,15 @@ LightweightThemeConsumer.prototype = {
|
|||
|
||||
_setImage(root, active, "--lwt-additional-images", theme.additionalBackgrounds);
|
||||
_setProperties(root, active, theme);
|
||||
this._setExperiment(active, themeData.experiment, theme.experimental);
|
||||
|
||||
if (theme.id != DEFAULT_THEME_ID || this.darkMode) {
|
||||
if (active) {
|
||||
root.setAttribute("lwtheme", "true");
|
||||
} else {
|
||||
root.removeAttribute("lwtheme");
|
||||
root.removeAttribute("lwthemetextcolor");
|
||||
}
|
||||
if (theme.id == DEFAULT_THEME_ID && this.darkMode) {
|
||||
if (themeData.id == DEFAULT_THEME_ID && this.darkMode) {
|
||||
root.setAttribute("lwt-default-theme-in-dark-mode", "true");
|
||||
} else {
|
||||
root.removeAttribute("lwt-default-theme-in-dark-mode");
|
||||
|
|
Загрузка…
Ссылка в новой задаче