Bug 1387594 - Add system colors for use in conjunction with -moz-font-smoothing-background-color and vibrant -moz-appearances. r=dbaron
authorMarkus Stange <mstange@themasta.com>
Wed, 13 Sep 2017 13:48:07 +0200
changeset 381051 b049c00f7a8f9310c4e9855a668c9d67fd9ebd49
parent 381050 cc52c89aeb32bab11a5c121828e8b5d72cc6d937
child 381052 3dcafbdc27cf956aaddf2a0997c8c2ac02829b28
push id95039
push userarchaeopteryx@coole-files.de
push dateFri, 15 Sep 2017 09:12:35 +0000
treeherdermozilla-inbound@c4a244ec50df [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1387594
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
layout/style/nsCSSKeywordList.h
layout/style/nsCSSProps.cpp
widget/LookAndFeel.h
widget/cocoa/nsLookAndFeel.mm
widget/nsXPLookAndFeel.cpp
widget/nsXPLookAndFeel.h
--- a/layout/style/nsCSSKeywordList.h
+++ b/layout/style/nsCSSKeywordList.h
@@ -91,16 +91,20 @@ CSS_KEY(-moz-mac-defaultbuttontext, _moz
 CSS_KEY(-moz-mac-focusring, _moz_mac_focusring)
 CSS_KEY(-moz-mac-fullscreen-button, _moz_mac_fullscreen_button)
 CSS_KEY(-moz-mac-menuselect, _moz_mac_menuselect)
 CSS_KEY(-moz-mac-menushadow, _moz_mac_menushadow)
 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)
 CSS_KEY(-moz-menubartext, _moz_menubartext)
 CSS_KEY(-moz-menubarhovertext, _moz_menubarhovertext)
 CSS_KEY(-moz-middle-with-baseline, _moz_middle_with_baseline)
 CSS_KEY(-moz-min-content, _moz_min_content)
 CSS_KEY(-moz-nativehyperlinktext, _moz_nativehyperlinktext)
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -1124,16 +1124,25 @@ const KTableEntry nsCSSProps::kColorKTab
   { eCSSKeyword__moz_mac_defaultbuttontext, LookAndFeel::eColorID__moz_mac_defaultbuttontext },
   { eCSSKeyword__moz_mac_focusring, LookAndFeel::eColorID__moz_mac_focusring },
   { eCSSKeyword__moz_mac_menuselect, LookAndFeel::eColorID__moz_mac_menuselect },
   { eCSSKeyword__moz_mac_menushadow, LookAndFeel::eColorID__moz_mac_menushadow },
   { eCSSKeyword__moz_mac_menutextdisable, LookAndFeel::eColorID__moz_mac_menutextdisable },
   { 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 },
   { eCSSKeyword__moz_menubarhovertext, LookAndFeel::eColorID__moz_menubarhovertext },
   { eCSSKeyword__moz_oddtreerow, LookAndFeel::eColorID__moz_oddtreerow },
   { eCSSKeyword__moz_visitedhyperlinktext, NS_COLOR_MOZ_VISITEDHYPERLINKTEXT },
   { eCSSKeyword_currentcolor, NS_COLOR_CURRENTCOLOR },
   { eCSSKeyword__moz_win_accentcolor, LookAndFeel::eColorID__moz_win_accentcolor },
--- a/widget/LookAndFeel.h
+++ b/widget/LookAndFeel.h
@@ -151,16 +151,28 @@ public:
     eColorID__moz_mac_menutextdisable,
     //colour used to display text while mouse is over a menu item
     eColorID__moz_mac_menutextselect,
     // text color of disabled text on toolbars
     eColorID__moz_mac_disabledtoolbartext,
     //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
     eColorID__moz_win_accentcolor,
     // color from drawing text over the accent color
     eColorID__moz_win_accentcolortext,
     // media rebar text
     eColorID__moz_win_mediatext,
--- a/widget/cocoa/nsLookAndFeel.mm
+++ b/widget/cocoa/nsLookAndFeel.mm
@@ -301,23 +301,51 @@ nsLookAndFeel::NativeGetColor(ColorID aI
     case eColorID__moz_oddtreerow:
       // Background color of odd list rows.
       aColor = GetColorFromNSColor([[NSColor controlAlternatingRowBackgroundColors] objectAtIndex:1]);
       break;
     case eColorID__moz_nativehyperlinktext:
       // 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;
 }
 
 nsresult
 nsLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult)
 {
--- a/widget/nsXPLookAndFeel.cpp
+++ b/widget/nsXPLookAndFeel.cpp
@@ -139,21 +139,21 @@ nsLookAndFeelFloatPref nsXPLookAndFeel::
   { "ui.caretAspectRatio",
     eFloatID_CaretAspectRatio,
     false, 0 },
 };
 
 
 // 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",
   "ui.widgetBackground",
   "ui.widgetForeground",
   "ui.widgetSelectBackground",
   "ui.widgetSelectForeground",
   "ui.widget3DHighlight",
@@ -232,16 +232,25 @@ const char nsXPLookAndFeel::sColorPrefs[
   "ui.-moz-mac-defaultbuttontext",
   "ui.-moz-mac-focusring",
   "ui.-moz-mac-menuselect",
   "ui.-moz-mac-menushadow",
   "ui.-moz-mac-menutextdisable",
   "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",
   "ui.-moz-comboboxtext",
   "ui.-moz-combobox"
 };
 
 int32_t nsXPLookAndFeel::sCachedColors[LookAndFeel::eColorID_LAST_COLOR] = {0};
@@ -653,16 +662,34 @@ nsXPLookAndFeel::GetStandinForNativeColo
     case eColorID__moz_mac_menutextdisable:
       result = NS_RGB(0x88, 0x88, 0x88); break;
     case eColorID__moz_mac_menutextselect:
       result = NS_RGB(0xFF, 0xFF, 0xFF); break;
     case eColorID__moz_mac_disabledtoolbartext:
       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;
     case eColorID__moz_win_accentcolortext:
       result = NS_RGB(0x00, 0x00, 0x00); break;
     case eColorID__moz_win_mediatext:
       result = NS_RGB(0xFF, 0xFF, 0xFF); break;
     case eColorID__moz_win_communicationstext:
--- a/widget/nsXPLookAndFeel.h
+++ b/widget/nsXPLookAndFeel.h
@@ -103,17 +103,17 @@ protected:
   static void OnPrefChanged(const char* aPref, void* aClosure);
 
   static bool sInitialized;
   static nsLookAndFeelIntPref sIntPrefs[];
   static nsLookAndFeelFloatPref sFloatPrefs[];
   /* 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;
   static bool sUseStandinsForNativeColors;
   static bool sFindbarModalHighlight;
 
   static nsXPLookAndFeel* sInstance;
   static bool sShutdown;