[gtk+/wip/cssnode3: 34/46] cssnode: Split out a function
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/cssnode3: 34/46] cssnode: Split out a function
- Date: Tue, 10 Feb 2015 01:57:58 +0000 (UTC)
commit 88b54aa7c96a1b5540a2f63207be6338f40b81fc
Author: Benjamin Otte <otte redhat com>
Date: Mon Feb 9 09:41:48 2015 +0100
cssnode: Split out a function
So far the vfunc is kinda quirky (the path argument is an out argument
for something you have to free when you're done with the matcher), but
I'm about to change that.
gtk/gtkcssmatcherprivate.h | 1 -
gtk/gtkcssnode.c | 52 +++++++++++++++++++++++++++++++++++++------
gtk/gtkcssnodeprivate.h | 10 +++++++-
gtk/gtkcsstypesprivate.h | 3 +-
4 files changed, 55 insertions(+), 11 deletions(-)
---
diff --git a/gtk/gtkcssmatcherprivate.h b/gtk/gtkcssmatcherprivate.h
index a988071..e37083e 100644
--- a/gtk/gtkcssmatcherprivate.h
+++ b/gtk/gtkcssmatcherprivate.h
@@ -24,7 +24,6 @@
G_BEGIN_DECLS
-typedef union _GtkCssMatcher GtkCssMatcher;
typedef struct _GtkCssMatcherSuperset GtkCssMatcherSuperset;
typedef struct _GtkCssMatcherWidgetPath GtkCssMatcherWidgetPath;
typedef struct _GtkCssMatcherClass GtkCssMatcherClass;
diff --git a/gtk/gtkcssnode.c b/gtk/gtkcssnode.c
index fccc43e..9f9ec53 100644
--- a/gtk/gtkcssnode.c
+++ b/gtk/gtkcssnode.c
@@ -109,6 +109,32 @@ gtk_css_node_real_validate (GtkCssNode *cssnode,
return _gtk_bitmask_new ();
}
+gboolean
+gtk_css_node_real_init_matcher (GtkCssNode *cssnode,
+ GtkCssMatcher *matcher,
+ GtkWidgetPath **path_out)
+{
+ GtkWidgetPath *path;
+
+ path = gtk_css_node_create_widget_path (cssnode);
+
+ if (!_gtk_css_matcher_init (matcher, path))
+ {
+ gtk_widget_path_free (path);
+ return FALSE;
+ }
+
+ if (path_out == NULL)
+ {
+ gtk_widget_path_free (path);
+ g_assert_not_reached ();
+ return FALSE;
+ }
+
+ *path_out = path;
+ return TRUE;
+}
+
static GtkWidgetPath *
gtk_css_node_real_create_widget_path (GtkCssNode *cssnode)
{
@@ -143,6 +169,7 @@ gtk_css_node_class_init (GtkCssNodeClass *klass)
klass->validate = gtk_css_node_real_validate;
klass->queue_validate = gtk_css_node_real_queue_validate;
klass->dequeue_validate = gtk_css_node_real_dequeue_validate;
+ klass->init_matcher = gtk_css_node_real_init_matcher;
klass->create_widget_path = gtk_css_node_real_create_widget_path;
klass->get_widget_path = gtk_css_node_real_get_widget_path;
klass->get_style_provider = gtk_css_node_real_get_style_provider;
@@ -562,9 +589,7 @@ gtk_css_node_update_style (GtkCssNode *cssnode,
if (result)
return g_object_ref (result);
- path = gtk_css_node_create_widget_path (cssnode);
-
- if (!_gtk_css_matcher_init (&matcher, path))
+ if (!gtk_css_node_init_matcher (cssnode, &matcher, &path))
{
g_assert_not_reached ();
}
@@ -575,7 +600,8 @@ gtk_css_node_update_style (GtkCssNode *cssnode,
&matcher,
parent);
- gtk_widget_path_free (path);
+ if (path)
+ gtk_widget_path_free (path);
store_in_global_parent_cache (cssnode, parent, decl, style);
@@ -598,9 +624,7 @@ gtk_css_node_create_style (GtkCssNode *cssnode)
if (style)
return g_object_ref (style);
- path = gtk_css_node_create_widget_path (cssnode);
-
- if (_gtk_css_matcher_init (&matcher, path))
+ if (gtk_css_node_init_matcher (cssnode, &matcher, &path))
style = gtk_css_static_style_new_compute (gtk_css_node_get_style_provider (cssnode),
&matcher,
parent);
@@ -609,7 +633,8 @@ gtk_css_node_create_style (GtkCssNode *cssnode)
NULL,
parent);
- gtk_widget_path_free (path);
+ if (path)
+ gtk_widget_path_free (path);
store_in_global_parent_cache (cssnode, parent, decl, style);
@@ -692,6 +717,17 @@ gtk_css_node_validate (GtkCssNode *cssnode,
_gtk_bitmask_free (changes);
}
+gboolean
+gtk_css_node_init_matcher (GtkCssNode *cssnode,
+ GtkCssMatcher *matcher,
+ GtkWidgetPath **path_out)
+{
+ if (path_out)
+ *path_out = NULL;
+
+ return GTK_CSS_NODE_GET_CLASS (cssnode)->init_matcher (cssnode, matcher, path_out);
+}
+
GtkWidgetPath *
gtk_css_node_create_widget_path (GtkCssNode *cssnode)
{
diff --git a/gtk/gtkcssnodeprivate.h b/gtk/gtkcssnodeprivate.h
index 25e4cfa..b119730 100644
--- a/gtk/gtkcssnodeprivate.h
+++ b/gtk/gtkcssnodeprivate.h
@@ -19,7 +19,8 @@
#define __GTK_CSS_NODE_PRIVATE_H__
#include "gtkcssnodedeclarationprivate.h"
-#include "gtkcssstyleprivate.h"
+#include "gtkbitmaskprivate.h"
+#include "gtkcsstypesprivate.h"
G_BEGIN_DECLS
@@ -56,6 +57,9 @@ struct _GtkCssNodeClass
{
GObjectClass object_class;
+ gboolean (* init_matcher) (GtkCssNode *cssnode,
+ GtkCssMatcher *matcher,
+ GtkWidgetPath **path);
GtkWidgetPath * (* create_widget_path) (GtkCssNode *cssnode);
const GtkWidgetPath * (* get_widget_path) (GtkCssNode *cssnode);
GtkStyleProviderPrivate *(* get_style_provider) (GtkCssNode *cssnode);
@@ -129,6 +133,10 @@ void gtk_css_node_validate (GtkCssNode *
const GtkBitmask *parent_changes);
void gtk_css_node_set_invalid (GtkCssNode *node,
gboolean invalid);
+
+gboolean gtk_css_node_init_matcher (GtkCssNode *cssnode,
+ GtkCssMatcher *matcher,
+ GtkWidgetPath **path);
GtkWidgetPath * gtk_css_node_create_widget_path (GtkCssNode *cssnode);
const GtkWidgetPath * gtk_css_node_get_widget_path (GtkCssNode *cssnode);
GtkStyleProviderPrivate *gtk_css_node_get_style_provider(GtkCssNode *cssnode);
diff --git a/gtk/gtkcsstypesprivate.h b/gtk/gtkcsstypesprivate.h
index 2308453..792a66e 100644
--- a/gtk/gtkcsstypesprivate.h
+++ b/gtk/gtkcsstypesprivate.h
@@ -23,7 +23,8 @@
G_BEGIN_DECLS
-/* forward declaration for GtkCssValue */
+typedef union _GtkCssMatcher GtkCssMatcher;
+typedef struct _GtkCssNode GtkCssNode;
typedef struct _GtkCssStyle GtkCssStyle;
typedef struct _GtkStyleProviderPrivate GtkStyleProviderPrivate; /* dummy typedef */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]