From 4ccbe3620eb1cd354ce66f51730d7baf9b1a5f81 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sat, 22 Jul 2017 01:53:42 +0200 Subject: Add a signal preference for dynamic color changes to adjust "brighttext" in the front-end. This makes all relevant toolbars pick up the fact that the Windows accent color has changed and should check and if necessary update the "brighttext" property on them for styling of controls. This is a bit of a hack-around to the fact that there is no real easy way otherwise to notify the front-end of color changes without needing a change in focus of the window. There is a deliberate 300ms delay built in, because otherwise the styles might not have propagated yet, resulting in brighttext not being updated properly. --- browser/base/content/browser.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'browser/base') diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index d813a55cc..bbfef0049 100755 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -8075,6 +8075,7 @@ var ToolbarIconColor = { window.addEventListener("activate", this); window.addEventListener("deactivate", this); Services.obs.addObserver(this, "lightweight-theme-styling-update", false); + gPrefService.addObserver("ui.colorChanged", this, false); // If the window isn't active now, we assume that it has never been active // before and will soon become active such that inferFromText will be @@ -8089,6 +8090,7 @@ var ToolbarIconColor = { window.removeEventListener("activate", this); window.removeEventListener("deactivate", this); Services.obs.removeObserver(this, "lightweight-theme-styling-update"); + gPrefService.removeObserver("ui.colorChanged", this); }, handleEvent: function (event) { @@ -8107,6 +8109,18 @@ var ToolbarIconColor = { // lightweight-theme-styling-update observer. setTimeout(() => { this.inferFromText(); }, 0); break; + case "nsPref:changed": + // system color change + var colorChangedPref = false; + try { + colorChangedPref = gPrefService.getBoolPref("ui.colorChanged"); + } catch(e) { } + // if pref indicates change, call inferFromText() on a small delay + if (colorChangedPref == true) + setTimeout(() => { this.inferFromText(); }, 300); + break; + default: + console.error("ToolbarIconColor: Uncaught topic " + aTopic); } }, @@ -8140,6 +8154,9 @@ var ToolbarIconColor = { else toolbar.setAttribute("brighttext", "true"); } + + // Clear pref if set, since we're done applying the color changes. + gPrefService.clearUserPref("ui.colorChanged"); } } -- cgit v1.2.3 From 6f5c57ae74045228c2cbe4b797fe228f03274e6c Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sat, 22 Jul 2017 01:59:19 +0200 Subject: Align ToolbarIconColor luminance computation with UWP guideline as well to make it consistent with the rest of the browser. --- browser/base/content/browser.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'browser/base') diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index bbfef0049..a8aff1bd7 100755 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -8144,12 +8144,12 @@ var ToolbarIconColor = { let luminances = new Map; for (let toolbar of document.querySelectorAll(toolbarSelector)) { let [r, g, b] = parseRGB(getComputedStyle(toolbar).color); - let luminance = 0.2125 * r + 0.7154 * g + 0.0721 * b; + let luminance = (2 * r + 5 * g + b) / 8; luminances.set(toolbar, luminance); } for (let [toolbar, luminance] of luminances) { - if (luminance <= 110) + if (luminance <= 128) toolbar.removeAttribute("brighttext"); else toolbar.setAttribute("brighttext", "true"); -- cgit v1.2.3 From 1a418cf476709cc49a4b7dcf4aef64c5100ddaf9 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sun, 31 Dec 2017 13:45:14 +0100 Subject: Rename Options to Preferences and unify location. This also removes OS-specific naming/handling for separate locations. Fixes #270. --- browser/base/content/browser-menubar.inc | 11 ----------- browser/base/content/browser.js | 4 +--- browser/base/content/sync/customize.xul | 7 +------ browser/base/jar.mn | 2 +- 4 files changed, 3 insertions(+), 21 deletions(-) (limited to 'browser/base') diff --git a/browser/base/content/browser-menubar.inc b/browser/base/content/browser-menubar.inc index e952bc3ca..3fc098755 100644 --- a/browser/base/content/browser-menubar.inc +++ b/browser/base/content/browser-menubar.inc @@ -179,15 +179,6 @@ label="&bidiSwitchTextDirectionItem.label;" accesskey="&bidiSwitchTextDirectionItem.accesskey;" hidden="true"/> -#ifdef XP_UNIX -#ifndef XP_MACOSX - - -#endif -#endif @@ -521,13 +512,11 @@ -#ifndef XP_UNIX -#endif diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index a8aff1bd7..9ccd86b12 100755 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -473,9 +473,7 @@ var gPopupBlockerObserver = { var brandShortName = brandBundle.getString("brandShortName"); var popupCount = gBrowser.selectedBrowser.blockedPopups.length; - var stringKey = AppConstants.platform == "win" - ? "popupWarningButton" - : "popupWarningButtonUnix"; + var stringKey = "popupWarningButton"; var popupButtonText = gNavigatorBundle.getString(stringKey); var popupButtonAccesskey = gNavigatorBundle.getString(stringKey + ".accesskey"); diff --git a/browser/base/content/sync/customize.xul b/browser/base/content/sync/customize.xul index d95536d9a..827edf565 100644 --- a/browser/base/content/sync/customize.xul +++ b/browser/base/content/sync/customize.xul @@ -31,12 +31,7 @@