forked from AuroraMiddleware/gtk
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.
This commit is contained in:
parent
5f19f09ac3
commit
cdd964a3af
@ -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))
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user