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:
@@ -136,7 +136,7 @@
|
||||
|
||||
#urlbar-input:not(:focus):-moz-lwtheme::selection,
|
||||
.searchbar-textbox:not(:focus-within):-moz-lwtheme::selection {
|
||||
background-color: var(--lwt-toolbar-field-highlight, text-select-background-disabled);
|
||||
background-color: var(--lwt-toolbar-field-highlight, text-select-disabled-background);
|
||||
}
|
||||
|
||||
#urlbar:not([focused="true"]) {
|
||||
|
||||
@@ -439,9 +439,9 @@ DeviceColor nsDisplaySelectionOverlay::ComputeColor() const {
|
||||
if (mSelectionValue == nsISelectionController::SELECTION_ON) {
|
||||
colorID = LookAndFeel::ColorID::Highlight;
|
||||
} else if (mSelectionValue == nsISelectionController::SELECTION_ATTENTION) {
|
||||
colorID = LookAndFeel::ColorID::TextSelectBackgroundAttention;
|
||||
colorID = LookAndFeel::ColorID::TextSelectAttentionBackground;
|
||||
} else {
|
||||
colorID = LookAndFeel::ColorID::TextSelectBackgroundDisabled;
|
||||
colorID = LookAndFeel::ColorID::TextSelectDisabledBackground;
|
||||
}
|
||||
|
||||
return ApplyTransparencyIfNecessary(
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -13,10 +13,9 @@ const NON_CONTENT_ACCESSIBLE_VALUES = {
|
||||
"-moz-colheaderhovertext",
|
||||
"-moz-colheadertext",
|
||||
"-moz-nativevisitedhyperlinktext",
|
||||
"text-select-foreground",
|
||||
"text-select-background",
|
||||
"text-select-background-disabled",
|
||||
"text-select-background-attention",
|
||||
"text-select-disabled-background",
|
||||
"text-select-attention-background",
|
||||
"text-select-attention-foreground",
|
||||
"-moz-autofill-background",
|
||||
],
|
||||
"display": [
|
||||
|
||||
@@ -702,11 +702,14 @@ pref("accessibility.browsewithcaret_shortcut.enabled", true);
|
||||
// These are some selection-related colors which have no per platform
|
||||
// implementation.
|
||||
#if !defined(XP_MACOSX)
|
||||
pref("ui.textSelectBackgroundDisabled", "#b0b0b0");
|
||||
pref("ui.textSelectDisabledBackground", "#b0b0b0");
|
||||
#endif
|
||||
|
||||
// This makes the selection stand out when typeaheadfind is on.
|
||||
// Used with nsISelectionController::SELECTION_ATTENTION
|
||||
pref("ui.textSelectBackgroundAttention", "#38d878");
|
||||
pref("ui.textSelectAttentionBackground", "#38d878");
|
||||
pref("ui.textSelectAttentionForeground", "#ffffff");
|
||||
|
||||
// This makes the matched text stand out when findbar highlighting is on.
|
||||
// Used with nsISelectionController::SELECTION_FIND
|
||||
pref("ui.textHighlightBackground", "#ef0fff");
|
||||
|
||||
@@ -216,9 +216,11 @@ pub enum Color {
|
||||
#[repr(u8)]
|
||||
pub enum SystemColor {
|
||||
#[parse(condition = "ParserContext::in_ua_or_chrome_sheet")]
|
||||
TextSelectBackgroundDisabled,
|
||||
#[parse(condition = "ParserContext::in_ua_or_chrome_sheet")]
|
||||
TextSelectBackgroundAttention,
|
||||
TextSelectDisabledBackground,
|
||||
#[css(skip)]
|
||||
TextSelectAttentionBackground,
|
||||
#[css(skip)]
|
||||
TextSelectAttentionForeground,
|
||||
#[css(skip)]
|
||||
TextHighlightBackground,
|
||||
#[css(skip)]
|
||||
|
||||
@@ -34,12 +34,12 @@ template <>
|
||||
struct ParamTraits<mozilla::LookAndFeel::ColorID>
|
||||
: ContiguousEnumSerializer<
|
||||
mozilla::LookAndFeel::ColorID,
|
||||
mozilla::LookAndFeel::ColorID::TextSelectBackgroundDisabled,
|
||||
mozilla::LookAndFeel::ColorID::TextSelectDisabledBackground,
|
||||
mozilla::LookAndFeel::ColorID::End> {
|
||||
using IdType = std::underlying_type_t<mozilla::LookAndFeel::ColorID>;
|
||||
static_assert(
|
||||
static_cast<IdType>(
|
||||
mozilla::LookAndFeel::ColorID::TextSelectBackgroundDisabled) ==
|
||||
mozilla::LookAndFeel::ColorID::TextSelectDisabledBackground) ==
|
||||
IdType(0));
|
||||
};
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme, nscolor
|
||||
break;
|
||||
// This is used to gray out the selection when it's not focused. Used with
|
||||
// nsISelectionController::SELECTION_DISABLED.
|
||||
case ColorID::TextSelectBackgroundDisabled:
|
||||
case ColorID::TextSelectDisabledBackground:
|
||||
color = ProcessSelectionBackground(GetColorFromNSColor(NSColor.secondarySelectedControlColor),
|
||||
aScheme);
|
||||
break;
|
||||
|
||||
@@ -70,10 +70,7 @@ nsresult HeadlessLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme,
|
||||
case ColorID::TextHighlightForeground:
|
||||
aColor = NS_RGB(0xff, 0xff, 0xff);
|
||||
break;
|
||||
case ColorID::TextSelectBackgroundAttention:
|
||||
aColor = NS_TRANSPARENT;
|
||||
break;
|
||||
case ColorID::TextSelectBackgroundDisabled:
|
||||
case ColorID::TextSelectDisabledBackground:
|
||||
aColor = NS_RGB(0xaa, 0xaa, 0xaa);
|
||||
break;
|
||||
case ColorID::Highlight:
|
||||
|
||||
@@ -199,8 +199,9 @@ static_assert(ArrayLength(sFloatPrefs) == size_t(LookAndFeel::FloatID::End),
|
||||
// This array MUST be kept in the same order as the color list in
|
||||
// specified/color.rs
|
||||
static const char sColorPrefs[][41] = {
|
||||
"ui.textSelectBackgroundDisabled",
|
||||
"ui.textSelectBackgroundAttention",
|
||||
"ui.textSelectDisabledBackground",
|
||||
"ui.textSelectAttentionBackground",
|
||||
"ui.textSelectAttentionForeground",
|
||||
"ui.textHighlightBackground",
|
||||
"ui.textHighlightForeground",
|
||||
"ui.IMERawInputBackground",
|
||||
@@ -1180,8 +1181,9 @@ static bool ColorIsCSSAccessible(LookAndFeel::ColorID aId) {
|
||||
using ColorID = LookAndFeel::ColorID;
|
||||
|
||||
switch (aId) {
|
||||
case ColorID::TextSelectBackgroundDisabled:
|
||||
case ColorID::TextSelectBackgroundAttention:
|
||||
case ColorID::TextSelectDisabledBackground:
|
||||
case ColorID::TextSelectAttentionBackground:
|
||||
case ColorID::TextSelectAttentionForeground:
|
||||
case ColorID::TextHighlightBackground:
|
||||
case ColorID::TextHighlightForeground:
|
||||
case ColorID::ThemedScrollbar:
|
||||
|
||||
Reference in New Issue
Block a user