From d79a44c1afaea14cd8442df61631154fe0bdd441 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 24 Jan 2015 20:57:17 +0100 Subject: [PATCH] stylecontext: Get rid of create_query_path() Move that functionality into GtkCssNode. --- gtk/gtkcsspathnode.c | 16 ++++++++++++++-- gtk/gtkcsswidgetnode.c | 16 ++++++++++++++-- gtk/gtkstylecontext.c | 38 +++----------------------------------- 3 files changed, 31 insertions(+), 39 deletions(-) diff --git a/gtk/gtkcsspathnode.c b/gtk/gtkcsspathnode.c index 85358b4666..39a2f073a1 100644 --- a/gtk/gtkcsspathnode.c +++ b/gtk/gtkcsspathnode.c @@ -26,11 +26,23 @@ static GtkWidgetPath * gtk_css_path_node_real_create_widget_path (GtkCssNode *node) { GtkCssPathNode *path_node = GTK_CSS_PATH_NODE (node); + GtkWidgetPath *path; + guint length; if (path_node->path == NULL) - return gtk_widget_path_new (); + path = gtk_widget_path_new (); + else + path = gtk_widget_path_copy (path_node->path); - return gtk_widget_path_copy (path_node->path); + length = gtk_widget_path_length (path); + if (length > 0) + { + gtk_css_node_declaration_add_to_widget_path (gtk_css_node_get_declaration (node), + path, + length - 1); + } + + return path; } static const GtkWidgetPath * diff --git a/gtk/gtkcsswidgetnode.c b/gtk/gtkcsswidgetnode.c index b7932ce5c3..c9e156e619 100644 --- a/gtk/gtkcsswidgetnode.c +++ b/gtk/gtkcsswidgetnode.c @@ -27,11 +27,23 @@ static GtkWidgetPath * gtk_css_widget_node_create_widget_path (GtkCssNode *node) { GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node); + GtkWidgetPath *path; + guint length; if (widget_node->widget == NULL) - return gtk_widget_path_new (); + path = gtk_widget_path_new (); + else + path = _gtk_widget_create_path (widget_node->widget); + + length = gtk_widget_path_length (path); + if (length > 0) + { + gtk_css_node_declaration_add_to_widget_path (gtk_css_node_get_declaration (node), + path, + length - 1); + } - return _gtk_widget_create_path (widget_node->widget); + return path; } static const GtkWidgetPath * diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 260aafa43c..0ff387e664 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -625,37 +625,6 @@ gtk_style_context_get_root (GtkStyleContext *context) return priv->cssnode; } -static GtkWidgetPath * -create_query_path (GtkStyleContext *context, - const GtkCssNodeDeclaration *decl, - gboolean is_root) -{ - GtkCssNode *root; - GtkWidgetPath *path; - guint length; - - root = gtk_style_context_get_root (context); - - path = gtk_css_node_create_widget_path (root); - length = gtk_widget_path_length (path); - if (!is_root) - { - - if (length > 0) - gtk_css_node_declaration_add_to_widget_path (gtk_css_node_get_declaration (root), path, length - 1); - - gtk_widget_path_append_type (path, length > 0 ? gtk_widget_path_iter_get_object_type (path, length - 1) : G_TYPE_NONE); - gtk_css_node_declaration_add_to_widget_path (decl, path, length); - } - else - { - if (length > 0) - gtk_css_node_declaration_add_to_widget_path (decl, path, length - 1); - } - - return path; -} - static gboolean gtk_style_context_has_custom_cascade (GtkStyleContext *context) { @@ -770,7 +739,7 @@ update_properties (GtkStyleContext *context, if (result) return g_object_ref (result); - path = create_query_path (context, decl, TRUE); + path = gtk_css_node_create_widget_path (cssnode); if (!_gtk_css_matcher_init (&matcher, path)) { @@ -811,9 +780,7 @@ build_properties (GtkStyleContext *context, if (style) return g_object_ref (style); - path = create_query_path (context, - decl, - cssnode == gtk_style_context_get_root (context)); + path = gtk_css_node_create_widget_path (cssnode); if (override_state) gtk_widget_path_iter_set_state (path, -1, state); @@ -1634,6 +1601,7 @@ gtk_style_context_save (GtkStyleContext *context) cssnode = gtk_css_transient_node_new (priv->cssnode); gtk_css_node_set_parent (cssnode, gtk_style_context_get_root (context)); + gtk_css_node_set_widget_type (cssnode, gtk_css_node_get_widget_type (priv->cssnode)); priv->saved_nodes = g_slist_prepend (priv->saved_nodes, priv->cssnode); priv->cssnode = cssnode;