cssnodedeclaration: Store the GType of the node

This commit is contained in:
Benjamin Otte 2014-12-21 20:26:26 +01:00
parent 9645daf48f
commit 26f36ef8ae
3 changed files with 40 additions and 2 deletions

View File

@ -32,6 +32,7 @@ struct _GtkRegion
struct _GtkCssNodeDeclaration {
guint refcount;
GtkJunctionSides junction_sides;
GType type;
GtkStateFlags state;
guint n_classes;
guint n_regions;
@ -160,6 +161,25 @@ gtk_css_node_declaration_get_junction_sides (const GtkCssNodeDeclaration *decl)
return decl->junction_sides;
}
gboolean
gtk_css_node_declaration_set_type (GtkCssNodeDeclaration **decl,
GType type)
{
if ((*decl)->type == type)
return FALSE;
gtk_css_node_declaration_make_writable (decl);
(*decl)->type = type;
return TRUE;
}
GType
gtk_css_node_declaration_get_type (const GtkCssNodeDeclaration *decl)
{
return decl->type;
}
gboolean
gtk_css_node_declaration_set_state (GtkCssNodeDeclaration **decl,
GtkStateFlags state)
@ -426,7 +446,7 @@ gtk_css_node_declaration_hash (gconstpointer elem)
GtkRegion *regions;
guint hash, i;
hash = 0;
hash = (guint) decl->type;
classes = get_classes (decl);
for (i = 0; i < decl->n_classes; i++)
@ -462,6 +482,9 @@ gtk_css_node_declaration_equal (gconstpointer elem1,
if (decl1 == decl2)
return TRUE;
if (decl1->type != decl2->type)
return FALSE;
if (decl1->state != decl2->state)
return FALSE;

View File

@ -33,6 +33,9 @@ void gtk_css_node_declaration_unref (GtkCssN
gboolean gtk_css_node_declaration_set_junction_sides (GtkCssNodeDeclaration **decl,
GtkJunctionSides junction_sides);
GtkJunctionSides gtk_css_node_declaration_get_junction_sides (const GtkCssNodeDeclaration *decl);
gboolean gtk_css_node_declaration_set_type (GtkCssNodeDeclaration **decl,
GType type);
GType gtk_css_node_declaration_get_type (const GtkCssNodeDeclaration *decl);
gboolean gtk_css_node_declaration_set_state (GtkCssNodeDeclaration **decl,
GtkStateFlags flags);
GtkStateFlags gtk_css_node_declaration_get_state (const GtkCssNodeDeclaration *decl);

View File

@ -881,6 +881,11 @@ _gtk_style_context_set_widget (GtkStyleContext *context,
context->priv->widget = widget;
if (widget)
gtk_css_node_declaration_set_type (&context->priv->info->decl, G_OBJECT_TYPE (widget));
else
gtk_css_node_declaration_set_type (&context->priv->info->decl, G_TYPE_NONE);
_gtk_style_context_update_animating (context);
_gtk_style_context_queue_invalidate (context, GTK_CSS_CHANGE_ANY_SELF);
@ -1373,10 +1378,17 @@ gtk_style_context_set_path (GtkStyleContext *context,
{
gtk_widget_path_free (priv->widget_path);
priv->widget_path = NULL;
gtk_css_node_declaration_set_type (&context->priv->info->decl, G_TYPE_NONE);
}
if (path)
priv->widget_path = gtk_widget_path_copy (path);
{
priv->widget_path = gtk_widget_path_copy (path);
if (gtk_widget_path_length (path))
gtk_css_node_declaration_set_type (&context->priv->info->decl,
gtk_widget_path_iter_get_object_type (path, -1));
}
_gtk_style_context_queue_invalidate (context, GTK_CSS_CHANGE_ANY);
}