Bug 1709647 - Use NS_SAME_AS_FOREGROUND_COLOR instead of NS_DONT_CHANGE_COLOR. r=jfkthame

I don't think they are meaningfully different.

Depends on D114390

Differential Revision: https://phabricator.services.mozilla.com/D114391
This commit is contained in:
Emilio Cobos Álvarez 2021-05-06 09:57:19 +00:00
parent 366c9f5ece
commit bb862cf713
6 changed files with 10 additions and 20 deletions

View File

@ -441,7 +441,8 @@ class nsTextPaintStyle {
// Ensures sufficient contrast between the frame background color and the
// selection background color, and swaps the selection text and background
// colors accordingly.
// Only used on platforms where mSelectionTextColor != NS_DONT_CHANGE_COLOR
// Only used on platforms where mSelectionTextColor !=
// NS_SAME_AS_FOREGROUND_COLOR
bool EnsureSufficientContrast(nscolor* aForeColor, nscolor* aBackColor);
nscolor GetResolvedForeColor(nscolor aColor, nscolor aDefaultForeColor,
@ -3865,7 +3866,9 @@ bool nsTextPaintStyle::EnsureSufficientContrast(nscolor* aForeColor,
nscolor nsTextPaintStyle::GetTextColor() {
if (SVGUtils::IsInSVGTextSubtree(mFrame)) {
if (!mResolveColors) return NS_SAME_AS_FOREGROUND_COLOR;
if (!mResolveColors) {
return NS_SAME_AS_FOREGROUND_COLOR;
}
const nsStyleSVG* style = mFrame->StyleSVG();
switch (style->mFill.kind.tag) {
@ -4140,7 +4143,7 @@ bool nsTextPaintStyle::InitSelectionColorsAndShadow() {
if (mResolveColors) {
// On MacOS X, only the background color gets set,
// the text color remains intact.
if (mSelectionTextColor == NS_DONT_CHANGE_COLOR) {
if (mSelectionTextColor == NS_SAME_AS_FOREGROUND_COLOR) {
nscolor frameColor =
SVGUtils::IsInSVGTextSubtree(mFrame)
? mFrame->GetVisitedDependentColor(&nsStyleSVG::mFill)
@ -4151,10 +4154,6 @@ bool nsTextPaintStyle::InitSelectionColorsAndShadow() {
} else {
EnsureSufficientContrast(&mSelectionTextColor, &mSelectionBGColor);
}
} else {
if (mSelectionTextColor == NS_DONT_CHANGE_COLOR) {
mSelectionTextColor = NS_SAME_AS_FOREGROUND_COLOR;
}
}
return true;
}

View File

@ -440,7 +440,7 @@ class LookAndFeel {
// color id.
//
// NOTE:
// ColorID::TextSelectForeground might return NS_DONT_CHANGE_COLOR.
// ColorID::TextSelectForeground might return NS_SAME_AS_FOREGROUND_COLOR.
// ColorID::IME* might return NS_TRANSPARENT, NS_SAME_AS_FOREGROUND_COLOR or
// NS_40PERCENT_FOREGROUND_COLOR.
// These values have particular meaning. Then, they are not an actual
@ -558,12 +558,6 @@ class LookAndFeel {
} // namespace mozilla
// On the Mac, GetColor(ColorID::TextSelectForeground, color) returns this
// constant to specify that the foreground color should not be changed
// (ie. a colored text keeps its colors when selected).
// Of course if other plaforms work like the Mac, they can use it too.
#define NS_DONT_CHANGE_COLOR NS_RGB(0x01, 0x01, 0x01)
// ---------------------------------------------------------------------
// Special colors for ColorID::IME* and ColorID::SpellCheckerUnderline
// ---------------------------------------------------------------------

View File

@ -151,9 +151,6 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme, nscolor
case ColorID::MozMenuhover:
color = GetColorFromNSColor(NSColor.alternateSelectedControlColor);
break;
case ColorID::TextSelectForeground:
color = NS_DONT_CHANGE_COLOR;
break;
case ColorID::Highlighttext: // CSS2 color
case ColorID::MozAccentColorForeground:
case ColorID::MozMenuhovertext:
@ -169,6 +166,7 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme, nscolor
case ColorID::IMESelectedConvertedTextForeground:
case ColorID::IMERawInputForeground:
case ColorID::IMEConvertedTextForeground:
case ColorID::TextSelectForeground:
color = NS_SAME_AS_FOREGROUND_COLOR;
break;
case ColorID::IMERawInputUnderline:

View File

@ -86,7 +86,7 @@ nsresult HeadlessLookAndFeel::NativeGetColor(ColorID aID, ColorScheme,
aColor = NS_RGB(0xaa, 0xaa, 0xaa);
break;
case ColorID::TextSelectForeground:
aColor = NS_DONT_CHANGE_COLOR;
aColor = NS_SAME_AS_FOREGROUND_COLOR;
break;
case ColorID::Widget3DHighlight:
aColor = NS_RGB(0xa0, 0xa0, 0xa0);

View File

@ -464,7 +464,6 @@ static bool IsSpecialColor(LookAndFeel::ColorID aID, nscolor aColor) {
switch (aID) {
case ColorID::TextSelectForeground:
return aColor == NS_DONT_CHANGE_COLOR;
case ColorID::IMESelectedRawTextBackground:
case ColorID::IMESelectedConvertedTextBackground:
case ColorID::IMERawInputBackground:

View File

@ -404,7 +404,7 @@ void nsLookAndFeel::EnsureInit() {
if (color == 0x000000) {
mColorTextSelectForeground = NS_RGB(0xff, 0xff, 0xff);
} else {
mColorTextSelectForeground = NS_DONT_CHANGE_COLOR;
mColorTextSelectForeground = NS_SAME_AS_FOREGROUND_COLOR;
}
mColorDarkText = GetColorFromUIColor([UIColor darkTextColor]);