Bug 1024930 - Change text highlighting color. r=roc

This commit is contained in:
Morris Tseng 2014-07-23 23:58:00 +02:00
Родитель acc8f97031
Коммит 3193636cc1
4 изменённых файлов: 23 добавлений и 0 удалений

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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
// ---------------------------------------------------------------------

Просмотреть файл

@ -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

Просмотреть файл

@ -151,6 +151,7 @@ const char nsXPLookAndFeel::sColorPrefs[][38] =
"ui.textForeground",
"ui.textSelectBackground",
"ui.textSelectForeground",
"ui.textSelectForegroundCustom",
"ui.textSelectBackgroundDisabled",
"ui.textSelectBackgroundAttention",
"ui.textHighlightBackground",