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
This commit is contained in:
Emilio Cobos Álvarez 2021-11-17 01:24:20 +00:00
parent 83d1e0047a
commit 6d41085b0e
3 changed files with 29 additions and 86 deletions

View File

@ -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

View File

@ -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

View File

@ -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)