diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 6ec672373810..4bd2c6da6310 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -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"); diff --git a/widget/LookAndFeel.h b/widget/LookAndFeel.h index 120b5d64fd13..b71aed2e23d9 100644 --- a/widget/LookAndFeel.h +++ b/widget/LookAndFeel.h @@ -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;