Bug 472772. Introduce a separate combobox-text color because some GTK themes need it. r+sr=roc
authorMichael Ventnor <ventnor.bugzilla@gmail.com>
Fri, 16 Jan 2009 21:18:49 +1300
changeset 23858 79e8e0d200194783a884c72b5e3d868d0604cc8b
parent 23857 55e7016fb7b2035fef419cbdd55b6659b9c7fb85
child 23859 9246fefef1cc661df9a0f9e41d64e61132bfafea
push id4759
push userrocallahan@mozilla.com
push dateSat, 17 Jan 2009 09:14:36 +0000
treeherdermozilla-central@7e0d34e958e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs472772
milestone1.9.2a1pre
Bug 472772. Introduce a separate combobox-text color because some GTK themes need it. r+sr=roc
layout/style/forms.css
layout/style/nsCSSKeywordList.h
layout/style/nsCSSProps.cpp
widget/public/nsILookAndFeel.h
widget/src/beos/nsLookAndFeel.cpp
widget/src/cocoa/nsLookAndFeel.mm
widget/src/gtk2/nsLookAndFeel.cpp
widget/src/gtk2/nsLookAndFeel.h
widget/src/os2/nsLookAndFeel.cpp
widget/src/qt/nsLookAndFeel.cpp
widget/src/windows/nsLookAndFeel.cpp
widget/src/xpwidgets/nsXPLookAndFeel.cpp
--- a/layout/style/forms.css
+++ b/layout/style/forms.css
@@ -150,18 +150,18 @@ input > .anonymous-div {
 input:-moz-read-write,
 textarea:-moz-read-write {
   -moz-user-modify: read-write !important;
 }
 
 select {
   margin: 0;
   border-color: ThreeDFace;
-  background-color: -moz-Field;
-  color: -moz-FieldText;
+  background-color: -moz-Combobox;
+  color: -moz-ComboboxText;
   font: -moz-list;
   line-height: normal !important;
   white-space: nowrap !important;
   word-wrap: normal !important;
   text-align: start; 
   cursor: default;
   -moz-box-sizing: border-box;
   -moz-user-select: none;
@@ -175,24 +175,28 @@ select {
 
 /* 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;
+  color: -moz-FieldText;
   vertical-align: text-bottom;
   padding: 1px 0 1px 0;
   -moz-appearance: listbox;
 }
 
 select[size="0"],
 select[size="1"] {
   /* Except this is not a listbox */
+  background-color: -moz-Combobox;
+  color: -moz-ComboboxText;
   vertical-align: baseline;
   padding: 0;
   -moz-appearance: menulist;
 }
 
 select > input[type="button"] {
   width: 12px;
   height: 12px;
--- a/layout/style/nsCSSKeywordList.h
+++ b/layout/style/nsCSSKeywordList.h
@@ -81,16 +81,18 @@ CSS_KEY(-moz-buttondefault, _moz_buttond
 CSS_KEY(-moz-buttonhoverface, _moz_buttonhoverface)
 CSS_KEY(-moz-buttonhovertext, _moz_buttonhovertext)
 CSS_KEY(-moz-cell, _moz_cell)
 CSS_KEY(-moz-cellhighlight, _moz_cellhighlight)
 CSS_KEY(-moz-cellhighlighttext, _moz_cellhighlighttext)
 CSS_KEY(-moz-center, _moz_center)
 CSS_KEY(-moz-cjk-earthly-branch, _moz_cjk_earthly_branch)
 CSS_KEY(-moz-cjk-heavenly-stem, _moz_cjk_heavenly_stem)
+CSS_KEY(-moz-combobox, _moz_combobox)
+CSS_KEY(-moz-comboboxtext, _moz_comboboxtext)
 CSS_KEY(-moz-compact, _moz_compact)  // Disabled because not supported.
 CSS_KEY(-moz-context-menu, _moz_context_menu)
 CSS_KEY(-moz-copy, _moz_copy)
 CSS_KEY(-moz-deck, _moz_deck)
 CSS_KEY(-moz-desktop, _moz_desktop)
 CSS_KEY(-moz-devanagari, _moz_devanagari)
 CSS_KEY(-moz-dialog, _moz_dialog)
 CSS_KEY(-moz-dialogtext, _moz_dialogtext)
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -659,16 +659,18 @@ const PRInt32 nsCSSProps::kColorKTable[]
   eCSSKeyword__moz_menuhovertext, nsILookAndFeel::eColor__moz_menuhovertext,
   eCSSKeyword__moz_menubarhovertext, nsILookAndFeel::eColor__moz_menubarhovertext,
   eCSSKeyword__moz_oddtreerow, nsILookAndFeel::eColor__moz_oddtreerow,
   eCSSKeyword__moz_visitedhyperlinktext, NS_COLOR_MOZ_VISITEDHYPERLINKTEXT,
   eCSSKeyword_currentcolor, NS_COLOR_CURRENTCOLOR,
   eCSSKeyword__moz_win_mediatext, nsILookAndFeel::eColor__moz_win_mediatext,
   eCSSKeyword__moz_win_communicationstext, nsILookAndFeel::eColor__moz_win_communicationstext,
   eCSSKeyword__moz_nativehyperlinktext, nsILookAndFeel::eColor__moz_nativehyperlinktext,
+  eCSSKeyword__moz_comboboxtext, nsILookAndFeel::eColor__moz_comboboxtext,
+  eCSSKeyword__moz_combobox, nsILookAndFeel::eColor__moz_combobox,
   eCSSKeyword_UNKNOWN,-1
 };
 
 const PRInt32 nsCSSProps::kContentKTable[] = {
   eCSSKeyword_open_quote, NS_STYLE_CONTENT_OPEN_QUOTE,
   eCSSKeyword_close_quote, NS_STYLE_CONTENT_CLOSE_QUOTE,
   eCSSKeyword_no_open_quote, NS_STYLE_CONTENT_NO_OPEN_QUOTE,
   eCSSKeyword_no_close_quote, NS_STYLE_CONTENT_NO_CLOSE_QUOTE,
--- a/widget/public/nsILookAndFeel.h
+++ b/widget/public/nsILookAndFeel.h
@@ -168,17 +168,21 @@ public:
 
     // vista rebars
     eColor__moz_win_mediatext,                     // media rebar text
     eColor__moz_win_communicationstext,            // communications rebar text
 
     // Hyperlink color extracted from the system, not affected by the browser.anchor_color user pref.
     // There is no OS-specified safe background color for this text, 
     // but it is used regularly within Windows and the Gnome DE on Dialog and Window colors.
-    eColor__moz_nativehyperlinktext,		
+    eColor__moz_nativehyperlinktext,
+
+    // Combo box widgets
+    eColor__moz_comboboxtext,
+    eColor__moz_combobox,
 
     // keep this one last, please
     eColor_LAST_COLOR
   } nsColorID;
 
   // When modifying this list, also modify nsXPLookAndFeel::sIntPrefs
   // in widget/src/xpwidgts/nsXPLookAndFeel.cpp.
   typedef enum {
--- a/widget/src/beos/nsLookAndFeel.cpp
+++ b/widget/src/beos/nsLookAndFeel.cpp
@@ -250,20 +250,22 @@ nsresult nsLookAndFeel::NativeGetColor(c
       aColor = NS_RGB(0xcc, 0xcc, 0xcc);
       break;
     case eColor_windowtext:
       aColor = NS_RGB(0x00, 0x00, 0x00);
       break;
     case eColor__moz_eventreerow:
     case eColor__moz_oddtreerow:
     case eColor__moz_field: 
+    case eColor__moz_combobox:
       // normal widget background
       aColor = NS_RGB(0xff, 0xff, 0xff);
       break;  
     case eColor__moz_fieldtext:
+    case eColor__moz_comboboxtext:
       aColor = NS_RGB(0x00, 0x00, 0x00);
       break;  
     case eColor__moz_dialog:
     case eColor__moz_cellhighlight:
       //all bars  including MenuBar
       aColor = NS_RGB(0xdd, 0xdd, 0xdd);
       break;  
     case eColor__moz_dialogtext:
--- a/widget/src/cocoa/nsLookAndFeel.mm
+++ b/widget/src/cocoa/nsLookAndFeel.mm
@@ -264,19 +264,21 @@ nsresult nsLookAndFeel::NativeGetColor(c
       //no way to fetch this colour. HARDCODING to Platinum
       //res = GetMacBrushColor(??, aColor, NS_RGB(0xCC,0xCC,0xCC));
       aColor = NS_RGB(0xCC,0xCC,0xCC);
       break;
     case eColor_window:
       res = GetMacBrushColor(kThemeBrushDocumentWindowBackground, aColor, NS_RGB(0xFF,0xFF,0xFF));        
       break;
     case eColor__moz_field:
+    case eColor__moz_combobox:
       aColor = NS_RGB(0xff,0xff,0xff);
       break;
     case eColor__moz_fieldtext:
+    case eColor__moz_comboboxtext:
       // XXX There may be a better color for this, but I'm making it
       // the same as WindowText since that's what's currently used where
       // I will use -moz-FieldText.
       res = GetMacTextColor(kThemeTextColorDialogActive, aColor, NS_RGB(0x00,0x00,0x00));
       break;
     case eColor__moz_dialog:
       // XXX There may be a better color for this, but I'm making it
       // the same as ThreeDFace since that's what's currently used where
--- a/widget/src/gtk2/nsLookAndFeel.cpp
+++ b/widget/src/gtk2/nsLookAndFeel.cpp
@@ -53,16 +53,18 @@ nscolor   nsLookAndFeel::sMenuHover = 0;
 nscolor   nsLookAndFeel::sMenuHoverText = 0;
 nscolor   nsLookAndFeel::sMenuBackground = 0;
 nscolor   nsLookAndFeel::sButtonBackground = 0;
 nscolor   nsLookAndFeel::sButtonText = 0;
 nscolor   nsLookAndFeel::sButtonOuterLightBorder = 0;
 nscolor   nsLookAndFeel::sButtonInnerDarkBorder = 0;
 nscolor   nsLookAndFeel::sOddCellBackground = 0;
 nscolor   nsLookAndFeel::sNativeHyperLinkText = 0;
+nscolor   nsLookAndFeel::sComboBoxText = 0;
+nscolor   nsLookAndFeel::sComboBoxBackground = 0;
 PRUnichar nsLookAndFeel::sInvisibleCharacter = PRUnichar('*');
 float     nsLookAndFeel::sCaretRatio = 0;
 
 //-------------------------------------------------------------------------
 //
 // Query interface implementation
 //
 //-------------------------------------------------------------------------
@@ -304,16 +306,22 @@ nsresult nsLookAndFeel::NativeGetColor(c
         aColor = sMenuHoverText;
         break;
     case eColor__moz_oddtreerow:
         aColor = sOddCellBackground;
         break;
     case eColor__moz_nativehyperlinktext:
         aColor = sNativeHyperLinkText;
         break;
+    case eColor__moz_comboboxtext:
+        aColor = sComboBoxText;
+        break;
+    case eColor__moz_combobox:
+        aColor = sComboBoxBackground;
+        break;
     default:
         /* default color is BLACK */
         aColor = 0;
         res    = NS_ERROR_FAILURE;
         break;
     }
 
     return res;
@@ -677,41 +685,58 @@ nsLookAndFeel::InitLookAndFeel()
 
     gtk_widget_unref(menu);
 
 
     // button styles
     GtkWidget *parent = gtk_fixed_new();
     GtkWidget *button = gtk_button_new();
     GtkWidget *label = gtk_label_new("M");
+    GtkWidget *combobox = gtk_combo_box_new();
+    GtkWidget *comboboxLabel = gtk_label_new("M");
     GtkWidget *window = gtk_window_new(GTK_WINDOW_POPUP);
     GtkWidget *treeView = gtk_tree_view_new();
     GtkWidget *linkButton = gtk_link_button_new("http://example.com/");
 
     gtk_container_add(GTK_CONTAINER(button), label);
+    gtk_container_add(GTK_CONTAINER(combobox), comboboxLabel);
     gtk_container_add(GTK_CONTAINER(parent), button);
     gtk_container_add(GTK_CONTAINER(parent), treeView);
     gtk_container_add(GTK_CONTAINER(parent), linkButton);
+    gtk_container_add(GTK_CONTAINER(parent), combobox);
     gtk_container_add(GTK_CONTAINER(window), parent);
 
     gtk_widget_set_rc_style(button);
     gtk_widget_set_rc_style(label);
     gtk_widget_set_rc_style(treeView);
     gtk_widget_set_rc_style(linkButton);
+    gtk_widget_set_rc_style(combobox);
+    gtk_widget_set_rc_style(comboboxLabel);
 
     gtk_widget_realize(button);
     gtk_widget_realize(label);
     gtk_widget_realize(treeView);
     gtk_widget_realize(linkButton);
+    gtk_widget_realize(combobox);
+    gtk_widget_realize(comboboxLabel);
 
     style = gtk_widget_get_style(label);
     if (style) {
         sButtonText = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]);
     }
 
+    style = gtk_widget_get_style(comboboxLabel);
+    if (style) {
+        sComboBoxText = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]);
+    }
+    style = gtk_widget_get_style(combobox);
+    if (style) {
+        sComboBoxBackground = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_NORMAL]);
+    }
+
     // GTK's guide to fancy odd row background colors:
     // 1) Check if a theme explicitly defines an odd row color
     // 2) If not, check if it defines an even row color, and darken it
     //    slightly by a hardcoded value (gtkstyle.c)
     // 3) If neither are defined, take the base background color and
     //    darken that by a hardcoded value
     GdkColor colorValue;
     GdkColor *colorValuePtr = NULL;
--- a/widget/src/gtk2/nsLookAndFeel.h
+++ b/widget/src/gtk2/nsLookAndFeel.h
@@ -68,16 +68,18 @@ protected:
     static nscolor sMenuHover;
     static nscolor sMenuHoverText;
     static nscolor sButtonBackground;
     static nscolor sButtonText;
     static nscolor sButtonOuterLightBorder;
     static nscolor sButtonInnerDarkBorder;
     static nscolor sOddCellBackground;
     static nscolor sNativeHyperLinkText;
+    static nscolor sComboBoxText;
+    static nscolor sComboBoxBackground;
     static PRUnichar sInvisibleCharacter;
     static float   sCaretRatio;
 
     static void InitLookAndFeel();
     void InitWidget() {
         mWidget = gtk_invisible_new();
         gtk_object_ref(GTK_OBJECT(mWidget));
         gtk_object_sink(GTK_OBJECT(mWidget));
--- a/widget/src/os2/nsLookAndFeel.cpp
+++ b/widget/src/os2/nsLookAndFeel.cpp
@@ -202,19 +202,21 @@ nsresult nsLookAndFeel::NativeGetColor(c
       idx = SYSCLR_WINDOWFRAME;
       break;
     case eColor_windowtext:
       idx = SYSCLR_WINDOWTEXT;
       break;
     case eColor__moz_eventreerow:
     case eColor__moz_oddtreerow:
     case eColor__moz_field:
+    case eColor__moz_combobox:
       idx = SYSCLR_ENTRYFIELD;
       break;
     case eColor__moz_fieldtext:
+    case eColor__moz_comboboxtext:
       idx = SYSCLR_WINDOWTEXT;
       break;
     case eColor__moz_dialog:
     case eColor__moz_cellhighlight:
       idx = SYSCLR_DIALOGBACKGROUND;
       break;
     case eColor__moz_dialogtext:
     case eColor__moz_cellhighlighttext:
--- a/widget/src/qt/nsLookAndFeel.cpp
+++ b/widget/src/qt/nsLookAndFeel.cpp
@@ -253,20 +253,22 @@ nsresult nsLookAndFeel::NativeGetColor(c
      // from the CSS3 working draft (not yet finalized)
      // http://www.w3.org/tr/2000/wd-css3-userint-20000216.html#color
 
     case eColor__moz_buttondefault:
       aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Button));
       break;
 
     case eColor__moz_field:
+    case eColor__moz_combobox:
       aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Base));
       break;
 
     case eColor__moz_fieldtext:
+    case eColor__moz_comboboxtext:
       aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Text));
       break;
 
     case eColor__moz_dialog:
       aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window));
       break;
 
     case eColor__moz_dialogtext:
--- a/widget/src/windows/nsLookAndFeel.cpp
+++ b/widget/src/windows/nsLookAndFeel.cpp
@@ -273,19 +273,21 @@ nsresult nsLookAndFeel::NativeGetColor(c
       idx = COLOR_WINDOWFRAME;
       break;
     case eColor_windowtext:
       idx = COLOR_WINDOWTEXT;
       break;
     case eColor__moz_eventreerow:
     case eColor__moz_oddtreerow:
     case eColor__moz_field:
+    case eColor__moz_combobox:
       idx = COLOR_WINDOW;
       break;
     case eColor__moz_fieldtext:
+    case eColor__moz_comboboxtext:
       idx = COLOR_WINDOWTEXT;
       break;
     case eColor__moz_dialog:
     case eColor__moz_cellhighlight:
       idx = COLOR_3DFACE;
       break;
     case eColor__moz_win_mediatext:
 #ifndef WINCE
--- a/widget/src/xpwidgets/nsXPLookAndFeel.cpp
+++ b/widget/src/xpwidgets/nsXPLookAndFeel.cpp
@@ -240,17 +240,19 @@ const char nsXPLookAndFeel::sColorPrefs[
   "ui.-moz-mac-accentlightshadow",
   "ui.-moz-mac-accentregularshadow",
   "ui.-moz-mac-accentdarkshadow",
   "ui.-moz-mac-accentdarkestshadow",
   "ui.-moz-mac-alternateprimaryhighlight",
   "ui.-moz-mac-secondaryhighlight",
   "ui.-moz-win-mediatext",
   "ui.-moz-win-communicationstext",
-  "ui.-moz-nativehyperlinktext"
+  "ui.-moz-nativehyperlinktext",
+  "ui.-moz-comboboxtext",
+  "ui.-moz-combobox"
 };
 
 PRInt32 nsXPLookAndFeel::sCachedColors[nsILookAndFeel::eColor_LAST_COLOR] = {0};
 PRInt32 nsXPLookAndFeel::sCachedColorBits[COLOR_CACHE_SIZE] = {0};
 
 PRBool nsXPLookAndFeel::sInitialized = PR_FALSE;
 
 nsXPLookAndFeel::nsXPLookAndFeel() : nsILookAndFeel()