Bug 1387594 - Add system colors for use in conjunction with -moz-font-smoothing-background-color and vibrant -moz-appearances. r=dbaron

MozReview-Commit-ID: IxXZwONxy41
This commit is contained in:
Markus Stange 2017-09-13 13:48:07 +02:00 коммит произвёл Emilio Cobos Álvarez
Родитель c0139d2740
Коммит 0704012f36
6 изменённых файлов: 84 добавлений и 4 удалений

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

@ -96,6 +96,10 @@ CSS_KEY(-moz-mac-menutextdisable, _moz_mac_menutextdisable)
CSS_KEY(-moz-mac-menutextselect, _moz_mac_menutextselect)
CSS_KEY(-moz-mac-disabledtoolbartext, _moz_mac_disabledtoolbartext)
CSS_KEY(-moz-mac-secondaryhighlight, _moz_mac_secondaryhighlight)
CSS_KEY(-moz-mac-menuitem, _moz_mac_menuitem)
CSS_KEY(-moz-mac-active-menuitem, _moz_mac_active_menuitem)
CSS_KEY(-moz-mac-menupopup, _moz_mac_menupopup)
CSS_KEY(-moz-mac-tooltip, _moz_mac_tooltip)
CSS_KEY(-moz-max-content, _moz_max_content)
CSS_KEY(-moz-menuhover, _moz_menuhover)
CSS_KEY(-moz-menuhovertext, _moz_menuhovertext)

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

@ -1129,6 +1129,15 @@ const KTableEntry nsCSSProps::kColorKTable[] = {
{ eCSSKeyword__moz_mac_menutextselect, LookAndFeel::eColorID__moz_mac_menutextselect },
{ eCSSKeyword__moz_mac_disabledtoolbartext, LookAndFeel::eColorID__moz_mac_disabledtoolbartext },
{ eCSSKeyword__moz_mac_secondaryhighlight, LookAndFeel::eColorID__moz_mac_secondaryhighlight },
{ eCSSKeyword__moz_mac_vibrancy_light, LookAndFeel::eColorID__moz_mac_vibrancy_light },
{ eCSSKeyword__moz_mac_vibrancy_dark, LookAndFeel::eColorID__moz_mac_vibrancy_dark },
{ eCSSKeyword__moz_mac_menuitem, LookAndFeel::eColorID__moz_mac_menuitem },
{ eCSSKeyword__moz_mac_active_menuitem, LookAndFeel::eColorID__moz_mac_active_menuitem },
{ eCSSKeyword__moz_mac_menupopup, LookAndFeel::eColorID__moz_mac_menupopup },
{ eCSSKeyword__moz_mac_source_list, LookAndFeel::eColorID__moz_mac_source_list },
{ eCSSKeyword__moz_mac_source_list_selection, LookAndFeel::eColorID__moz_mac_source_list_selection },
{ eCSSKeyword__moz_mac_active_source_list_selection, LookAndFeel::eColorID__moz_mac_active_source_list_selection },
{ eCSSKeyword__moz_mac_tooltip, LookAndFeel::eColorID__moz_mac_tooltip },
{ eCSSKeyword__moz_menuhover, LookAndFeel::eColorID__moz_menuhover },
{ eCSSKeyword__moz_menuhovertext, LookAndFeel::eColorID__moz_menuhovertext },
{ eCSSKeyword__moz_menubartext, LookAndFeel::eColorID__moz_menubartext },

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

@ -156,6 +156,18 @@ public:
//inactive light hightlight
eColorID__moz_mac_secondaryhighlight,
// Font smoothing background colors needed by the Mac OS X theme, based
// on -moz-appearance names
eColorID__moz_mac_vibrancy_light,
eColorID__moz_mac_vibrancy_dark,
eColorID__moz_mac_menupopup,
eColorID__moz_mac_menuitem,
eColorID__moz_mac_active_menuitem,
eColorID__moz_mac_source_list,
eColorID__moz_mac_source_list_selection,
eColorID__moz_mac_active_source_list_selection,
eColorID__moz_mac_tooltip,
// vista rebars
// accent color for title bar

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

@ -306,13 +306,41 @@ nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor)
// There appears to be no available system defined color. HARDCODING to the appropriate color.
aColor = NS_RGB(0x14,0x4F,0xAE);
break;
// The following colors are supposed to be used as font-smoothing background
// colors, in the chrome-only -moz-font-smoothing-background-color property.
// This property is used for text on "vibrant" -moz-appearances.
// The colors have been obtained from the system on 10.12.6 using the
// program at https://bugzilla.mozilla.org/attachment.cgi?id=8907533 .
// We could obtain them at runtime, but doing so may be expensive and
// requires the use of the private API
// -[NSVisualEffectView fontSmoothingBackgroundColor].
case eColorID__moz_mac_vibrancy_light:
case eColorID__moz_mac_source_list:
case eColorID__moz_mac_tooltip:
aColor = NS_RGB(0xf7,0xf7,0xf7);
break;
case eColorID__moz_mac_vibrancy_dark:
aColor = NS_RGB(0x28,0x28,0x28);
break;
case eColorID__moz_mac_menupopup:
case eColorID__moz_mac_menuitem:
aColor = NS_RGB(0xe6,0xe6,0xe6);
break;
case eColorID__moz_mac_source_list_selection:
aColor = NS_RGB(0xc8,0xc8,0xc8);
break;
case eColorID__moz_mac_active_menuitem:
case eColorID__moz_mac_active_source_list_selection:
aColor = [NSColor currentControlTint] == NSGraphiteControlTint
? NS_RGB(0xa0,0xa0,0xa0) : NS_RGB(0x0a,0x64,0xdc);
break;
default:
NS_WARNING("Someone asked nsILookAndFeel for a color I don't know about");
aColor = NS_RGB(0xff,0xff,0xff);
res = NS_ERROR_FAILURE;
break;
}
return res;
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;

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

@ -144,11 +144,11 @@ nsLookAndFeelFloatPref nsXPLookAndFeel::sFloatPrefs[] =
// This array MUST be kept in the same order as the color list in LookAndFeel.h.
/* XXX If you add any strings longer than
* "ui.IMESelectedConvertedTextBackground"
* "ui.-moz-mac-active-source-list-selection"
* to the following array then you MUST update the
* sizes of the sColorPrefs array in nsXPLookAndFeel.h
*/
const char nsXPLookAndFeel::sColorPrefs[][38] =
const char nsXPLookAndFeel::sColorPrefs[][41] =
{
"ui.windowBackground",
"ui.windowForeground",
@ -237,6 +237,15 @@ const char nsXPLookAndFeel::sColorPrefs[][38] =
"ui.-moz-mac-menutextselect",
"ui.-moz_mac_disabledtoolbartext",
"ui.-moz-mac-secondaryhighlight",
"ui.-moz-mac-vibrancy-light",
"ui.-moz-mac-vibrancy-dark",
"ui.-moz-mac-menupopup",
"ui.-moz-mac-menuitem",
"ui.-moz-mac-active-menuitem",
"ui.-moz-mac-source-list",
"ui.-moz-mac-source-list-selection",
"ui.-moz-mac-active-source-list-selection",
"ui.-moz-mac-tooltip",
"ui.-moz-win-mediatext",
"ui.-moz-win-communicationstext",
"ui.-moz-nativehyperlinktext",
@ -658,6 +667,24 @@ nsXPLookAndFeel::GetStandinForNativeColor(ColorID aID)
result = NS_RGB(0x3F, 0x3F, 0x3F); break;
case eColorID__moz_mac_secondaryhighlight:
result = NS_RGB(0xD4, 0xD4, 0xD4); break;
case eColorID__moz_mac_vibrancy_light:
result = NS_RGB(0xf7, 0xf7, 0xf7); break;
case eColorID__moz_mac_vibrancy_dark:
result = NS_RGB(0x28, 0x28, 0x28); break;
case eColorID__moz_mac_menupopup:
result = NS_RGB(0xe6, 0xe6, 0xe6); break;
case eColorID__moz_mac_menuitem:
result = NS_RGB(0xe6, 0xe6, 0xe6); break;
case eColorID__moz_mac_active_menuitem:
result = NS_RGB(0x0a, 0x64, 0xdc); break;
case eColorID__moz_mac_source_list:
result = NS_RGB(0xf7, 0xf7, 0xf7); break;
case eColorID__moz_mac_source_list_selection:
result = NS_RGB(0xc8, 0xc8, 0xc8); break;
case eColorID__moz_mac_active_source_list_selection:
result = NS_RGB(0x0a, 0x64, 0xdc); break;
case eColorID__moz_mac_tooltip:
result = NS_RGB(0xf7, 0xf7, 0xf7); break;
case eColorID__moz_win_accentcolor:
// Seems to be the default color (hardcoded because of bug 1065998)
result = NS_RGB(0x9E, 0x9E, 0x9E); break;

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

@ -108,7 +108,7 @@ protected:
/* this length must not be shorter than the length of the longest string in the array
* see nsXPLookAndFeel.cpp
*/
static const char sColorPrefs[][38];
static const char sColorPrefs[][41];
static int32_t sCachedColors[LookAndFeel::eColorID_LAST_COLOR];
static int32_t sCachedColorBits[COLOR_CACHE_SIZE];
static bool sUseNativeColors;