From 6d41085b0edb50e0b50abc16933fd81c30748584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 17 Nov 2021 01:24:20 +0000 Subject: [PATCH] Bug 1741499 - Cleanup a bit HeadlessLookAndFeelGTK too. r=spohl The colors that I didn't move to nsXPLookAndFeel are always set via prefs. Differential Revision: https://phabricator.services.mozilla.com/D131286 --- widget/headless/HeadlessLookAndFeel.h | 14 ++-- widget/headless/HeadlessLookAndFeelGTK.cpp | 81 ++-------------------- widget/nsXPLookAndFeel.cpp | 20 ++++++ 3 files changed, 29 insertions(+), 86 deletions(-) diff --git a/widget/headless/HeadlessLookAndFeel.h b/widget/headless/HeadlessLookAndFeel.h index 7f026edd671f..4e61b9e95d5f 100644 --- a/widget/headless/HeadlessLookAndFeel.h +++ b/widget/headless/HeadlessLookAndFeel.h @@ -35,16 +35,12 @@ class HeadlessLookAndFeel : public nsXPLookAndFeel { virtual ~HeadlessLookAndFeel(); void NativeInit() final{}; - virtual nsresult NativeGetInt(IntID aID, int32_t& aResult) override; - virtual nsresult NativeGetFloat(FloatID aID, float& aResult) override; - virtual nsresult NativeGetColor(ColorID, ColorScheme, - nscolor& aResult) override; - virtual bool NativeGetFont(FontID aID, nsString& aFontName, - gfxFontStyle& aFontStyle) override; + nsresult NativeGetInt(IntID, int32_t& aResult) override; + nsresult NativeGetFloat(FloatID, float& aResult) override; + nsresult NativeGetColor(ColorID, ColorScheme, nscolor& aResult) override; + bool NativeGetFont(FontID, nsString& aFontName, gfxFontStyle&) override; - virtual void RefreshImpl() override; - virtual char16_t GetPasswordCharacterImpl() override; - virtual bool GetEchoPasswordImpl() override; + char16_t GetPasswordCharacterImpl() override; }; #else diff --git a/widget/headless/HeadlessLookAndFeelGTK.cpp b/widget/headless/HeadlessLookAndFeelGTK.cpp index 0246850794bc..b9b69e44d4a0 100644 --- a/widget/headless/HeadlessLookAndFeelGTK.cpp +++ b/widget/headless/HeadlessLookAndFeelGTK.cpp @@ -12,83 +12,14 @@ namespace mozilla::widget { static const char16_t UNICODE_BULLET = 0x2022; -HeadlessLookAndFeel::HeadlessLookAndFeel() {} +HeadlessLookAndFeel::HeadlessLookAndFeel() = default; HeadlessLookAndFeel::~HeadlessLookAndFeel() = default; nsresult HeadlessLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme, - nscolor& aColor) { - // For headless mode, we use GetStandinForNativeColor for everything we can, - // and hardcoded values for everything else. - // - // TODO(emilio): We should probably just move these to - // GetStandinForNativeColor. - - nsresult res = NS_OK; - - switch (aID) { - // Override the solid black that GetStandinForNativeColor provides for - // FieldText, to match our behavior under the real GTK. - case ColorID::Fieldtext: - aColor = NS_RGB(0x21, 0x21, 0x21); - break; - - // The rest are not provided by GetStandinForNativeColor. - case ColorID::IMESelectedRawTextBackground: - case ColorID::IMESelectedConvertedTextBackground: - case ColorID::IMERawInputBackground: - case ColorID::IMEConvertedTextBackground: - aColor = NS_TRANSPARENT; - break; - case ColorID::IMESelectedRawTextForeground: - case ColorID::IMESelectedConvertedTextForeground: - case ColorID::IMERawInputForeground: - case ColorID::IMEConvertedTextForeground: - aColor = NS_SAME_AS_FOREGROUND_COLOR; - break; - case ColorID::IMERawInputUnderline: - case ColorID::IMEConvertedTextUnderline: - aColor = NS_40PERCENT_FOREGROUND_COLOR; - break; - case ColorID::IMESelectedRawTextUnderline: - case ColorID::IMESelectedConvertedTextUnderline: - aColor = NS_SAME_AS_FOREGROUND_COLOR; - break; - case ColorID::MozEventreerow: - aColor = NS_RGB(0xff, 0xff, 0xff); - break; - case ColorID::MozButtonactivetext: - case ColorID::MozMacDefaultbuttontext: - aColor = NS_RGB(0xff, 0xff, 0xff); - break; - case ColorID::SpellCheckerUnderline: - aColor = NS_RGB(0xff, 0x00, 0x00); - break; - case ColorID::TextHighlightBackground: - aColor = NS_RGB(0xef, 0x0f, 0xff); - break; - case ColorID::TextHighlightForeground: - aColor = NS_RGB(0xff, 0xff, 0xff); - break; - case ColorID::TextSelectDisabledBackground: - aColor = NS_RGB(0xaa, 0xaa, 0xaa); - break; - case ColorID::Highlight: - case ColorID::Selecteditem: - case ColorID::MozAccentColor: - aColor = NS_RGB(53, 132, 228); - break; - case ColorID::Highlighttext: - case ColorID::Selecteditemtext: - case ColorID::MozAccentColorForeground: - aColor = NS_RGB(0xff, 0xff, 0xff); - break; - default: - aColor = GetStandinForNativeColor(aID, aScheme); - break; - } - - return res; + nscolor& aResult) { + aResult = GetStandinForNativeColor(aID, aScheme); + return NS_OK; } nsresult HeadlessLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) { @@ -299,8 +230,4 @@ char16_t HeadlessLookAndFeel::GetPasswordCharacterImpl() { return UNICODE_BULLET; } -void HeadlessLookAndFeel::RefreshImpl() { nsXPLookAndFeel::RefreshImpl(); } - -bool HeadlessLookAndFeel::GetEchoPasswordImpl() { return false; } - } // namespace mozilla::widget diff --git a/widget/nsXPLookAndFeel.cpp b/widget/nsXPLookAndFeel.cpp index 2240c680727a..19f11b7f58ec 100644 --- a/widget/nsXPLookAndFeel.cpp +++ b/widget/nsXPLookAndFeel.cpp @@ -525,6 +525,25 @@ nscolor nsXPLookAndFeel::GetStandinForNativeColor(ColorID aID, return NS_RGBA(r, g, b, a); switch (aID) { + // These are here for the purposes of headless mode. + case ColorID::IMESelectedRawTextBackground: + case ColorID::IMESelectedConvertedTextBackground: + case ColorID::IMERawInputBackground: + case ColorID::IMEConvertedTextBackground: + return NS_TRANSPARENT; + case ColorID::IMESelectedRawTextForeground: + case ColorID::IMESelectedConvertedTextForeground: + case ColorID::IMERawInputForeground: + case ColorID::IMEConvertedTextForeground: + return NS_SAME_AS_FOREGROUND_COLOR; + case ColorID::IMERawInputUnderline: + case ColorID::IMEConvertedTextUnderline: + return NS_40PERCENT_FOREGROUND_COLOR; + COLOR(MozAccentColor, 53, 132, 228) + COLOR(MozAccentColorForeground, 0xff, 0xff, 0xff) + COLOR(SpellCheckerUnderline, 0xff, 0x00, 0x00) + COLOR(TextSelectDisabledBackground, 0xaa, 0xaa, 0xaa) + // CSS 2 colors: COLOR(Activeborder, 0xB4, 0xB4, 0xB4) COLOR(Activecaption, 0x99, 0xB4, 0xD1) @@ -584,6 +603,7 @@ nscolor nsXPLookAndFeel::GetStandinForNativeColor(ColorID aID, COLOR(MozMenuhovertext, 0x00, 0x00, 0x00) COLOR(MozMenubartext, 0x00, 0x00, 0x00) COLOR(MozMenubarhovertext, 0x00, 0x00, 0x00) + COLOR(MozEventreerow, 0xFF, 0xFF, 0xFF) COLOR(MozOddtreerow, 0xFF, 0xFF, 0xFF) COLOR(MozMacChromeActive, 0xB2, 0xB2, 0xB2) COLOR(MozMacChromeInactive, 0xE1, 0xE1, 0xE1)