[gtk+/wip/cssnode3: 28/102] cssnode: Change way invalidation is handled
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/cssnode3: 28/102] cssnode: Change way invalidation is handled
- Date: Wed, 11 Mar 2015 00:18:45 +0000 (UTC)
commit a5658db1bcae289d96c7d75bf0c660de58df9a94
Author: Benjamin Otte <otte redhat com>
Date: Sat Feb 7 17:19:07 2015 +0100
cssnode: Change way invalidation is handled
Have a queue_validate() vfunc and a dequeue_validate() vfunc that are
called only on root nodes so they can queue a validation on their frame
clocks.
gtk/gtkcssnode.c | 54 +++++++++++++++++++++++++++++++++++++++-----
gtk/gtkcssnodeprivate.h | 4 +-
gtk/gtkcsspathnode.c | 8 ------
gtk/gtkcsstransientnode.c | 8 ------
gtk/gtkcsswidgetnode.c | 11 ++------
5 files changed, 52 insertions(+), 33 deletions(-)
---
diff --git a/gtk/gtkcssnode.c b/gtk/gtkcssnode.c
index db68349..9d7c0cb 100644
--- a/gtk/gtkcssnode.c
+++ b/gtk/gtkcssnode.c
@@ -37,9 +37,26 @@ gtk_css_node_set_invalid (GtkCssNode *node,
if (node->invalid == invalid)
return;
- GTK_CSS_NODE_GET_CLASS (node)->set_invalid (node, invalid);
+ if (GTK_IS_CSS_TRANSIENT_NODE (node))
+ return;
+
+ node->invalid = invalid;
+
+ if (node->parent)
+ {
+ if (invalid)
+ gtk_css_node_set_invalid (node->parent, TRUE);
+ }
+ else
+ {
+ if (invalid)
+ GTK_CSS_NODE_GET_CLASS (node)->queue_validate (node);
+ else
+ GTK_CSS_NODE_GET_CLASS (node)->dequeue_validate (node);
+ }
}
+
static void
gtk_css_node_dispose (GObject *object)
{
@@ -50,6 +67,8 @@ gtk_css_node_dispose (GObject *object)
gtk_css_node_set_parent (cssnode->first_child, NULL);
}
+ gtk_css_node_set_invalid (cssnode, FALSE);
+
G_OBJECT_CLASS (gtk_css_node_parent_class)->dispose (object);
}
@@ -261,13 +280,13 @@ gtk_css_node_real_invalidate (GtkCssNode *node)
}
static void
-gtk_css_node_real_set_invalid (GtkCssNode *node,
- gboolean invalid)
+gtk_css_node_real_queue_validate (GtkCssNode *node)
{
- node->invalid = invalid;
+}
- if (invalid && node->parent)
- gtk_css_node_set_invalid (node->parent, invalid);
+static void
+gtk_css_node_real_dequeue_validate (GtkCssNode *node)
+{
}
static GtkBitmask *
@@ -311,7 +330,8 @@ gtk_css_node_class_init (GtkCssNodeClass *klass)
klass->update_style = gtk_css_node_real_update_style;
klass->invalidate = gtk_css_node_real_invalidate;
klass->validate = gtk_css_node_real_validate;
- klass->set_invalid = gtk_css_node_real_set_invalid;
+ klass->queue_validate = gtk_css_node_real_queue_validate;
+ klass->dequeue_validate = gtk_css_node_real_dequeue_validate;
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;
@@ -325,6 +345,20 @@ gtk_css_node_init (GtkCssNode *cssnode)
cssnode->style = g_object_ref (gtk_css_static_style_get_default ());
}
+static void
+gtk_css_node_parent_was_unset (GtkCssNode *node)
+{
+ if (node->invalid)
+ GTK_CSS_NODE_GET_CLASS (node)->queue_validate (node);
+}
+
+static void
+gtk_css_node_parent_will_be_set (GtkCssNode *node)
+{
+ if (node->invalid)
+ GTK_CSS_NODE_GET_CLASS (node)->dequeue_validate (node);
+}
+
void
gtk_css_node_set_parent (GtkCssNode *node,
GtkCssNode *parent)
@@ -357,10 +391,16 @@ gtk_css_node_set_parent (GtkCssNode *node,
node->previous_sibling = NULL;
g_object_unref (node);
+
+ if (parent == NULL)
+ gtk_css_node_parent_was_unset (node);
}
if (parent)
{
+ if (node->parent == NULL)
+ gtk_css_node_parent_will_be_set (node);
+
node->parent = parent;
if (!GTK_IS_CSS_TRANSIENT_NODE (node))
diff --git a/gtk/gtkcssnodeprivate.h b/gtk/gtkcssnodeprivate.h
index d368a50..45fe926 100644
--- a/gtk/gtkcssnodeprivate.h
+++ b/gtk/gtkcssnodeprivate.h
@@ -63,8 +63,8 @@ struct _GtkCssNodeClass
GtkCssChange pending_changes,
GtkCssStyle *old_style);
void (* invalidate) (GtkCssNode *node);
- void (* set_invalid) (GtkCssNode *node,
- gboolean invalid);
+ void (* queue_validate) (GtkCssNode *node);
+ void (* dequeue_validate) (GtkCssNode *node);
GtkBitmask * (* validate) (GtkCssNode *cssnode,
gint64 timestamp,
GtkCssChange change,
diff --git a/gtk/gtkcsspathnode.c b/gtk/gtkcsspathnode.c
index a92743c..1e50182 100644
--- a/gtk/gtkcsspathnode.c
+++ b/gtk/gtkcsspathnode.c
@@ -47,13 +47,6 @@ gtk_css_path_node_invalidate (GtkCssNode *node)
}
}
-static void
-gtk_css_path_node_set_invalid (GtkCssNode *node,
- gboolean invalid)
-{
- /* path nodes are always valid */
-}
-
static GtkWidgetPath *
gtk_css_path_node_real_create_widget_path (GtkCssNode *node)
{
@@ -105,7 +98,6 @@ gtk_css_path_node_class_init (GtkCssPathNodeClass *klass)
object_class->finalize = gtk_css_path_node_finalize;
node_class->invalidate = gtk_css_path_node_invalidate;
- node_class->set_invalid = gtk_css_path_node_set_invalid;
node_class->create_widget_path = gtk_css_path_node_real_create_widget_path;
node_class->get_widget_path = gtk_css_path_node_real_get_widget_path;
node_class->get_style_provider = gtk_css_path_node_get_style_provider;
diff --git a/gtk/gtkcsstransientnode.c b/gtk/gtkcsstransientnode.c
index f2602e5..723c97a 100644
--- a/gtk/gtkcsstransientnode.c
+++ b/gtk/gtkcsstransientnode.c
@@ -22,13 +22,6 @@
G_DEFINE_TYPE (GtkCssTransientNode, gtk_css_transient_node, GTK_TYPE_CSS_NODE)
-static void
-gtk_css_transient_node_set_invalid (GtkCssNode *node,
- gboolean invalid)
-{
- /* transient nodes are always valid */
-}
-
static GtkWidgetPath *
gtk_css_transient_node_create_widget_path (GtkCssNode *node)
{
@@ -64,7 +57,6 @@ gtk_css_transient_node_class_init (GtkCssTransientNodeClass *klass)
{
GtkCssNodeClass *node_class = GTK_CSS_NODE_CLASS (klass);
- node_class->set_invalid = gtk_css_transient_node_set_invalid;
node_class->create_widget_path = gtk_css_transient_node_create_widget_path;
node_class->get_widget_path = gtk_css_transient_node_get_widget_path;
}
diff --git a/gtk/gtkcsswidgetnode.c b/gtk/gtkcsswidgetnode.c
index 794d5de..cb46bb2 100644
--- a/gtk/gtkcsswidgetnode.c
+++ b/gtk/gtkcsswidgetnode.c
@@ -40,17 +40,12 @@ gtk_css_widget_node_update_style (GtkCssNode *cssnode,
}
static void
-gtk_css_widget_node_set_invalid (GtkCssNode *node,
- gboolean invalid)
+gtk_css_widget_node_queue_validate (GtkCssNode *node)
{
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
- GTK_CSS_NODE_CLASS (gtk_css_widget_node_parent_class)->set_invalid (node, invalid);
-
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- if (invalid &&
- gtk_css_node_get_parent (node) == NULL &&
- GTK_IS_RESIZE_CONTAINER (widget_node->widget))
+ if (GTK_IS_RESIZE_CONTAINER (widget_node->widget))
{
_gtk_container_queue_restyle (GTK_CONTAINER (widget_node->widget));
}
@@ -208,7 +203,7 @@ gtk_css_widget_node_class_init (GtkCssWidgetNodeClass *klass)
node_class->update_style = gtk_css_widget_node_update_style;
node_class->validate = gtk_css_widget_node_validate;
- node_class->set_invalid = gtk_css_widget_node_set_invalid;
+ node_class->queue_validate = gtk_css_widget_node_queue_validate;
node_class->create_widget_path = gtk_css_widget_node_create_widget_path;
node_class->get_widget_path = gtk_css_widget_node_get_widget_path;
node_class->get_style_provider = gtk_css_widget_node_get_style_provider;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]