diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index 7458d028bb1d..018bb997930f 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -3643,6 +3643,14 @@ nsTextPaintStyle::InitSelectionColorsAndShadow() eCSSProperty_color; nscoord frameColor = mFrame->GetVisitedDependentColor(property); mSelectionTextColor = EnsureDifferentColors(frameColor, mSelectionBGColor); + } else if (mSelectionTextColor == NS_CHANGE_COLOR_IF_SAME_AS_BG) { + nsCSSProperty property = mFrame->IsSVGText() ? eCSSProperty_fill : + eCSSProperty_color; + nscolor frameColor = mFrame->GetVisitedDependentColor(property); + if (frameColor == mSelectionBGColor) { + mSelectionTextColor = + LookAndFeel::GetColor(LookAndFeel::eColorID_TextSelectForegroundCustom); + } } else { EnsureSufficientContrast(&mSelectionTextColor, &mSelectionBGColor); } diff --git a/widget/LookAndFeel.h b/widget/LookAndFeel.h index 823848b67260..41722561b3e6 100644 --- a/widget/LookAndFeel.h +++ b/widget/LookAndFeel.h @@ -39,6 +39,7 @@ public: eColorID_TextForeground, eColorID_TextSelectBackground, eColorID_TextSelectForeground, + eColorID_TextSelectForegroundCustom, eColorID_TextSelectBackgroundDisabled, eColorID_TextSelectBackgroundAttention, eColorID_TextHighlightBackground, @@ -588,6 +589,12 @@ public: // Of course if other plaforms work like the Mac, they can use it too. #define NS_DONT_CHANGE_COLOR NS_RGB(0x01, 0x01, 0x01) +// Similar with NS_DONT_CHANGE_COLOR, except NS_DONT_CHANGE_COLOR would returns +// complementary color if fg color is same as bg color. +// NS_CHANGE_COLOR_IF_SAME_AS_BG would returns eColorID_TextSelectForegroundCustom if +// fg and bg color are the same. +#define NS_CHANGE_COLOR_IF_SAME_AS_BG NS_RGB(0x02, 0x02, 0x02) + // --------------------------------------------------------------------- // Special colors for eColorID_IME* and eColorID_SpellCheckerUnderline // --------------------------------------------------------------------- diff --git a/widget/gonk/nsLookAndFeel.cpp b/widget/gonk/nsLookAndFeel.cpp index 6e503d6661c6..3aae4eae86e9 100644 --- a/widget/gonk/nsLookAndFeel.cpp +++ b/widget/gonk/nsLookAndFeel.cpp @@ -92,12 +92,19 @@ nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor) aColor = TEXT_NORMAL_COLOR; break; case eColorID_TextSelectBackground: + aColor = NS_RGBA(0x33,0xb5,0xe5,0x66); + break; case eColorID_IMESelectedRawTextBackground: case eColorID_IMESelectedConvertedTextBackground: // still used aColor = BASE_SELECTED_COLOR; break; + case eColorID_TextSelectForegroundCustom: + aColor = NS_RGB(0x4d,0x4d,0x4d); + break; case eColorID_TextSelectForeground: + aColor = NS_CHANGE_COLOR_IF_SAME_AS_BG; + break; case eColorID_IMESelectedRawTextForeground: case eColorID_IMESelectedConvertedTextForeground: // still used diff --git a/widget/xpwidgets/nsXPLookAndFeel.cpp b/widget/xpwidgets/nsXPLookAndFeel.cpp index c16133c5b7c3..c1f146feab44 100644 --- a/widget/xpwidgets/nsXPLookAndFeel.cpp +++ b/widget/xpwidgets/nsXPLookAndFeel.cpp @@ -151,6 +151,7 @@ const char nsXPLookAndFeel::sColorPrefs[][38] = "ui.textForeground", "ui.textSelectBackground", "ui.textSelectForeground", + "ui.textSelectForegroundCustom", "ui.textSelectBackgroundDisabled", "ui.textSelectBackgroundAttention", "ui.textHighlightBackground",