Bug 426732 - implement -moz-nativelinktext, r=dbaron, sr=roc

This commit is contained in:
Ryan A. C. 2008-07-11 16:23:26 +02:00
parent 7283e91f7c
commit 8fa9043b87
9 changed files with 36 additions and 2 deletions

View File

@ -154,6 +154,7 @@ 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-myanmar, _moz_myanmar)
CSS_KEY(-moz-nativehyperlinktext, _moz_nativehyperlinktext)
CSS_KEY(-moz-none, _moz_none)
CSS_KEY(-moz-oddtreerow, _moz_oddtreerow)
CSS_KEY(-moz-oriya, _moz_oriya)

View File

@ -468,6 +468,7 @@ const PRInt32 nsCSSProps::kColorKTable[] = {
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_UNKNOWN,-1
};

View File

@ -792,7 +792,7 @@ var gCSSProperties = {
type: CSS_TYPE_LONGHAND,
/* XXX should test currentColor, but may or may not be initial */
initial_values: [ "black", "#000" ],
other_values: [ "green", "#f3c", "#fed292", "rgba(45,300,12,2)", "transparent" ],
other_values: [ "green", "#f3c", "#fed292", "rgba(45,300,12,2)", "transparent", "-moz-nativehyperlinktext", "rgba(255,128,0,0.5)" ],
invalid_values: [ "fff", "ffffff", "#f", "#ff", "#ffff", "#fffff", "#fffffff", "#ffffffff", "#fffffffff" ]
},
"content": {

View File

@ -165,6 +165,11 @@ public:
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,
// keep this one last, please
eColor_LAST_COLOR
} nsColorID;

View File

@ -350,6 +350,10 @@ nsresult nsLookAndFeel::NativeGetColor(const nsColorID aID, nscolor &aColor)
// Background color of odd list rows.
res = GetMacBrushColor(kThemeBrushListViewEvenRowBackground, aColor, NS_RGB(0xF0,0xF0,0xF0));
break;
case eColor__moz_nativehyperlinktext:
// There appears to be no available system defined color. HARDCODING to the appropriate color.
aColor = NS_RGB(0x14,0x4F,0xAE);
break;
default:
NS_WARNING("Someone asked nsILookAndFeel for a color I don't know about");
aColor = NS_RGB(0xff,0xff,0xff);

View File

@ -57,6 +57,7 @@ nscolor nsLookAndFeel::sButtonText = 0;
nscolor nsLookAndFeel::sButtonOuterLightBorder = 0;
nscolor nsLookAndFeel::sButtonInnerDarkBorder = 0;
nscolor nsLookAndFeel::sOddCellBackground = 0;
nscolor nsLookAndFeel::sNativeHyperLinkText = 0;
PRUnichar nsLookAndFeel::sInvisibleCharacter = PRUnichar('*');
float nsLookAndFeel::sCaretRatio = 0;
@ -305,6 +306,9 @@ nsresult nsLookAndFeel::NativeGetColor(const nsColorID aID, nscolor& aColor)
case eColor__moz_oddtreerow:
aColor = sOddCellBackground;
break;
case eColor__moz_nativehyperlinktext:
aColor = sNativeHyperLinkText;
break;
default:
/* default color is BLACK */
aColor = 0;
@ -674,19 +678,23 @@ nsLookAndFeel::InitLookAndFeel()
GtkWidget *label = 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(parent), button);
gtk_container_add(GTK_CONTAINER(parent), treeView);
gtk_container_add(GTK_CONTAINER(parent), linkButton);
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_realize(button);
gtk_widget_realize(label);
gtk_widget_realize(treeView);
gtk_widget_realize(linkButton);
style = gtk_widget_get_style(label);
if (style) {
@ -730,6 +738,16 @@ nsLookAndFeel::InitLookAndFeel()
GDK_COLOR_TO_NS_RGB(style->dark[GTK_STATE_NORMAL]);
}
colorValuePtr = NULL;
gtk_widget_style_get(linkButton, "link-color", &colorValuePtr, NULL);
if (colorValuePtr) {
colorValue = *colorValuePtr; //we can't pass deref pointers to GDK_COLOR_TO_NS_RGB
sNativeHyperLinkText = GDK_COLOR_TO_NS_RGB(colorValue);
gdk_color_free(colorValuePtr);
} else {
sNativeHyperLinkText = NS_RGB(0x00,0x00,0xEE);
}
gtk_widget_destroy(window);
// invisible character styles

View File

@ -72,6 +72,7 @@ protected:
static nscolor sButtonOuterLightBorder;
static nscolor sButtonInnerDarkBorder;
static nscolor sOddCellBackground;
static nscolor sNativeHyperLinkText;
static PRUnichar sInvisibleCharacter;
static float sCaretRatio;

View File

@ -398,6 +398,9 @@ nsresult nsLookAndFeel::NativeGetColor(const nsColorID aID, nscolor &aColor)
case eColor__moz_buttondefault:
idx = COLOR_3DDKSHADOW;
break;
case eColor__moz_nativehyperlinktext:
idx = COLOR_HOTLIGHT;
break;
default:
idx = COLOR_WINDOW;
break;

View File

@ -242,7 +242,8 @@ const char nsXPLookAndFeel::sColorPrefs[][38] =
"ui.-moz-mac-alternateprimaryhighlight",
"ui.-moz-mac-secondaryhighlight",
"ui.-moz-win-mediatext",
"ui.-moz-win-communicationstext"
"ui.-moz-win-communicationstext",
"ui.-moz-nativehyperlinktext"
};
PRInt32 nsXPLookAndFeel::sCachedColors[nsILookAndFeel::eColor_LAST_COLOR] = {0};