summaryrefslogtreecommitdiff
path: root/gtk/gtkcssnodedeclaration.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2015-01-20 00:33:34 +0100
committerBenjamin Otte <otte@redhat.com>2015-01-20 01:07:13 +0100
commitdbb8d1dd07a91171ba4a32119713c05e0483de91 (patch)
tree69cfffb22d7117e16e7253c637bb9afb0c797c2d /gtk/gtkcssnodedeclaration.c
parent39d6ec167eaf87b2f94a49cee7702aaf458ee46b (diff)
downloadgtk+-dbb8d1dd07a91171ba4a32119713c05e0483de91.tar.gz
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.
Diffstat (limited to 'gtk/gtkcssnodedeclaration.c')
-rw-r--r--gtk/gtkcssnodedeclaration.c27
1 files changed, 27 insertions, 0 deletions
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;
@@ -181,6 +182,27 @@ gtk_css_node_declaration_get_type (const GtkCssNodeDeclaration *decl)
}
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;