diff --git a/browser/base/content/browser-addons.js b/browser/base/content/browser-addons.js index 13d0b0fbe8a8..509558107609 100644 --- a/browser/base/content/browser-addons.js +++ b/browser/base/content/browser-addons.js @@ -798,7 +798,7 @@ var LightweightThemeListener = { Services.obs.addObserver(this, "lightweight-theme-styling-update", false); Services.obs.addObserver(this, "lightweight-theme-optimized", false); if (document.documentElement.hasAttribute("lwtheme")) - this.updateStyleSheet(document.documentElement.style.backgroundImage); + this.updateStyleSheet(document.documentElement.style.getPropertyValue("--lwt-header-image")); }, uninit() { diff --git a/browser/themes/linux/browser.css b/browser/themes/linux/browser.css index 0b3c043e9378..f9aa30ba9bf2 100644 --- a/browser/themes/linux/browser.css +++ b/browser/themes/linux/browser.css @@ -42,6 +42,12 @@ --lwt-header-image: none; } +:root { + color: var(--lwt-textcolor); + background-color: var(--lwt-accentcolor); + background-image: var(--lwt-header-image); +} + #menubar-items { -moz-box-orient: vertical; /* for flex hack */ } @@ -127,6 +133,11 @@ background-color: -moz-Dialog; } +#browser-bottombox:-moz-lwtheme { + background-color: var(--lwt-accentcolor); + background-image: var(--lwt-header-image); +} + /* Places toolbar */ toolbarbutton.bookmark-item:not(.subviewbutton), #personal-bookmarks[cui-areatype="toolbar"]:not([overflowedItem=true]) > #bookmarks-toolbar-placeholder { diff --git a/browser/themes/osx/browser.css b/browser/themes/osx/browser.css index bc8eee0fb7ca..05a4bd7a2e37 100644 --- a/browser/themes/osx/browser.css +++ b/browser/themes/osx/browser.css @@ -53,6 +53,12 @@ --lwt-header-image: none; } +:root { + color: var(--lwt-textcolor); + background-color: var(--lwt-accentcolor); + background-image: var(--lwt-header-image); +} + #urlbar:-moz-lwtheme:not([focused="true"]), .searchbar-textbox:-moz-lwtheme:not([focused="true"]) { opacity: .9; @@ -3357,6 +3363,11 @@ menulist.translate-infobar-element > .menulist-dropmarker { -moz-box-ordinal-group: 0; } +#browser-bottombox:-moz-lwtheme { + background-color: var(--lwt-accentcolor); + background-image: var(--lwt-footer-image); +} + %include ../shared/UITour.inc.css #UITourTooltipDescription { diff --git a/browser/themes/windows/browser.css b/browser/themes/windows/browser.css index 8551636eefa4..ec4b27fe0c65 100644 --- a/browser/themes/windows/browser.css +++ b/browser/themes/windows/browser.css @@ -83,6 +83,12 @@ toolbar:-moz-lwtheme { --toolbarbutton-checkedhover-backgroundcolor: rgba(85%,85%,85%,.25); } +:root { + color: var(--lwt-textcolor); + background-color: var(--lwt-accentcolor); + background-image: var(--lwt-header-image); +} + #menubar-items { -moz-box-orient: vertical; /* for flex hack */ } @@ -338,6 +344,11 @@ toolbar:-moz-lwtheme { -moz-appearance: toolbox; } +#browser-bottombox:-moz-lwtheme { + background-color: var(--lwt-accentcolor); + background-image: var(--lwt-footer-image); +} + #browser-bottombox:not(:-moz-lwtheme) { background-color: -moz-dialog; } diff --git a/toolkit/modules/LightweightThemeConsumer.jsm b/toolkit/modules/LightweightThemeConsumer.jsm index de6e64646830..532d7c173478 100644 --- a/toolkit/modules/LightweightThemeConsumer.jsm +++ b/toolkit/modules/LightweightThemeConsumer.jsm @@ -104,11 +104,11 @@ LightweightThemeConsumer.prototype = { // We need to clear these either way: either because the theme is being removed, // or because we are applying a new theme and the data might be bogus CSS, // so if we don't reset first, it'll keep the old value. - root.style.removeProperty("color"); - root.style.removeProperty("background-color"); + root.style.removeProperty("--lwt-textcolor"); + root.style.removeProperty("--lwt-accentcolor"); if (active) { - root.style.color = aData.textcolor || "black"; - root.style.backgroundColor = aData.accentcolor || "white"; + root.style.setProperty("--lwt-textcolor", aData.textcolor || "black"); + root.style.setProperty("--lwt-accentcolor", aData.accentcolor || "white"); let [r, g, b] = _parseRGB(this._doc.defaultView.getComputedStyle(root).color); let luminance = 0.2125 * r + 0.7154 * g + 0.0721 * b; root.setAttribute("lwthemetextcolor", luminance <= 110 ? "dark" : "bright"); @@ -120,11 +120,10 @@ LightweightThemeConsumer.prototype = { this._active = active; - _setImage(root, active, aData.headerURL); + _setImage(root, active, aData.headerURL, "--lwt-header-image"); if (this._footerId) { let footer = this._doc.getElementById(this._footerId); - footer.style.backgroundColor = active ? aData.accentcolor || "white" : ""; - _setImage(footer, active, aData.footerURL); + _setImage(footer, active, aData.footerURL, "--lwt-footer-image"); if (active && aData.footerURL) footer.setAttribute("lwthemefooter", "true"); else @@ -157,9 +156,12 @@ LightweightThemeConsumer.prototype = { } } -function _setImage(aElement, aActive, aURL) { - aElement.style.backgroundImage = - (aActive && aURL) ? 'url("' + aURL.replace(/"/g, '\\"') + '")' : ""; +function _setImage(aElement, aActive, aURL, aVariableName) { + if (aActive && aURL) { + aElement.style.setProperty(aVariableName, `url("${aURL.replace(/"/g, '\\"')}")`); + } else { + aElement.style.removeProperty(aVariableName); + } } function _parseRGB(aColorString) {