[gtk+/wip/cssnode3: 10/101] stylecontext: Get rid of create_query_path()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/cssnode3: 10/101] stylecontext: Get rid of create_query_path()
- Date: Wed, 11 Mar 2015 00:20:26 +0000 (UTC)
commit cf877639541a9522d721477e5c77e36137b1dacb
Author: Benjamin Otte <otte redhat com>
Date: Sat Jan 24 20:57:17 2015 +0100
stylecontext: Get rid of create_query_path()
Move that functionality into GtkCssNode.
gtk/gtkcsspathnode.c | 16 ++++++++++++++--
gtk/gtkcsswidgetnode.c | 18 +++++++++++++++---
gtk/gtkstylecontext.c | 38 +++-----------------------------------
3 files changed, 32 insertions(+), 40 deletions(-)
---
diff --git a/gtk/gtkcsspathnode.c b/gtk/gtkcsspathnode.c
index 85358b4..39a2f07 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 ();
-
- 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 *
diff --git a/gtk/gtkcsswidgetnode.c b/gtk/gtkcsswidgetnode.c
index b7932ce..c9e156e 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 ();
-
- 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 *
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index e025be0..e2e0400 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]