summaryrefslogtreecommitdiffstats
path: root/browser/base/content
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2017-07-22 01:53:42 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-02-17 16:31:25 +0100
commit4ccbe3620eb1cd354ce66f51730d7baf9b1a5f81 (patch)
tree29c816a66838cab9b9c452a0d20669355baac24c /browser/base/content
parentd6d1c2dad1079a09a131a94c87c78aca9aa0d1da (diff)
downloadUXP-4ccbe3620eb1cd354ce66f51730d7baf9b1a5f81.tar
UXP-4ccbe3620eb1cd354ce66f51730d7baf9b1a5f81.tar.gz
UXP-4ccbe3620eb1cd354ce66f51730d7baf9b1a5f81.tar.lz
UXP-4ccbe3620eb1cd354ce66f51730d7baf9b1a5f81.tar.xz
UXP-4ccbe3620eb1cd354ce66f51730d7baf9b1a5f81.zip
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.
Diffstat (limited to 'browser/base/content')
-rwxr-xr-xbrowser/base/content/browser.js17
1 files changed, 17 insertions, 0 deletions
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");
}
}