Bug 1250704 - use same widget heirarchy as GTK for tooltip text color. r=stransky

MozReview-Commit-ID: 41sDYu3IqYq

--HG--
extra : rebase_source : 425a04503441f3edfd4ebbd71a21921013690426
This commit is contained in:
Karl Tomlinson 2016-06-07 18:06:04 +12:00
parent 7d57ffab85
commit 8c5debe5af
4 changed files with 42 additions and 1 deletions

View File

@ -163,6 +163,29 @@ GetWidget(WidgetNodeType aWidgetType)
return widget;
}
GtkStyleContext*
CreateStyleForWidget(GtkWidget* aWidget, GtkStyleContext* aParentStyle)
{
GtkWidgetPath* path =
gtk_widget_path_copy(gtk_style_context_get_path(aParentStyle));
// Work around https://bugzilla.gnome.org/show_bug.cgi?id=767312
// which exists in GTK+ 3.20.
gtk_widget_get_style_context(aWidget);
gtk_widget_path_append_for_widget(path, aWidget);
// Release any floating reference on aWidget.
g_object_ref_sink(aWidget);
g_object_unref(aWidget);
GtkStyleContext *context = gtk_style_context_new();
gtk_style_context_set_path(context, path);
gtk_style_context_set_parent(context, aParentStyle);
gtk_widget_path_unref(path);
return context;
}
GtkStyleContext*
CreateCSSNode(const char* aName, GtkStyleContext* aParentStyle, GType aType)
{

View File

@ -21,6 +21,13 @@ enum : StyleFlags {
GtkWidget*
GetWidget(WidgetNodeType aNodeType);
/*
* Return a new style context based on aWidget, as a child of aParentStyle.
* If aWidget still has a floating reference, then it is sunk and released.
*/
GtkStyleContext*
CreateStyleForWidget(GtkWidget* aWidget, GtkStyleContext* aParentStyle);
// CreateCSSNode is implemented for gtk >= 3.20 only.
GtkStyleContext*
CreateCSSNode(const char* aName,

View File

@ -518,6 +518,7 @@ STUB(gdk_event_get_source_device)
STUB(gdk_window_get_type)
STUB(gdk_x11_window_get_xid)
STUB(gdk_x11_display_get_type)
STUB(gtk_box_new)
STUB(gtk_cairo_should_draw_window)
STUB(gtk_cairo_transform_to_window)
STUB(gtk_combo_box_text_append)
@ -573,6 +574,7 @@ STUB(gtk_tree_view_column_get_button)
STUB(gtk_widget_get_preferred_size)
STUB(gtk_widget_get_state_flags)
STUB(gtk_widget_get_style_context)
STUB(gtk_widget_path_append_for_widget)
STUB(gtk_widget_path_append_type)
STUB(gtk_widget_path_copy)
STUB(gtk_widget_path_free)

View File

@ -1142,7 +1142,16 @@ nsLookAndFeel::Init()
style = ClaimStyleContext(MOZ_GTK_TOOLTIP);
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
sInfoBackground = GDK_RGBA_TO_NS_RGBA(color);
gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
{
GtkStyleContext* boxStyle =
CreateStyleForWidget(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0),
style);
GtkStyleContext* labelStyle =
CreateStyleForWidget(gtk_label_new(nullptr), boxStyle);
gtk_style_context_get_color(labelStyle, GTK_STATE_FLAG_NORMAL, &color);
g_object_unref(labelStyle);
g_object_unref(boxStyle);
}
sInfoText = GDK_RGBA_TO_NS_RGBA(color);
ReleaseStyleContext(style);