stylecontext: Get rid of create_query_path()
authorBenjamin Otte <otte@redhat.com>
Sat, 24 Jan 2015 19:57:17 +0000 (20:57 +0100)
committerBenjamin Otte <otte@redhat.com>
Wed, 18 Mar 2015 14:23:29 +0000 (15:23 +0100)
Move that functionality into GtkCssNode.

gtk/gtkcsspathnode.c
gtk/gtkcsswidgetnode.c
gtk/gtkstylecontext.c

index 85358b466674b9d468558262021a648fcead3927..39a2f073a13389ccde6dec895f73455ccf82f251 100644 (file)
@@ -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 ();
-
-  return gtk_widget_path_copy (path_node->path);
+    path = gtk_widget_path_new ();
+  else
+    path = 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 *
index b7932ce5c369f969fa47fdbd4ad5267a4d8b03ae..c9e156e619427f0e0b5e9c37c350acf62606f7ee 100644 (file)
@@ -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 ();
-
-  return _gtk_widget_create_path (widget_node->widget);
+    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 path;
 }
 
 static const GtkWidgetPath *
index 260aafa43c63ede563c7fc1d7179b227b2a298c4..0ff387e6648c4c2f201b499c5ea8684fa30da54b 100644 (file)
@@ -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;