Bug 1044595 - fix default/active button text on OS X 10.10, r=mstange,jaws
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Fri, 12 Sep 2014 00:31:15 +0100
changeset 205322 3646cd944abe82efeaf2c44fef429e5a94263c38
parent 205235 bf5fcc0c4b27ee0f135e0e4e014740b7041a3bba
child 205323 54ca5ea4de1dacd96868be7cb520798193461bee
push id49139
push usercbook@mozilla.com
push dateMon, 15 Sep 2014 12:34:39 +0000
treeherdermozilla-inbound@ff1d0d059574 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange, jaws
bugs1044595
milestone35.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 1044595 - fix default/active button text on OS X 10.10, r=mstange,jaws
layout/style/nsCSSKeywordList.h
layout/style/nsCSSProps.cpp
toolkit/themes/osx/global/button.css
widget/LookAndFeel.h
widget/cocoa/nsLookAndFeel.mm
widget/tests/test_platform_colors.xul
widget/xpwidgets/nsXPLookAndFeel.cpp
--- a/layout/style/nsCSSKeywordList.h
+++ b/layout/style/nsCSSKeywordList.h
@@ -79,18 +79,20 @@ CSS_KEY(-moz-image-rect, _moz_image_rect
 CSS_KEY(-moz-info, _moz_info)
 CSS_KEY(-moz-inline-box, _moz_inline_box)
 CSS_KEY(-moz-inline-grid, _moz_inline_grid)
 CSS_KEY(-moz-inline-stack, _moz_inline_stack)
 CSS_KEY(-moz-isolate, _moz_isolate)
 CSS_KEY(-moz-isolate-override, _moz_isolate_override)
 CSS_KEY(-moz-left, _moz_left)
 CSS_KEY(-moz-list, _moz_list)
+CSS_KEY(-moz-mac-buttonactivetext, _moz_mac_buttonactivetext)
 CSS_KEY(-moz-mac-chrome-active, _moz_mac_chrome_active)
 CSS_KEY(-moz-mac-chrome-inactive, _moz_mac_chrome_inactive)
+CSS_KEY(-moz-mac-defaultbuttontext, _moz_mac_defaultbuttontext)
 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)
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -943,18 +943,20 @@ const KTableValue nsCSSProps::kColorKTab
   eCSSKeyword__moz_default_background_color, NS_COLOR_MOZ_DEFAULT_BACKGROUND_COLOR,
   eCSSKeyword__moz_default_color, NS_COLOR_MOZ_DEFAULT_COLOR,
   eCSSKeyword__moz_dialog, LookAndFeel::eColorID__moz_dialog,
   eCSSKeyword__moz_dialogtext, LookAndFeel::eColorID__moz_dialogtext,
   eCSSKeyword__moz_dragtargetzone, LookAndFeel::eColorID__moz_dragtargetzone,
   eCSSKeyword__moz_hyperlinktext, NS_COLOR_MOZ_HYPERLINKTEXT,
   eCSSKeyword__moz_html_cellhighlight, LookAndFeel::eColorID__moz_html_cellhighlight,
   eCSSKeyword__moz_html_cellhighlighttext, LookAndFeel::eColorID__moz_html_cellhighlighttext,
+  eCSSKeyword__moz_mac_buttonactivetext, LookAndFeel::eColorID__moz_mac_buttonactivetext,
   eCSSKeyword__moz_mac_chrome_active, LookAndFeel::eColorID__moz_mac_chrome_active,
   eCSSKeyword__moz_mac_chrome_inactive, LookAndFeel::eColorID__moz_mac_chrome_inactive,
+  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_menuhover, LookAndFeel::eColorID__moz_menuhover,
--- a/toolkit/themes/osx/global/button.css
+++ b/toolkit/themes/osx/global/button.css
@@ -9,16 +9,32 @@ button {
   /* The horizontal margin used here come from the Aqua Human Interface
      Guidelines, there should be 12 pixels between two buttons. */
   margin: 5px 6px 3px;
   min-width: 79px;
   color: ButtonText;
   text-shadow: none;
 }
 
+button:hover:active {
+  color: -moz-mac-buttonactivetext;
+}
+
+/* When the window isn't focused, the default button background isn't drawn,
+ * so don't change the text color then: */
+button[default="true"]:not(:-moz-window-inactive) {
+  color: -moz-mac-defaultbuttontext;
+}
+
+/* Likewise, when active (mousedown) but not hovering, the default button
+ * background isn't drawn, override the previous selector for that case: */
+button[default="true"]:not(:hover):active {
+  color: ButtonText;
+}
+
 .button-text {
   margin: 1px 0 !important;
   -moz-margin-start: 3px !important;
   -moz-margin-end: 2px !important;
   text-align: center;
 }
 
 .button-icon {
--- a/widget/LookAndFeel.h
+++ b/widget/LookAndFeel.h
@@ -121,20 +121,24 @@ public:
     eColorID__moz_menubarhovertext,
     // On platforms where these colors are the same as
     // -moz-field, use -moz-fieldtext as foreground color
     eColorID__moz_eventreerow,
     eColorID__moz_oddtreerow,
 
     // colors needed by the Mac OS X theme
 
+    // foreground color of :hover:active buttons
+    eColorID__moz_mac_buttonactivetext,
     // background color of chrome toolbars in active windows
     eColorID__moz_mac_chrome_active,
     // background color of chrome toolbars in inactive windows
     eColorID__moz_mac_chrome_inactive,
+    // foreground color of default buttons
+    eColorID__moz_mac_defaultbuttontext,
     //ring around text fields and lists
     eColorID__moz_mac_focusring,
     //colour used when mouse is over a menu item
     eColorID__moz_mac_menuselect,
     //colour used to do shadows on menu items
     eColorID__moz_mac_menushadow,
     // color used to display text for disabled menu items
     eColorID__moz_mac_menutextdisable,
--- a/widget/cocoa/nsLookAndFeel.mm
+++ b/widget/cocoa/nsLookAndFeel.mm
@@ -132,16 +132,23 @@ nsLookAndFeel::NativeGetColor(ColorID aI
       // It's really hard to effectively map these to the Appearance Manager properly,
       // since they are modeled word for word after the win32 system colors and don't have any 
       // real counterparts in the Mac world. I'm sure we'll be tweaking these for 
       // years to come. 
       //
       // Thanks to mpt26@student.canterbury.ac.nz for the hardcoded values that form the defaults
       //  if querying the Appearance Manager fails ;)
       //
+    case eColorID__moz_mac_buttonactivetext:
+    case eColorID__moz_mac_defaultbuttontext:
+      if (nsCocoaFeatures::OnYosemiteOrLater()) {
+        aColor = NS_RGB(0xFF,0xFF,0xFF);
+        break;
+      }
+      // Otherwise fall through and return the regular button text:
       
     case eColorID_buttontext:
     case eColorID__moz_buttonhovertext:
       aColor = GetColorFromNSColor([NSColor controlTextColor]);
       break;
     case eColorID_captiontext:
     case eColorID_menutext:
     case eColorID_infotext:
--- a/widget/tests/test_platform_colors.xul
+++ b/widget/tests/test_platform_colors.xul
@@ -61,18 +61,20 @@ var colors = {
   "-moz-field": ["rgb(255, 255, 255)"],
   "-moz-fieldtext": ["rgb(0, 0, 0)"],
   "-moz-dialog": ["rgb(232, 232, 232)"],
   "-moz-dialogtext": ["rgb(0, 0, 0)"],
   "-moz-dragtargetzone": ["rgb(199, 208, 218)", "rgb(198, 198, 198)", "rgb(180, 213, 255)", "rgb(250, 236, 115)", "rgb(255, 176, 139)", "rgb(255, 209, 129)", "rgb(194, 249, 144)", "rgb(232, 184, 255)"],
   "-moz-hyperlinktext": ["rgb(0, 0, 238)"],
   "-moz-html-cellhighlight": ["rgb(212, 212, 212)"],
   "-moz-html-cellhighlighttext": ["rgb(0, 0, 0)"],
+  "-moz-mac-buttonactivetext": ["rgb(0, 0, 0)", "rgb(255, 255, 255)"],
   "-moz-mac-chrome-active": ["rgb(150, 150, 150)", "rgb(167, 167, 167)", "rgb(178, 178, 178)"],
   "-moz-mac-chrome-inactive": ["rgb(202, 202, 202)", "rgb(216, 216, 216)", "rgb(225, 225, 225)"],
+  "-moz-mac-defaultbuttontext": ["rgb(0, 0, 0)", "rgb(255, 255, 255)"],
   //"-moz-mac-focusring": ["rgb(83, 144, 210)", "rgb(95, 112, 130)", "rgb(63, 152, 221)", "rgb(108, 126, 141)"],
   "-moz-mac-menuselect": ["rgb(115, 132, 153)", "rgb(127, 127, 127)", "rgb(56, 117, 215)", "rgb(255, 193, 31)", "rgb(243, 70, 72)", "rgb(255, 138, 34)", "rgb(102, 197, 71)", "rgb(140, 78, 184)"],
   "-moz-mac-menushadow": ["rgb(163, 163, 163)"],
   "-moz-mac-menutextdisable": ["rgb(152, 152, 152)"],
   "-moz-mac-menutextselect": ["rgb(255, 255, 255)"],
   "-moz-mac-disabledtoolbartext": ["rgb(127, 127, 127)"],
   "-moz-mac-secondaryhighlight": ["rgb(212, 212, 212)"],
   "-moz-menuhover": ["rgb(115, 132, 153)", "rgb(127, 127, 127)", "rgb(56, 117, 215)", "rgb(255, 193, 31)", "rgb(243, 70, 72)", "rgb(255, 138, 34)", "rgb(102, 197, 71)", "rgb(140, 78, 184)"],
--- a/widget/xpwidgets/nsXPLookAndFeel.cpp
+++ b/widget/xpwidgets/nsXPLookAndFeel.cpp
@@ -210,18 +210,20 @@ const char nsXPLookAndFeel::sColorPrefs[
   "ui.-moz-buttonhoverface",
   "ui.-moz_buttonhovertext",
   "ui.-moz_menuhover",
   "ui.-moz_menuhovertext",
   "ui.-moz_menubartext",
   "ui.-moz_menubarhovertext",
   "ui.-moz_eventreerow",
   "ui.-moz_oddtreerow",
+  "ui.-moz-mac-buttonactivetext",
   "ui.-moz_mac_chrome_active",
   "ui.-moz_mac_chrome_inactive",
+  "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-win-mediatext",