Bug 1739925 - Add a foreground color to attention selection. r=jfkthame

In some platforms (like macOS, windows dark mode, android, and some gtk
themes) the foreground selection color might be `currentcolor`, and that
doesn't generally guarantee enough contrast with the attention
background.

Remove HeadlessLookAndFeelGTK's handling of this color since it's
useless (always overridden by prefs in all.js)

Differential Revision: https://phabricator.services.mozilla.com/D130617
This commit is contained in:
Emilio Cobos Álvarez
2021-11-11 11:14:13 +00:00
parent ea90691f9a
commit c98f60ad6a
10 changed files with 33 additions and 28 deletions

View File

@@ -4129,13 +4129,18 @@ bool nsTextPaintStyle::InitSelectionColorsAndShadow() {
return true;
}
mSelectionTextColor =
LookAndFeel::Color(LookAndFeel::ColorID::Highlighttext, mFrame);
nscolor selectionBGColor =
LookAndFeel::Color(LookAndFeel::ColorID::Highlight, mFrame);
switch (selectionStatus) {
case nsISelectionController::SELECTION_ATTENTION: {
mSelectionTextColor = LookAndFeel::Color(
LookAndFeel::ColorID::TextSelectAttentionForeground, mFrame);
mSelectionBGColor = LookAndFeel::Color(
LookAndFeel::ColorID::TextSelectBackgroundAttention, mFrame);
LookAndFeel::ColorID::TextSelectAttentionBackground, mFrame);
mSelectionBGColor =
EnsureDifferentColors(mSelectionBGColor, selectionBGColor);
break;
@@ -4146,16 +4151,13 @@ bool nsTextPaintStyle::InitSelectionColorsAndShadow() {
}
default: {
mSelectionBGColor = LookAndFeel::Color(
LookAndFeel::ColorID::TextSelectBackgroundDisabled, mFrame);
LookAndFeel::ColorID::TextSelectDisabledBackground, mFrame);
mSelectionBGColor =
EnsureDifferentColors(mSelectionBGColor, selectionBGColor);
break;
}
}
mSelectionTextColor =
LookAndFeel::Color(LookAndFeel::ColorID::Highlighttext, mFrame);
if (mResolveColors) {
EnsureSufficientContrast(&mSelectionTextColor, &mSelectionBGColor);
}