--- a/browser/base/content/browser-addons.js
+++ b/browser/base/content/browser-addons.js
@@ -784,49 +784,8 @@ var LightWeightThemeWebInstaller = {
if (!uri.schemeIs("https")) {
return false;
}
let pm = Services.perms;
return pm.testPermission(uri, "install") == pm.ALLOW_ACTION;
}
};
-
-/*
- * Listen for Lightweight Theme styling changes and update the browser's theme accordingly.
- */
-var LightweightThemeListener = {
- init() {
- 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.getPropertyValue("--lwt-header-image"));
- },
-
- uninit() {
- Services.obs.removeObserver(this, "lightweight-theme-styling-update");
- Services.obs.removeObserver(this, "lightweight-theme-optimized");
- },
-
- /**
- * Set the headerImage to a CSS variable which is used to apply the background-image
- * property of the respective rulesets in tabs.inc.css.
- *
- * @param headerImage - a string containing a CSS image for the lightweight theme header.
- */
- updateStyleSheet(headerImage) {
- document.documentElement.style.setProperty("--lwt-header-image", headerImage);
-},
- // nsIObserver
- observe(aSubject, aTopic, aData) {
- if (aTopic != "lightweight-theme-styling-update" &&
- aTopic != "lightweight-theme-optimized")
- return;
-
- if (aTopic == "lightweight-theme-optimized" && aSubject != window)
- return;
-
- let themeData = JSON.parse(aData);
- if (!themeData)
- return;
- this.updateStyleSheet("url(" + themeData.headerURL + ")");
- },
-};
--- a/browser/base/content/browser.css
+++ b/browser/base/content/browser.css
@@ -6,16 +6,25 @@
@namespace html url("http://www.w3.org/1999/xhtml");
@namespace svg url("http://www.w3.org/2000/svg");
:root {
--identity-popup-expander-width: 38px;
--panelui-subview-transition-duration: 150ms;
}
+:root:-moz-lwtheme {
+ color: var(--lwt-textcolor) !important;
+}
+
+:root:-moz-lwtheme:not([customization-lwtheme]) {
+ background-color: var(--lwt-accentcolor) !important;
+ background-image: var(--lwt-header-image) !important;
+}
+
#main-window:not([chromehidden~="toolbar"]) {
%ifdef XP_MACOSX
min-width: 335px;
%else
min-width: 300px;
%endif
}
@@ -440,16 +449,18 @@ toolbar:not(#TabsToolbar) > #personal-bo
#main-window[inFullscreen="true"] {
padding-top: 0; /* override drawintitlebar="true" */
}
%endif
#browser-bottombox[lwthemefooter="true"] {
background-repeat: no-repeat;
background-position: bottom left;
+ background-color: var(--lwt-accentcolor);
+ background-image: var(--lwt-header-image);
}
.menuitem-iconic-tooltip {
-moz-binding: url("chrome://browser/content/urlbarBindings.xml#menuitem-iconic-tooltip");
}
/* Hide menu elements intended for keyboard access support */
#main-menubar[openedwithkey=false] .show-only-for-keyboard {
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -1362,17 +1362,16 @@ var gBrowserInit = {
if (AppConstants.E10S_TESTING_ONLY)
gRemoteTabsUI.init();
// Initialize the full zoom setting.
// We do this before the session restore service gets initialized so we can
// apply full zoom settings to tabs restored by the session restore service.
FullZoom.init();
PanelUI.init();
- LightweightThemeListener.init();
UpdateUrlbarSearchSplitterState();
if (!(isBlankPageURL(uriToLoad) || uriToLoad == "about:privatebrowsing") ||
!focusAndSelectUrlBar()) {
if (gBrowser.selectedBrowser.isRemoteBrowser) {
// If the initial browser is remote, in order to optimize for first paint,
// we'll defer switching focus to that browser until it has painted.
@@ -1699,17 +1698,16 @@ var gBrowserInit = {
}
if (this.gmpInstallManager) {
this.gmpInstallManager.uninit();
}
BrowserOffline.uninit();
IndexedDBPromptHelper.uninit();
- LightweightThemeListener.uninit();
PanelUI.uninit();
AutoShowBookmarksToolbar.uninit();
}
// Final window teardown, do this last.
window.XULBrowserWindow = null;
window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
--- a/browser/components/customizableui/CustomizeMode.jsm
+++ b/browser/components/customizableui/CustomizeMode.jsm
@@ -442,17 +442,17 @@ CustomizeMode.prototype = {
undoResetButton.hidden = resetButton.disabled = true;
this._transitioning = true;
Task.spawn(function*() {
yield this.depopulatePalette();
yield this._doTransition(false);
- this.removeLWTStyling();
+ this.updateLWTStyling({});
Services.obs.removeObserver(this, "lightweight-theme-window-updated");
if (this.browser.selectedTab == gTab) {
if (gTab.linkedBrowser.currentURI.spec == "about:blank") {
closeGlobalTab();
} else {
unregisterGlobalTab();
@@ -606,81 +606,26 @@ CustomizeMode.prototype = {
updateLWTStyling(aData) {
let docElement = this.document.documentElement;
if (!aData) {
let lwt = docElement._lightweightTheme;
aData = lwt.getData();
}
let headerURL = aData && aData.headerURL;
if (!headerURL) {
- this.removeLWTStyling();
+ docElement.removeAttribute("customization-lwtheme");
return;
}
+ docElement.setAttribute("customization-lwtheme", "true");
let deck = this.document.getElementById("tab-view-deck");
- let headerImageRef = this._getHeaderImageRef(aData);
- docElement.setAttribute("customization-lwtheme", "true");
-
let toolboxRect = this.window.gNavToolbox.getBoundingClientRect();
let height = toolboxRect.bottom;
-
- if (AppConstants.platform == "macosx") {
- let drawingInTitlebar = !docElement.hasAttribute("drawtitle");
- let titlebar = this.document.getElementById("titlebar");
- if (drawingInTitlebar) {
- titlebar.setProperty("--lwt-header-image", headerImageRef);
- } else {
- titlebar.style.removeProperty("--lwt-header-image");
- }
- }
-
- let limitedBG = "-moz-image-rect(" + headerImageRef + ", 0, 100%, " +
- height + ", 0)";
-
- let ridgeStart = height - 1;
- let ridgeCenter = (ridgeStart + 1) + "px";
- let ridgeEnd = (ridgeStart + 2) + "px";
- ridgeStart = ridgeStart + "px";
-
- let ridge = "linear-gradient(to bottom, " +
- "transparent " + ridgeStart +
- ", rgba(0,0,0,0.25) " + ridgeStart +
- ", rgba(0,0,0,0.25) " + ridgeCenter +
- ", rgba(255,255,255,0.5) " + ridgeCenter +
- ", rgba(255,255,255,0.5) " + ridgeEnd + ", " +
- "transparent " + ridgeEnd + ")";
- deck.style.setProperty("--lwt-header-image", ridge + ", " + limitedBG);
-
- let tabs = this.document.getElementById("tabbrowser-tabs");
- tabs.style.setProperty("--lwt-header-image", headerImageRef);
-
- /* Remove the background styles from the <window> so we can style it instead. */
- docElement.style.removeProperty("--lwt-header-image");
- docElement.style.removeProperty("--lwt-accentcolor");
- },
-
- removeLWTStyling() {
- let affectedNodes = AppConstants.platform == "macosx" ?
- ["tab-view-deck", "titlebar"] :
- ["tab-view-deck"];
- for (let id of affectedNodes) {
- let node = this.document.getElementById(id);
- node.style.removeProperty("--lwt-header-image");
- }
- let docElement = this.document.documentElement;
- docElement.removeAttribute("customization-lwtheme");
- let data = docElement._lightweightTheme.getData();
- if (data && data.headerURL) {
- docElement.style.setProperty("--lwt-header-image", this._getHeaderImageRef(data));
- docElement.style.setProperty("--lwt-accentcolor", data.accentcolor || "white");
- }
- },
-
- _getHeaderImageRef(aData) {
- return "url(\"" + aData.headerURL.replace(/"/g, '\\"') + "\")";
+ deck.style.setProperty("--toolbox-rect-height", `${height}`);
+ deck.style.setProperty("--toolbox-rect-height-with-unit", `${height}px`);
},
maybeShowTip(aAnchor) {
let shown = false;
const kShownPref = "browser.customizemode.tip0.shown";
try {
shown = Services.prefs.getBoolPref(kShownPref);
} catch (ex) {}
@@ -1542,21 +1487,17 @@ CustomizeMode.prototype = {
this._updateUndoResetButton();
if (AppConstants.CAN_DRAW_IN_TITLEBAR) {
this._updateTitlebarButton();
}
break;
case "lightweight-theme-window-updated":
if (aSubject == this.window) {
aData = JSON.parse(aData);
- if (!aData) {
- this.removeLWTStyling();
- } else {
- this.updateLWTStyling(aData);
- }
+ this.updateLWTStyling(aData);
}
break;
}
},
_updateTitlebarButton() {
if (!AppConstants.CAN_DRAW_IN_TITLEBAR) {
return;
--- a/browser/themes/linux/browser.css
+++ b/browser/themes/linux/browser.css
@@ -35,24 +35,16 @@
--toolbarbutton-checkedhover-backgroundcolor: rgba(200,200,200,.5);
--panel-separator-color: ThreeDShadow;
--arrowpanel-dimmed: hsla(0,0%,80%,.3);
--arrowpanel-dimmed-further: hsla(0,0%,80%,.45);
--arrowpanel-dimmed-even-further: hsla(0,0%,80%,.8);
--urlbar-separator-color: ThreeDShadow;
-
- --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 */
}
#main-menubar {
-moz-box-flex: 1; /* make menu items expand to fill toolbar height */
@@ -130,21 +122,16 @@
min-height: 30px;
}
#browser-bottombox {
/* opaque for layers optimization */
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 {
margin: 0;
padding: 2px 3px;
}
toolbarbutton.bookmark-item:not(.subviewbutton):not(:hover):not(:active):not([open]) {
@@ -1532,25 +1519,16 @@ notification.pluginVulnerable > .notific
%include ../shared/customizableui/customizeMode.inc.css
#main-window[customize-entered] > #tab-view-deck {
background-image: url("chrome://browser/skin/customizableui/customizeMode-gridTexture.png"),
linear-gradient(to bottom, #bcbcbc, #b5b5b5);
background-attachment: fixed;
}
-#main-window[customization-lwtheme] > #tab-view-deck:-moz-lwtheme {
- background-repeat: no-repeat;
- background-position: right top;
- background-attachment: fixed;
- /* The image will get set from CustomizeMode.jsm */
- background-image: var(--lwt-header-image);
- background-color: transparent;
-}
-
#main-window[customization-lwtheme]:-moz-lwtheme {
background-image: url("chrome://browser/skin/customizableui/customizeMode-gridTexture.png"),
url("chrome://browser/skin/customizableui/background-noise-toolbar.png"),
linear-gradient(to bottom, #bcbcbc, #b5b5b5);
background-color: #b5b5b5;
background-repeat: repeat;
background-attachment: fixed;
background-position: left top;
--- a/browser/themes/osx/browser.css
+++ b/browser/themes/osx/browser.css
@@ -46,24 +46,16 @@
--urlbar-dropmarker-active-2x-region: rect(0, 44px, 28px, 22px);
--panel-separator-color: hsla(210,4%,10%,.14);
--arrowpanel-dimmed: hsla(210,4%,10%,.07);
--arrowpanel-dimmed-further: hsla(210,4%,10%,.12);
--arrowpanel-dimmed-even-further: hsla(210,4%,10%,.17);
--urlbar-separator-color: hsla(0,0%,16%,.2);
-
- --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;
}
#navigator-toolbox::after {
@@ -3193,24 +3185,22 @@ menulist.translate-infobar-element > .me
#main-window[privatebrowsingmode=temporary]:not([tabsintitlebar])[customize-entered] > #titlebar,
#main-window[customize-entered] > #tab-view-deck {
background-image: url("chrome://browser/skin/customizableui/customizeMode-gridTexture.png"),
url("chrome://browser/skin/customizableui/background-noise-toolbar.png"),
linear-gradient(to bottom, rgb(233,233,233), rgb(178,178,178) 40px);
background-attachment: fixed;
}
-#main-window[tabsintitlebar][customization-lwtheme] > #titlebar:-moz-lwtheme,
-#main-window[customization-lwtheme] > #tab-view-deck:-moz-lwtheme {
+#main-window[tabsintitlebar][customization-lwtheme] > #titlebar:-moz-lwtheme {
background-repeat: no-repeat;
background-position: right top;
background-attachment: fixed;
- /* The image will get set from CustomizeMode.jsm */
background-image: var(--lwt-header-image);
- background-color: transparent;
+ background-color: var(--lwt-accentcolor);
}
#main-window[customization-lwtheme]:-moz-lwtheme {
background-image: url("chrome://browser/skin/customizableui/customizeMode-gridTexture.png"),
url("chrome://browser/skin/customizableui/background-noise-toolbar.png");
background-color: rgb(178,178,178);
background-repeat: repeat;
background-attachment: fixed;
@@ -3330,21 +3320,16 @@ menulist.translate-infobar-element > .me
position and padding for the private browsing indicator. */
display: -moz-box;
}
#TabsToolbar > .private-browsing-indicator:-moz-locale-dir(rtl) {
-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 {
font-size: 1.18rem;
line-height: 2rem;
}
#UITourTooltipClose {
--- a/browser/themes/shared/customizableui/customizeMode.inc.css
+++ b/browser/themes/shared/customizableui/customizeMode.inc.css
@@ -3,16 +3,32 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* Customization mode */
:root {
--drag-drop-transition-duration: .3s;
}
+#main-window[customization-lwtheme] #tab-view-deck:-moz-lwtheme {
+ background-repeat: no-repeat;
+ background-position: right top;
+ background-attachment: fixed;
+ background-color: transparent;
+ background-image: -moz-image-rect(var(--lwt-header-image), 0, 100%,
+ var(--toolbox-rect-height), 0),
+ linear-gradient(to bottom,
+ var(--lwt-accentcolor) calc(var(--toolbox-rect-height-with-unit) - 1px),
+ rgba(0,0,0,0.25) calc(var(--toolbox-rect-height-with-unit) - 1px),
+ rgba(0,0,0,0.25) calc(var(--toolbox-rect-height-with-unit) + 1px),
+ rgba(255,255,255,0.5) calc(var(--toolbox-rect-height-with-unit) + 1px),
+ rgba(255,255,255,0.5) calc(var(--toolbox-rect-height-with-unit) + 2px),
+ transparent calc(var(--toolbox-rect-height-with-unit) + 2px));
+}
+
#main-window:-moz-any([customize-entering],[customize-entered]) #browser-bottombox {
margin-bottom: 2em;
}
#main-window:-moz-any([customize-entering],[customize-entered]) #content-deck,
#main-window:-moz-any([customize-entering],[customize-entered]) #browser-bottombox,
#main-window:-moz-any([customize-entering],[customize-entered]) #navigator-toolbox {
margin-left: 2em;
--- a/browser/themes/windows/browser.css
+++ b/browser/themes/windows/browser.css
@@ -48,18 +48,16 @@
--urlbar-dropmarker-active-2x-region: rect(0, 66px, 28px, 44px);
--panel-separator-color: ThreeDLightShadow;
--arrowpanel-dimmed: hsla(0,0%,80%,.3);
--arrowpanel-dimmed-further: hsla(0,0%,80%,.45);
--arrowpanel-dimmed-even-further: hsla(0,0%,80%,.8);
--urlbar-separator-color: ThreeDLightShadow;
-
- --lwt-header-image: none;
}
@media (-moz-windows-default-theme) {
:root {
--panel-separator-color: hsla(210,4%,10%,.14);
}
}
@@ -80,22 +78,16 @@ toolbar:-moz-lwtheme {
--toolbarbutton-active-background: rgba(70%,70%,70%,.25);
--toolbarbutton-active-bordercolor: rgba(0,0,0,.3);
--toolbarbutton-active-boxshadow: 0 0 2px rgba(0,0,0,.6) inset;
--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 */
}
#main-menubar {
-moz-box-flex: 1; /* make menu items expand to fill toolbar height */
}
@@ -341,21 +333,16 @@ toolbar:-moz-lwtheme {
#personal-bookmarks {
min-height: 24px;
}
#print-preview-toolbar:not(:-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;
}
/* ::::: titlebar ::::: */
#main-window[sizemode="normal"] > #titlebar {
-moz-appearance: -moz-window-titlebar;
@@ -2335,25 +2322,16 @@ notification.pluginVulnerable > .notific
transform: perspective(0.01px);
}
#main-window[customize-entered] > #tab-view-deck {
background-image: url("chrome://browser/skin/customizableui/customizeMode-gridTexture.png");
background-attachment: fixed;
}
-#main-window[customization-lwtheme] > #tab-view-deck:-moz-lwtheme {
- background-repeat: no-repeat;
- background-position: right top;
- background-attachment: fixed;
- /* The image will get set from CustomizeMode.jsm */
- background-image: var(--lwt-header-image);
- background-color: transparent;
-}
-
#main-window[customization-lwtheme]:-moz-lwtheme {
background-image: url("chrome://browser/skin/customizableui/customizeMode-gridTexture.png");
background-repeat: repeat;
background-attachment: fixed;
background-position: left top;
}
#main-window[customize-entered] #browser-bottombox,
--- a/toolkit/modules/LightweightThemeConsumer.jsm
+++ b/toolkit/modules/LightweightThemeConsumer.jsm
@@ -102,19 +102,22 @@ LightweightThemeConsumer.prototype = {
let stateChanging = (active != this._active);
// 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("--lwt-textcolor");
root.style.removeProperty("--lwt-accentcolor");
if (active) {
- root.style.setProperty("--lwt-textcolor", aData.textcolor || "black");
+ let textcolor = aData.textcolor || "black";
+ root.style.setProperty("--lwt-textcolor", textcolor);
root.style.setProperty("--lwt-accentcolor", aData.accentcolor || "white");
- let [r, g, b] = _parseRGB(this._doc.defaultView.getComputedStyle(root).color);
+ let dummy = this._doc.createElement("dummy");
+ dummy.style.color = textcolor;
+ let [r, g, b] = _parseRGB(this._doc.defaultView.getComputedStyle(dummy).color);
let luminance = 0.2125 * r + 0.7154 * g + 0.0721 * b;
root.setAttribute("lwthemetextcolor", luminance <= 110 ? "dark" : "bright");
root.setAttribute("lwtheme", "true");
} else {
root.removeAttribute("lwthemetextcolor");
root.removeAttribute("lwtheme");
}