mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1330876 - Listen to change event of preference "ui.use_standins_for_native_colors" and update default foreground and background colors r=heycam
MozReview-Commit-ID: BVFbGQVVNkf --HG-- extra : rebase_source : 77f9e3bc43524ef2271a9ad1e9f0f25dc9c57aed
This commit is contained in:
parent
cdcbcb9478
commit
0aaeee9340
@ -67,8 +67,6 @@ function beginTest() {
|
||||
[ "-moz-MenubarHoverText", 0x00, 0x00, 0x00 ],
|
||||
[ "-moz-NativeHyperlinkText", 0x00, 0x66, 0xCC ],
|
||||
[ "-moz-OddTreeRow", 0xFF, 0xFF, 0xFF ],
|
||||
[ "-moz-html-CellHighlight", 0x33, 0x99, 0xFF ],
|
||||
[ "-moz-html-CellHighlightText", 0xFF, 0xFF, 0xFF ],
|
||||
[ "-moz-mac-chrome-active", 0xB2, 0xB2, 0xB2 ],
|
||||
[ "-moz-mac-chrome-inactive", 0xE1, 0xE1, 0xE1 ],
|
||||
[ "-moz-mac-focusring", 0x60, 0x9D, 0xD7 ],
|
||||
@ -81,6 +79,8 @@ function beginTest() {
|
||||
[ "-moz-mac-SecondaryHighlight", 0xD4, 0xD4, 0xD4 ],
|
||||
[ "-moz-win-MediaText", 0xFF, 0xFF, 0xFF ],
|
||||
[ "-moz-win-CommunicationsText", 0xFF, 0xFF, 0xFF ],
|
||||
[ "-moz-html-CellHighlight", 0x33, 0x99, 0xFF ],
|
||||
[ "-moz-html-CellHighlightText", 0xFF, 0xFF, 0xFF ],
|
||||
|
||||
// These five are configured via Tools -> Options -> Content -> Colors.
|
||||
//"-moz-ActiveHyperlinkText",
|
||||
|
@ -100,6 +100,10 @@ using namespace mozilla::layers;
|
||||
|
||||
uint8_t gNotifySubDocInvalidationData;
|
||||
|
||||
// This preference was first introduced in Bug 232227, in order to prevent
|
||||
// system colors from being exposed to CSS or canvas.
|
||||
constexpr char kUseStandinsForNativeColors[] = "ui.use_standins_for_native_colors";
|
||||
|
||||
/**
|
||||
* Layer UserData for ContainerLayers that want to be notified
|
||||
* of local invalidations of them and their descendant layers.
|
||||
@ -381,6 +385,9 @@ nsPresContext::Destroy()
|
||||
Preferences::UnregisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"nglayout.debug.paint_flashing_chrome",
|
||||
this);
|
||||
Preferences::UnregisterCallback(nsPresContext::PrefChangedCallback,
|
||||
kUseStandinsForNativeColors,
|
||||
this);
|
||||
|
||||
mRefreshDriver = nullptr;
|
||||
}
|
||||
@ -468,11 +475,17 @@ nsPresContext::GetDocumentColorPreferences()
|
||||
bool isChromeDocShell = false;
|
||||
static int32_t sDocumentColorsSetting;
|
||||
static bool sDocumentColorsSettingPrefCached = false;
|
||||
static bool sUseStandinsForNativeColors = false;
|
||||
if (!sDocumentColorsSettingPrefCached) {
|
||||
sDocumentColorsSettingPrefCached = true;
|
||||
Preferences::AddIntVarCache(&sDocumentColorsSetting,
|
||||
"browser.display.document_color_use",
|
||||
0);
|
||||
|
||||
// The preference "ui.use_standins_for_native_colors" also affects
|
||||
// default foreground and background colors.
|
||||
Preferences::AddBoolVarCache(&sUseStandinsForNativeColors,
|
||||
kUseStandinsForNativeColors);
|
||||
}
|
||||
|
||||
nsIDocument* doc = mDocument->GetDisplayDocument();
|
||||
@ -501,7 +514,18 @@ nsPresContext::GetDocumentColorPreferences()
|
||||
!Preferences::GetBool("browser.display.use_system_colors", false);
|
||||
}
|
||||
|
||||
if (usePrefColors) {
|
||||
if (sUseStandinsForNativeColors) {
|
||||
// Once the preference "ui.use_standins_for_native_colors" is enabled,
|
||||
// use fixed color values instead of prefered colors and system colors.
|
||||
if (NS_FAILED(LookAndFeel::GetColor(
|
||||
LookAndFeel::eColorID_windowtext, true, &mDefaultColor))) {
|
||||
mDefaultColor = NS_RGB(0x00, 0x00, 0x00);
|
||||
}
|
||||
if (NS_FAILED(LookAndFeel::GetColor(
|
||||
LookAndFeel::eColorID_window, true, &mBackgroundColor))) {
|
||||
mBackgroundColor = NS_RGB(0xff, 0xff, 0xff);
|
||||
}
|
||||
} else if (usePrefColors) {
|
||||
nsAdoptingString colorStr =
|
||||
Preferences::GetString("browser.display.foreground_color");
|
||||
|
||||
@ -924,6 +948,9 @@ nsPresContext::Init(nsDeviceContext* aDeviceContext)
|
||||
Preferences::RegisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"nglayout.debug.paint_flashing_chrome",
|
||||
this);
|
||||
Preferences::RegisterCallback(nsPresContext::PrefChangedCallback,
|
||||
kUseStandinsForNativeColors,
|
||||
this);
|
||||
|
||||
nsresult rv = mEventManager->Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
Loading…
Reference in New Issue
Block a user