summaryrefslogtreecommitdiffstats
path: root/browser/base
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-02-17 17:12:28 +0100
committerwolfbeast <mcwerewolf@gmail.com>2018-02-17 17:12:28 +0100
commit050cfdc4cabb50df1a3f0005e967359dc800131e (patch)
tree72f882929fa06be8b77575894e5f8e991e3c76f1 /browser/base
parent1da0e8a095d82dd6b9ad0c0a45a7ee3b9d80ded7 (diff)
parent6f5c57ae74045228c2cbe4b797fe228f03274e6c (diff)
downloadUXP-050cfdc4cabb50df1a3f0005e967359dc800131e.tar
UXP-050cfdc4cabb50df1a3f0005e967359dc800131e.tar.gz
UXP-050cfdc4cabb50df1a3f0005e967359dc800131e.tar.lz
UXP-050cfdc4cabb50df1a3f0005e967359dc800131e.tar.xz
UXP-050cfdc4cabb50df1a3f0005e967359dc800131e.zip
Merge branch 'ported-moebius'
Diffstat (limited to 'browser/base')
-rwxr-xr-xbrowser/base/content/browser.js21
1 files changed, 19 insertions, 2 deletions
diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
index d813a55cc..a8aff1bd7 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);
}
},
@@ -8130,16 +8144,19 @@ 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");
}
+
+ // Clear pref if set, since we're done applying the color changes.
+ gPrefService.clearUserPref("ui.colorChanged");
}
}