From dbb8d1dd07a91171ba4a32119713c05e0483de91 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 20 Jan 2015 00:33:34 +0100 Subject: stylecontext: Keep track of the CSS ID This is necessary since we do the new caching and need to distinguish between styles with different IDs. Fixes various test cases. --- gtk/gtkcssnodedeclaration.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'gtk/gtkcssnodedeclaration.c') diff --git a/gtk/gtkcssnodedeclaration.c b/gtk/gtkcssnodedeclaration.c index e5c718708a..989ad94fd4 100644 --- a/gtk/gtkcssnodedeclaration.c +++ b/gtk/gtkcssnodedeclaration.c @@ -33,6 +33,7 @@ struct _GtkCssNodeDeclaration { guint refcount; GtkJunctionSides junction_sides; GType type; + const /* interened */ char *id; GtkStateFlags state; guint n_classes; guint n_regions; @@ -180,6 +181,27 @@ gtk_css_node_declaration_get_type (const GtkCssNodeDeclaration *decl) return decl->type; } +gboolean +gtk_css_node_declaration_set_id (GtkCssNodeDeclaration **decl, + const char *id) +{ + id = g_intern_string (id); + + if ((*decl)->id == id) + return FALSE; + + gtk_css_node_declaration_make_writable (decl); + (*decl)->id = id; + + return TRUE; +} + +const char * +gtk_css_node_declaration_get_id (const GtkCssNodeDeclaration *decl) +{ + return decl->id; +} + gboolean gtk_css_node_declaration_set_state (GtkCssNodeDeclaration **decl, GtkStateFlags state) @@ -447,6 +469,8 @@ gtk_css_node_declaration_hash (gconstpointer elem) guint hash, i; hash = (guint) decl->type; + hash <<= 5; + hash ^= GPOINTER_TO_UINT (decl->id); classes = get_classes (decl); for (i = 0; i < decl->n_classes; i++) @@ -488,6 +512,9 @@ gtk_css_node_declaration_equal (gconstpointer elem1, if (decl1->state != decl2->state) return FALSE; + if (decl1->id != decl2->id) + return FALSE; + if (decl1->n_classes != decl2->n_classes) return FALSE; -- cgit v1.2.1