Bug 1531338 - [Linux/Gtk] Get and use Gtk theme text color for active/pressed button, r=dao,emilio, a=jcristau
authorMartin Stransky <stransky@redhat.com>
Fri, 24 May 2019 08:51:48 +0000
changeset 536798 1176df94118f3b4957e4f0851995e34bbb137774
parent 536797 33d0d344ea16b9219b36d922fe45549c29326e6a
child 536799 570065ea87fc4409718c9fd7f950863696fb8518
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdao, emilio, jcristau
bugs1531338
milestone68.0
Bug 1531338 - [Linux/Gtk] Get and use Gtk theme text color for active/pressed button, r=dao,emilio, a=jcristau - Follow Gtk and get theme button text color directly from "button" CSS node instead of "button label" - Provide new -moz-gtk-buttonactivetext color for active/pressed button text color - Replace ButtonText color with -moz-gtk-buttonactivetext when it's appropriate Differential Revision: https://phabricator.services.mozilla.com/D30566
browser/themes/linux/places/organizer.css
layout/style/res/forms.css
servo/components/style/properties/longhands/color.mako.rs
toolkit/themes/linux/global/button.css
widget/LookAndFeel.h
widget/gtk/nsLookAndFeel.cpp
widget/gtk/nsLookAndFeel.h
widget/nsXPLookAndFeel.cpp
--- a/browser/themes/linux/places/organizer.css
+++ b/browser/themes/linux/places/organizer.css
@@ -59,20 +59,23 @@
 }
 
 /* Menu */
 #placesMenu > menu {
   padding-inline-start: 4px;
   -moz-appearance: toolbarbutton;
 }
 
+#placesMenu > menu:hover {
+  color: ButtonText;
+}
+
 #placesMenu > menu:active,
-#placesMenu > menu:hover,
 #placesMenu > menu[open] {
-  color: ButtonText;
+  color: -moz-gtk-buttonactivetext;
 }
 
 #placesMenu > menu::after {
   content: "";
   display: -moz-box;
   -moz-appearance: toolbarbutton-dropdown;
   width: 12px;
   height: 12px;
--- a/layout/style/res/forms.css
+++ b/layout/style/res/forms.css
@@ -239,16 +239,24 @@ select {
   overflow: -moz-hidden-unscrollable;
   text-shadow: none;
   /* No text-decoration reaching inside, by default */
   display: inline-block;
   page-break-inside: avoid;
   overflow-clip-box: padding-box !important; /* bug 992447 */
 }
 
+%ifdef MOZ_WIDGET_GTK
+/* Comboboxes use button styles on Gtk so it's safe to
+ * use a button style here. */
+select:active:hover {
+  color: -moz-gtk-buttonactivetext;
+}
+%endif
+
 /* Need the "select[size][multiple]" selector to override the settings on
    'select[size="1"]', eg if one has <select size="1" multiple> */
 
 select[size],
 select[multiple],
 select[size][multiple] {
   /* Different alignment and padding for listbox vs combobox */
   background-color: -moz-Field;
@@ -691,19 +699,24 @@ input[type="submit"]:active:hover {
   border-style: inset;
   background-color: ButtonFace;
 }
 
 button:active:hover,
 input[type="reset"]:active:hover,
 input[type="button"]:active:hover,
 input[type="submit"]:active:hover {
+%ifdef MOZ_WIDGET_GTK
+  color: -moz-gtk-buttonactivetext;
+%else
   color: ButtonText;
+%endif
 }
 
+
 button::-moz-focus-inner,
 input[type="color"]::-moz-focus-inner,
 input[type="reset"]::-moz-focus-inner,
 input[type="button"]::-moz-focus-inner,
 input[type="submit"]::-moz-focus-inner {
   /* Note this padding only affects the -moz-focus-inner ring, not the button itself */
   padding-block-start: 0px;
   padding-inline-end: 2px;
--- a/servo/components/style/properties/longhands/color.mako.rs
+++ b/servo/components/style/properties/longhands/color.mako.rs
@@ -30,16 +30,17 @@ pub mod system_colors {
                            highlighttext inactiveborder inactivecaption inactivecaptiontext
                            infobackground infotext menu menutext scrollbar threeddarkshadow
                            threedface threedhighlight threedlightshadow threedshadow window
                            windowframe windowtext -moz-buttondefault -moz-buttonhoverface
                            -moz-buttonhovertext -moz-cellhighlight -moz-cellhighlighttext
                            -moz-eventreerow -moz-field -moz-fieldtext -moz-dialog -moz-dialogtext
                            -moz-dragtargetzone -moz-gtk-info-bar-text -moz-html-cellhighlight
                            -moz-html-cellhighlighttext -moz-mac-buttonactivetext
+                           -moz-gtk-buttonactivetext
                            -moz-mac-chrome-active -moz-mac-chrome-inactive
                            -moz-mac-defaultbuttontext -moz-mac-focusring -moz-mac-menuselect
                            -moz-mac-menushadow -moz-mac-menutextdisable -moz-mac-menutextselect
                            -moz-mac-disabledtoolbartext -moz-mac-secondaryhighlight
                            -moz-mac-vibrancy-light -moz-mac-vibrancy-dark
                            -moz-mac-vibrant-titlebar-light -moz-mac-vibrant-titlebar-dark
                            -moz-mac-menupopup
                            -moz-mac-menuitem -moz-mac-active-menuitem -moz-mac-source-list
--- a/toolkit/themes/linux/global/button.css
+++ b/toolkit/themes/linux/global/button.css
@@ -32,16 +32,22 @@ button {
 }
 
 /* .......... hover state .......... */
 
 button:hover:not(:-moz-any(:active,[disabled="true"],[open="true"],[checked="true"])) {
   color: -moz-buttonhovertext;
 }
 
+/* .......... active state .......... */
+
+button:not([disabled="true"]):-moz-any(:hover:active,[open="true"]) {
+  color: -moz-gtk-buttonactivetext;
+}
+
 /* .......... disabled state .......... */
 
 button[disabled="true"] {
   color: GrayText;
 }
 
 /* ::::: menu buttons ::::: */
 
--- a/widget/LookAndFeel.h
+++ b/widget/LookAndFeel.h
@@ -129,16 +129,21 @@ class LookAndFeel {
     eColorID__moz_menubartext,
     // used to menu bar item text, when mouse is over
     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 Linux Gtk theme
+
+    // used to button text, when button is pressed
+    eColorID__moz_gtk_buttonactivetext,
+
     // 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,
--- a/widget/gtk/nsLookAndFeel.cpp
+++ b/widget/gtk/nsLookAndFeel.cpp
@@ -424,16 +424,19 @@ nsresult nsLookAndFeel::NativeGetColor(C
       aColor = mButtonDefault;
       break;
     case eColorID__moz_buttonhoverface:
       aColor = mButtonHoverFace;
       break;
     case eColorID__moz_buttonhovertext:
       aColor = mButtonHoverText;
       break;
+    case eColorID__moz_gtk_buttonactivetext:
+      aColor = mButtonActiveText;
+      break;
     case eColorID__moz_menuhover:
       aColor = mMenuHover;
       break;
     case eColorID__moz_menuhovertext:
       aColor = mMenuHoverText;
       break;
     case eColorID__moz_oddtreerow:
       aColor = mOddCellBackground;
@@ -1000,31 +1003,32 @@ void nsLookAndFeel::EnsureInit() {
                                  GTK_STATE_FLAG_SELECTED),
       &color);
   mTextSelectedText = GDK_RGBA_TO_NS_RGBA(color);
 
   // Button text color
   style = GetStyleContext(MOZ_GTK_BUTTON);
   {
     GtkStyleContext* labelStyle = CreateStyleForWidget(labelWidget, style);
-
     GetSystemFontInfo(labelStyle, &mButtonFontName, &mButtonFontStyle);
-
-    gtk_style_context_get_border_color(style, GTK_STATE_FLAG_NORMAL, &color);
-    mButtonDefault = GDK_RGBA_TO_NS_RGBA(color);
-    gtk_style_context_get_color(labelStyle, GTK_STATE_FLAG_NORMAL, &color);
-    mButtonText = GDK_RGBA_TO_NS_RGBA(color);
-    gtk_style_context_get_color(labelStyle, GTK_STATE_FLAG_PRELIGHT, &color);
-    mButtonHoverText = GDK_RGBA_TO_NS_RGBA(color);
-    gtk_style_context_get_background_color(style, GTK_STATE_FLAG_PRELIGHT,
-                                           &color);
-    mButtonHoverFace = GDK_RGBA_TO_NS_RGBA(color);
     g_object_unref(labelStyle);
   }
 
+  gtk_style_context_get_border_color(style, GTK_STATE_FLAG_NORMAL, &color);
+  mButtonDefault = GDK_RGBA_TO_NS_RGBA(color);
+  gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
+  mButtonText = GDK_RGBA_TO_NS_RGBA(color);
+  gtk_style_context_get_color(style, GTK_STATE_FLAG_PRELIGHT, &color);
+  mButtonHoverText = GDK_RGBA_TO_NS_RGBA(color);
+  gtk_style_context_get_color(style, GTK_STATE_FLAG_ACTIVE, &color);
+  mButtonActiveText = GDK_RGBA_TO_NS_RGBA(color);
+  gtk_style_context_get_background_color(style, GTK_STATE_FLAG_PRELIGHT,
+                                         &color);
+  mButtonHoverFace = GDK_RGBA_TO_NS_RGBA(color);
+
   // Combobox text color
   style = GetStyleContext(MOZ_GTK_COMBOBOX_ENTRY_TEXTAREA);
   gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
   mComboBoxText = GDK_RGBA_TO_NS_RGBA(color);
 
   // Menubar text and hover text colors
   style = GetStyleContext(MOZ_GTK_MENUBARITEM);
   gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
--- a/widget/gtk/nsLookAndFeel.h
+++ b/widget/gtk/nsLookAndFeel.h
@@ -60,16 +60,17 @@ class nsLookAndFeel final : public nsXPL
   nscolor mMenuText = kBlack;
   nscolor mMenuTextInactive = kWhite;
   nscolor mMenuHover = kWhite;
   nscolor mMenuHoverText = kBlack;
   nscolor mButtonDefault = kWhite;
   nscolor mButtonText = kBlack;
   nscolor mButtonHoverText = kBlack;
   nscolor mButtonHoverFace = kWhite;
+  nscolor mButtonActiveText = kBlack;
   nscolor mFrameOuterLightBorder = kBlack;
   nscolor mFrameInnerDarkBorder = kBlack;
   nscolor mOddCellBackground = kWhite;
   nscolor mNativeHyperLinkText = kBlack;
   nscolor mComboBoxText = kBlack;
   nscolor mComboBoxBackground = kWhite;
   nscolor mMozFieldText = kBlack;
   nscolor mMozFieldBackground = kWhite;
--- a/widget/nsXPLookAndFeel.cpp
+++ b/widget/nsXPLookAndFeel.cpp
@@ -172,16 +172,17 @@ 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-gtk-buttonactivetext",
     "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",
@@ -641,16 +642,17 @@ nscolor nsXPLookAndFeel::GetStandinForNa
       break;
     case eColorID__moz_menubartext:
       result = NS_RGB(0x00, 0x00, 0x00);
       break;
     case eColorID__moz_menubarhovertext:
       result = NS_RGB(0x00, 0x00, 0x00);
       break;
     case eColorID__moz_oddtreerow:
+    case eColorID__moz_gtk_buttonactivetext:
       result = NS_RGB(0xFF, 0xFF, 0xFF);
       break;
     case eColorID__moz_mac_chrome_active:
       result = NS_RGB(0xB2, 0xB2, 0xB2);
       break;
     case eColorID__moz_mac_chrome_inactive:
       result = NS_RGB(0xE1, 0xE1, 0xE1);
       break;