From a7da137778d1254ca036486b79c0cbf8da14a706 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 7 Nov 2012 18:52:20 +0000 Subject: [PATCH] st_theme_node_equal: use split (pseudo-)classes This is a prerequisite for getting rid of the unsplit versions. Bug: https://bugzilla.gnome.org/show_bug.cgi?id=687465 Reviewed-by: Jasper St. Pierre --- src/st/st-theme-node.c | 53 +++++++++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/src/st/st-theme-node.c b/src/st/st-theme-node.c index 31bcf8aa5..1eda14d0a 100644 --- a/src/st/st-theme-node.c +++ b/src/st/st-theme-node.c @@ -363,14 +363,51 @@ st_theme_node_equal (StThemeNode *node_a, StThemeNode *node_b) g_return_val_if_fail (ST_IS_THEME_NODE (node_a), FALSE); g_return_val_if_fail (ST_IS_THEME_NODE (node_b), FALSE); - return node_a->parent_node == node_b->parent_node && - node_a->context == node_b->context && - node_a->theme == node_b->theme && - node_a->element_type == node_b->element_type && - !g_strcmp0 (node_a->element_id, node_b->element_id) && - !g_strcmp0 (node_a->element_class, node_b->element_class) && - !g_strcmp0 (node_a->pseudo_class, node_b->pseudo_class) && - !g_strcmp0 (node_a->inline_style, node_b->inline_style); + if (node_a->parent_node != node_b->parent_node || + node_a->context != node_b->context || + node_a->theme != node_b->theme || + node_a->element_type != node_b->element_type || + g_strcmp0 (node_a->element_id, node_b->element_id) || + g_strcmp0 (node_a->inline_style, node_b->inline_style)) + return FALSE; + + if ((node_a->element_classes == NULL) != (node_b->element_classes == NULL)) + return FALSE; + + if ((node_a->pseudo_classes == NULL) != (node_b->pseudo_classes == NULL)) + return FALSE; + + if (node_a->element_classes != NULL) + { + int i; + + for (i = 0; ; i++) + { + if (g_strcmp0 (node_a->element_classes[i], + node_b->element_classes[i])) + return FALSE; + + if (node_a->element_classes[i] == NULL) + break; + } + } + + if (node_a->pseudo_classes != NULL) + { + int i; + + for (i = 0; ; i++) + { + if (g_strcmp0 (node_a->pseudo_classes[i], + node_b->pseudo_classes[i])) + return FALSE; + + if (node_a->pseudo_classes[i] == NULL) + break; + } + } + + return TRUE; } static void