From bb862cf713cb15b6efad35f88ee50e90c14b5b0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 6 May 2021 09:57:19 +0000 Subject: [PATCH] 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 --- layout/generic/nsTextFrame.cpp | 13 ++++++------- widget/LookAndFeel.h | 8 +------- widget/cocoa/nsLookAndFeel.mm | 4 +--- widget/headless/HeadlessLookAndFeelGTK.cpp | 2 +- widget/nsXPLookAndFeel.cpp | 1 - widget/uikit/nsLookAndFeel.mm | 2 +- 6 files changed, 10 insertions(+), 20 deletions(-) diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index 02ab34beb3b0..8bd9c886333c 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -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; } diff --git a/widget/LookAndFeel.h b/widget/LookAndFeel.h index 7292b4b4410b..023c401bcc54 100644 --- a/widget/LookAndFeel.h +++ b/widget/LookAndFeel.h @@ -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 // --------------------------------------------------------------------- diff --git a/widget/cocoa/nsLookAndFeel.mm b/widget/cocoa/nsLookAndFeel.mm index 30b9c7c4e74d..8941a0e6c97d 100644 --- a/widget/cocoa/nsLookAndFeel.mm +++ b/widget/cocoa/nsLookAndFeel.mm @@ -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: diff --git a/widget/headless/HeadlessLookAndFeelGTK.cpp b/widget/headless/HeadlessLookAndFeelGTK.cpp index 2eb809bd96af..a6460668c925 100644 --- a/widget/headless/HeadlessLookAndFeelGTK.cpp +++ b/widget/headless/HeadlessLookAndFeelGTK.cpp @@ -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); diff --git a/widget/nsXPLookAndFeel.cpp b/widget/nsXPLookAndFeel.cpp index 1d26be973868..f2a2289889cd 100644 --- a/widget/nsXPLookAndFeel.cpp +++ b/widget/nsXPLookAndFeel.cpp @@ -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: diff --git a/widget/uikit/nsLookAndFeel.mm b/widget/uikit/nsLookAndFeel.mm index eb6575072224..122d43380dc5 100644 --- a/widget/uikit/nsLookAndFeel.mm +++ b/widget/uikit/nsLookAndFeel.mm @@ -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]);