[gtk+/wip/cssnode3: 28/46] cssnode: Change way invalidation is handled
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/cssnode3: 28/46] cssnode: Change way invalidation is handled
- Date: Tue, 10 Feb 2015 01:57:27 +0000 (UTC)
commit cecc78b927d0e597cc4173a2ae6ee879df176bd2
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 | 53 +++++++++++++++++++++++++++++++++++++++------
gtk/gtkcssnodeprivate.h | 4 +-
gtk/gtkcsspathnode.c | 8 ------
gtk/gtkcsstransientnode.c | 8 ------
gtk/gtkcsswidgetnode.c | 11 ++------
5 files changed, 51 insertions(+), 33 deletions(-)
---
diff --git a/gtk/gtkcssnode.c b/gtk/gtkcssnode.c
index 90c8f83..7a00c51 100644
--- a/gtk/gtkcssnode.c
+++ b/gtk/gtkcssnode.c
@@ -40,6 +40,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);
}
@@ -89,13 +91,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 *
@@ -139,7 +141,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;
@@ -160,7 +163,37 @@ 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_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
@@ -195,10 +228,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 aeecc4d..1e41a05 100644
--- a/gtk/gtkcsspathnode.c
+++ b/gtk/gtkcsspathnode.c
@@ -36,13 +36,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)
{
@@ -91,7 +84,6 @@ gtk_css_path_node_class_init (GtkCssPathNodeClass *klass)
GtkCssNodeClass *node_class = GTK_CSS_NODE_CLASS (klass);
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]