Bug 1330876 - Add a new variant of LookAndFeel::GetColor that uses stand-ins for native colors and accepts default value. r=heycam

MozReview-Commit-ID: 40tmdTJbLy1

--HG--
extra : rebase_source : 391be7415abf32f77ee7371901fd0c7c3875b49e
This commit is contained in:
Chung-Sheng Fu 2017-06-12 13:57:17 +08:00
parent 0aaeee9340
commit 666911d06a
2 changed files with 16 additions and 8 deletions

View File

@ -517,14 +517,10 @@ nsPresContext::GetDocumentColorPreferences()
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);
}
mDefaultColor = LookAndFeel::GetColorUsingStandins(
LookAndFeel::eColorID_windowtext, NS_RGB(0x00, 0x00, 0x00));
mBackgroundColor = LookAndFeel::GetColorUsingStandins(
LookAndFeel::eColorID_window, NS_RGB(0xff, 0xff, 0xff));
} else if (usePrefColors) {
nsAdoptingString colorStr =
Preferences::GetString("browser.display.foreground_color");

View File

@ -537,6 +537,18 @@ public:
return result;
}
static nscolor GetColorUsingStandins(ColorID aID,
nscolor aDefault = NS_RGB(0, 0, 0))
{
nscolor result = NS_RGB(0, 0, 0);
if (NS_FAILED(GetColor(aID,
true, // aUseStandinsForNativeColors
&result))) {
return aDefault;
}
return result;
}
static int32_t GetInt(IntID aID, int32_t aDefault = 0)
{
int32_t result;