Bug 537124 - "Some native color values are not initialized properly (ex: eColor__moz_fieldtext)" [r=Ventron sr=roc]

This commit is contained in:
romaxa 2009-12-31 04:29:00 -06:00
Родитель fe14f634f1
Коммит ac89a2ecc3
7 изменённых файлов: 45 добавлений и 9 удалений

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

@ -95,6 +95,8 @@ CSS_KEY(-moz-dialog, _moz_dialog)
CSS_KEY(-moz-dialogtext, _moz_dialogtext)
CSS_KEY(-moz-document, _moz_document)
CSS_KEY(-moz-dragtargetzone, _moz_dragtargetzone)
CSS_KEY(-moz-entry, _moz_entry)
CSS_KEY(-moz-entrytext, _moz_entrytext)
CSS_KEY(-moz-eventreerow, _moz_eventreerow)
CSS_KEY(-moz-ethiopic-halehame, _moz_ethiopic_halehame)
CSS_KEY(-moz-ethiopic-numeric, _moz_ethiopic_numeric)

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

@ -706,6 +706,8 @@ const PRInt32 nsCSSProps::kColorKTable[] = {
eCSSKeyword__moz_nativehyperlinktext, nsILookAndFeel::eColor__moz_nativehyperlinktext,
eCSSKeyword__moz_comboboxtext, nsILookAndFeel::eColor__moz_comboboxtext,
eCSSKeyword__moz_combobox, nsILookAndFeel::eColor__moz_combobox,
eCSSKeyword__moz_entrytext, nsILookAndFeel::eColor__moz_entrytext,
eCSSKeyword__moz_entry, nsILookAndFeel::eColor__moz_entry,
eCSSKeyword_UNKNOWN,-1
};

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

@ -56,8 +56,8 @@ textbox {
-moz-border-left-colors: ThreeDShadow ThreeDDarkShadow;
padding: 2px 2px 3px;
-moz-padding-start: 4px;
background-color: -moz-Field;
color: -moz-FieldText;
background-color: -moz-entry;
color: -moz-entryText;
}
textbox[isempty="true"] {

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

@ -172,6 +172,10 @@ public:
eColor__moz_comboboxtext,
eColor__moz_combobox,
// Entry text widgets
eColor__moz_entrytext,
eColor__moz_entry,
// keep this one last, please
eColor_LAST_COLOR
} nsColorID;

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

@ -70,6 +70,8 @@ nscolor nsLookAndFeel::sComboBoxText = 0;
nscolor nsLookAndFeel::sComboBoxBackground = 0;
PRUnichar nsLookAndFeel::sInvisibleCharacter = PRUnichar('*');
float nsLookAndFeel::sCaretRatio = 0;
nscolor nsLookAndFeel::sEntryText = 0;
nscolor nsLookAndFeel::sEntryBackground = 0;
//-------------------------------------------------------------------------
//
@ -334,6 +336,12 @@ nsresult nsLookAndFeel::NativeGetColor(const nsColorID aID, nscolor& aColor)
case eColor__moz_menubarhovertext:
aColor = sMenuBarHoverText;
break;
case eColor__moz_entrytext:
aColor = sEntryText;
break;
case eColor__moz_entry:
aColor = sEntryBackground;
break;
default:
/* default color is BLACK */
aColor = 0;
@ -747,6 +755,7 @@ nsLookAndFeel::InitLookAndFeel()
GtkWidget *treeView = gtk_tree_view_new();
GtkWidget *linkButton = gtk_link_button_new("http://example.com/");
GtkWidget *menuBar = gtk_menu_bar_new();
GtkWidget *entry = gtk_entry_new();
gtk_container_add(GTK_CONTAINER(button), label);
gtk_container_add(GTK_CONTAINER(combobox), comboboxLabel);
@ -755,6 +764,7 @@ nsLookAndFeel::InitLookAndFeel()
gtk_container_add(GTK_CONTAINER(parent), linkButton);
gtk_container_add(GTK_CONTAINER(parent), combobox);
gtk_container_add(GTK_CONTAINER(parent), menuBar);
gtk_container_add(GTK_CONTAINER(parent), entry);
gtk_container_add(GTK_CONTAINER(window), parent);
gtk_widget_set_style(button, NULL);
@ -764,6 +774,7 @@ nsLookAndFeel::InitLookAndFeel()
gtk_widget_set_style(combobox, NULL);
gtk_widget_set_style(comboboxLabel, NULL);
gtk_widget_set_style(menuBar, NULL);
gtk_widget_set_style(entry, NULL);
gtk_widget_realize(button);
gtk_widget_realize(label);
@ -772,6 +783,7 @@ nsLookAndFeel::InitLookAndFeel()
gtk_widget_realize(combobox);
gtk_widget_realize(comboboxLabel);
gtk_widget_realize(menuBar);
gtk_widget_realize(entry);
style = gtk_widget_get_style(label);
if (style) {
@ -793,6 +805,23 @@ nsLookAndFeel::InitLookAndFeel()
sMenuBarHoverText = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_SELECTED]);
}
style = gtk_widget_get_style(entry);
if (style) {
sEntryText = GDK_COLOR_TO_NS_RGB(style->text[GTK_STATE_NORMAL]);
GdkColor c;
if (gtk_style_lookup_color(style, "ReversedTextColor", &c)) {
if (sEntryText == GDK_COLOR_TO_NS_RGB(c)) {
if (gtk_style_lookup_color(style, "ReversedBackgroundColor", &c))
sEntryBackground = GDK_COLOR_TO_NS_RGB(c);
else
sEntryBackground = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]);
} else {
sEntryBackground = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_NORMAL]);
}
} else
sEntryBackground = 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
@ -840,11 +869,7 @@ nsLookAndFeel::InitLookAndFeel()
sNativeHyperLinkText = NS_RGB(0x00,0x00,0xEE);
}
gtk_widget_destroy(window);
// invisible character styles
GtkWidget *entry = gtk_entry_new();
g_object_ref_sink(entry);
guint value;
g_object_get (entry, "invisible-char", &value, NULL);
sInvisibleCharacter = PRUnichar(value);
@ -854,8 +879,7 @@ nsLookAndFeel::InitLookAndFeel()
"cursor-aspect-ratio", &sCaretRatio,
NULL);
gtk_widget_destroy(entry);
g_object_unref(entry);
gtk_widget_destroy(window);
}
// virtual

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

@ -78,6 +78,8 @@ protected:
static nscolor sComboBoxBackground;
static PRUnichar sInvisibleCharacter;
static float sCaretRatio;
static nscolor sEntryText;
static nscolor sEntryBackground;
static void InitLookAndFeel();
void InitWidget() {

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

@ -249,7 +249,9 @@ const char nsXPLookAndFeel::sColorPrefs[][38] =
"ui.-moz-win-communicationstext",
"ui.-moz-nativehyperlinktext",
"ui.-moz-comboboxtext",
"ui.-moz-combobox"
"ui.-moz-combobox",
"ui.-moz-entrytext",
"ui.-moz-entry"
};
PRInt32 nsXPLookAndFeel::sCachedColors[nsILookAndFeel::eColor_LAST_COLOR] = {0};