[gtk+/wip/cssnode3: 58/88] cssnode: Change get_style_provider() vfunc
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/cssnode3: 58/88] cssnode: Change get_style_provider() vfunc
- Date: Thu, 5 Mar 2015 19:55:42 +0000 (UTC)
commit ffcd01ae34c07618e9a51b11f9ec86222951ce9f
Author: Benjamin Otte <otte redhat com>
Date: Tue Feb 17 15:18:32 2015 +0100
cssnode: Change get_style_provider() vfunc
Instead of always returning a provider, allow the vfunc to return NULL
to mane "use same provider as parent". This allows a bunch of
optimizations.
gtk/gtkcssnode.c | 26 ++++++++++++++++++++------
gtk/gtkcssnodeprivate.h | 1 +
gtk/gtkcsspathnode.c | 2 +-
gtk/gtkcsswidgetnode.c | 2 +-
4 files changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkcssnode.c b/gtk/gtkcssnode.c
index 877dd18..d81f061 100644
--- a/gtk/gtkcssnode.c
+++ b/gtk/gtkcssnode.c
@@ -29,6 +29,12 @@
G_DEFINE_TYPE (GtkCssNode, gtk_css_node, G_TYPE_OBJECT)
+static GtkStyleProviderPrivate *
+gtk_css_node_get_style_provider_or_null (GtkCssNode *cssnode)
+{
+ return GTK_CSS_NODE_GET_CLASS (cssnode)->get_style_provider (cssnode);
+}
+
void
gtk_css_node_set_invalid (GtkCssNode *node,
gboolean invalid)
@@ -82,13 +88,15 @@ gtk_css_node_finalize (GObject *object)
static gboolean
may_use_global_parent_cache (GtkCssNode *node)
{
+ GtkStyleProviderPrivate *provider;
GtkCssNode *parent;
parent = gtk_css_node_get_parent (node);
if (parent == NULL)
return FALSE;
- if (gtk_css_node_get_style_provider (node) != gtk_css_node_get_style_provider (parent))
+ provider = gtk_css_node_get_style_provider_or_null (node);
+ if (provider != NULL && provider != gtk_css_node_get_style_provider (parent))
return FALSE;
return TRUE;
@@ -275,10 +283,7 @@ gtk_css_node_real_get_widget_path (GtkCssNode *cssnode)
static GtkStyleProviderPrivate *
gtk_css_node_real_get_style_provider (GtkCssNode *cssnode)
{
- if (cssnode->parent)
- return gtk_css_node_get_style_provider (cssnode->parent);
-
- return GTK_STYLE_PROVIDER_PRIVATE (_gtk_settings_get_style_cascade (gtk_settings_get_default (), 1));
+ return NULL;
}
static void
@@ -821,5 +826,14 @@ gtk_css_node_get_widget_path (GtkCssNode *cssnode)
GtkStyleProviderPrivate *
gtk_css_node_get_style_provider (GtkCssNode *cssnode)
{
- return GTK_CSS_NODE_GET_CLASS (cssnode)->get_style_provider (cssnode);
+ GtkStyleProviderPrivate *result;
+
+ result = gtk_css_node_get_style_provider_or_null (cssnode);
+ if (result)
+ return result;
+
+ if (cssnode->parent)
+ return gtk_css_node_get_style_provider (cssnode->parent);
+
+ return GTK_STYLE_PROVIDER_PRIVATE (_gtk_settings_get_style_cascade (gtk_settings_get_default (), 1));
}
diff --git a/gtk/gtkcssnodeprivate.h b/gtk/gtkcssnodeprivate.h
index 32f938f..8cfcd2a 100644
--- a/gtk/gtkcssnodeprivate.h
+++ b/gtk/gtkcssnodeprivate.h
@@ -68,6 +68,7 @@ struct _GtkCssNodeClass
GtkCssMatcher *matcher);
GtkWidgetPath * (* create_widget_path) (GtkCssNode *cssnode);
const GtkWidgetPath * (* get_widget_path) (GtkCssNode *cssnode);
+ /* get style provider to use or NULL to use parent's */
GtkStyleProviderPrivate *(* get_style_provider) (GtkCssNode *cssnode);
GtkCssStyle * (* update_style) (GtkCssNode *cssnode,
GtkCssChange pending_changes,
diff --git a/gtk/gtkcsspathnode.c b/gtk/gtkcsspathnode.c
index 1fc702e..50a1cc3 100644
--- a/gtk/gtkcsspathnode.c
+++ b/gtk/gtkcsspathnode.c
@@ -107,7 +107,7 @@ gtk_css_path_node_get_style_provider (GtkCssNode *node)
GtkCssPathNode *path_node = GTK_CSS_PATH_NODE (node);
if (path_node->context == NULL)
- return GTK_CSS_NODE_CLASS (gtk_css_path_node_parent_class)->get_style_provider (node);
+ return NULL;
return gtk_style_context_get_style_provider (path_node->context);
}
diff --git a/gtk/gtkcsswidgetnode.c b/gtk/gtkcsswidgetnode.c
index 12e346b..10d0334 100644
--- a/gtk/gtkcsswidgetnode.c
+++ b/gtk/gtkcsswidgetnode.c
@@ -262,7 +262,7 @@ gtk_css_widget_node_get_style_provider (GtkCssNode *node)
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
if (widget_node->widget == NULL)
- return GTK_CSS_NODE_CLASS (gtk_css_widget_node_parent_class)->get_style_provider (node);
+ return NULL;
return gtk_style_context_get_style_provider (gtk_widget_get_style_context (widget_node->widget));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]