forked from AuroraMiddleware/gtk
cssnode: Track invalid flag
Remove it from GtkStyleContext.
This commit is contained in:
parent
a589f98821
commit
55e68bc2ea
@ -23,6 +23,16 @@
|
||||
|
||||
G_DEFINE_TYPE (GtkCssNode, gtk_css_node, G_TYPE_OBJECT)
|
||||
|
||||
void
|
||||
gtk_css_node_set_invalid (GtkCssNode *node,
|
||||
gboolean invalid)
|
||||
{
|
||||
if (node->invalid == invalid)
|
||||
return;
|
||||
|
||||
GTK_CSS_NODE_GET_CLASS (node)->set_invalid (node, invalid);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_node_dispose (GObject *object)
|
||||
{
|
||||
@ -54,6 +64,16 @@ gtk_css_node_real_invalidate (GtkCssNode *cssnode,
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_node_real_set_invalid (GtkCssNode *node,
|
||||
gboolean invalid)
|
||||
{
|
||||
node->invalid = invalid;
|
||||
|
||||
if (invalid && node->parent)
|
||||
gtk_css_node_set_invalid (node->parent, invalid);
|
||||
}
|
||||
|
||||
static GtkWidgetPath *
|
||||
gtk_css_node_real_create_widget_path (GtkCssNode *cssnode)
|
||||
{
|
||||
@ -75,6 +95,7 @@ gtk_css_node_class_init (GtkCssNodeClass *klass)
|
||||
object_class->finalize = gtk_css_node_finalize;
|
||||
|
||||
klass->invalidate = gtk_css_node_real_invalidate;
|
||||
klass->set_invalid = gtk_css_node_real_set_invalid;
|
||||
klass->create_widget_path = gtk_css_node_real_create_widget_path;
|
||||
klass->get_widget_path = gtk_css_node_real_get_widget_path;
|
||||
}
|
||||
@ -137,6 +158,9 @@ gtk_css_node_set_parent (GtkCssNode *node,
|
||||
if (parent->first_child == NULL)
|
||||
parent->first_child = node;
|
||||
}
|
||||
|
||||
if (node->invalid)
|
||||
gtk_css_node_set_invalid (parent, TRUE);
|
||||
}
|
||||
|
||||
gtk_css_node_invalidate (node, GTK_CSS_CHANGE_ANY_PARENT | GTK_CSS_CHANGE_ANY_SIBLING);
|
||||
@ -330,6 +354,8 @@ gtk_css_node_invalidate (GtkCssNode *cssnode,
|
||||
GtkCssChange change)
|
||||
{
|
||||
GTK_CSS_NODE_GET_CLASS (cssnode)->invalidate (cssnode, change);
|
||||
|
||||
gtk_css_node_set_invalid (cssnode, TRUE);
|
||||
}
|
||||
|
||||
GtkWidgetPath *
|
||||
|
@ -46,6 +46,8 @@ struct _GtkCssNode
|
||||
|
||||
GtkCssNodeDeclaration *decl;
|
||||
GtkCssStyle *style;
|
||||
|
||||
guint invalid :1; /* set if node or a child is invalid */
|
||||
};
|
||||
|
||||
struct _GtkCssNodeClass
|
||||
@ -56,6 +58,8 @@ struct _GtkCssNodeClass
|
||||
const GtkWidgetPath * (* get_widget_path) (GtkCssNode *cssnode);
|
||||
void (* invalidate) (GtkCssNode *cssnode,
|
||||
GtkCssChange change);
|
||||
void (* set_invalid) (GtkCssNode *node,
|
||||
gboolean invalid);
|
||||
};
|
||||
|
||||
GType gtk_css_node_get_type (void) G_GNUC_CONST;
|
||||
@ -108,6 +112,8 @@ void gtk_css_node_set_style (GtkCssNode *
|
||||
|
||||
void gtk_css_node_invalidate (GtkCssNode *cssnode,
|
||||
GtkCssChange change);
|
||||
void gtk_css_node_set_invalid (GtkCssNode *node,
|
||||
gboolean invalid);
|
||||
GtkWidgetPath * gtk_css_node_create_widget_path (GtkCssNode *cssnode);
|
||||
const GtkWidgetPath * gtk_css_node_get_widget_path (GtkCssNode *cssnode);
|
||||
|
||||
|
@ -39,6 +39,13 @@ 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)
|
||||
{
|
||||
@ -76,6 +83,7 @@ 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;
|
||||
}
|
||||
|
@ -29,6 +29,13 @@ gtk_css_transient_node_invalidate (GtkCssNode *node,
|
||||
gtk_css_node_set_style (node, NULL);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@ -65,6 +72,7 @@ gtk_css_transient_node_class_init (GtkCssTransientNodeClass *klass)
|
||||
GtkCssNodeClass *node_class = GTK_CSS_NODE_CLASS (klass);
|
||||
|
||||
node_class->invalidate = gtk_css_transient_node_invalidate;
|
||||
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;
|
||||
}
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkcsswidgetnodeprivate.h"
|
||||
|
||||
#include "gtkcontainerprivate.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
@ -29,15 +31,26 @@ gtk_css_widget_node_invalidate (GtkCssNode *node,
|
||||
GtkCssChange change)
|
||||
{
|
||||
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
|
||||
GtkStyleContext *context;
|
||||
|
||||
widget_node->pending_changes |= change;
|
||||
}
|
||||
|
||||
if (widget_node->widget == NULL)
|
||||
return;
|
||||
static void
|
||||
gtk_css_widget_node_set_invalid (GtkCssNode *node,
|
||||
gboolean invalid)
|
||||
{
|
||||
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
|
||||
|
||||
context = gtk_widget_get_style_context (widget_node->widget);
|
||||
gtk_style_context_set_invalid (context, TRUE);
|
||||
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))
|
||||
{
|
||||
_gtk_container_queue_restyle (GTK_CONTAINER (widget_node->widget));
|
||||
}
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
}
|
||||
|
||||
static GtkWidgetPath *
|
||||
@ -80,6 +93,7 @@ gtk_css_widget_node_class_init (GtkCssWidgetNodeClass *klass)
|
||||
GtkCssNodeClass *node_class = GTK_CSS_NODE_CLASS (klass);
|
||||
|
||||
node_class->invalidate = gtk_css_widget_node_invalidate;
|
||||
node_class->set_invalid = gtk_css_widget_node_set_invalid;
|
||||
node_class->create_widget_path = gtk_css_widget_node_create_widget_path;
|
||||
node_class->get_widget_path = gtk_css_widget_node_get_widget_path;
|
||||
}
|
||||
|
@ -163,7 +163,6 @@ struct _GtkStyleContextPrivate
|
||||
|
||||
const GtkBitmask *invalidating_context;
|
||||
guint animating : 1;
|
||||
guint invalid : 1;
|
||||
};
|
||||
|
||||
enum {
|
||||
@ -838,33 +837,6 @@ gtk_style_context_lookup_style_for_state (GtkStyleContext *context,
|
||||
return values;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_style_context_set_invalid (GtkStyleContext *context,
|
||||
gboolean invalid)
|
||||
{
|
||||
GtkStyleContextPrivate *priv;
|
||||
|
||||
priv = context->priv;
|
||||
|
||||
if (priv->invalid == invalid)
|
||||
return;
|
||||
|
||||
priv->invalid = invalid;
|
||||
|
||||
if (invalid)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
||||
if (GTK_IS_CSS_WIDGET_NODE (priv->cssnode) &&
|
||||
GTK_IS_RESIZE_CONTAINER (widget = gtk_css_widget_node_get_widget (GTK_CSS_WIDGET_NODE (priv->cssnode))))
|
||||
_gtk_container_queue_restyle (GTK_CONTAINER (widget));
|
||||
else if (priv->parent)
|
||||
gtk_style_context_set_invalid (priv->parent, TRUE);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_style_context_new:
|
||||
*
|
||||
@ -1505,8 +1477,6 @@ gtk_style_context_set_parent (GtkStyleContext *context,
|
||||
{
|
||||
parent->priv->children = g_slist_prepend (parent->priv->children, context);
|
||||
g_object_ref (parent);
|
||||
if (priv->invalid)
|
||||
gtk_style_context_set_invalid (parent, TRUE);
|
||||
gtk_css_node_set_parent (gtk_style_context_get_root (context),
|
||||
gtk_style_context_get_root (parent));
|
||||
}
|
||||
@ -2883,10 +2853,10 @@ _gtk_style_context_validate (GtkStyleContext *context,
|
||||
if (G_UNLIKELY (gtk_get_debug_flags () & GTK_DEBUG_NO_CSS_CACHE))
|
||||
change = GTK_CSS_CHANGE_ANY;
|
||||
|
||||
if (!priv->invalid && change == 0 && _gtk_bitmask_is_empty (parent_changes))
|
||||
if (!cssnode->invalid && change == 0 && _gtk_bitmask_is_empty (parent_changes))
|
||||
return;
|
||||
|
||||
gtk_style_context_set_invalid (context, FALSE);
|
||||
gtk_css_node_set_invalid (cssnode, FALSE);
|
||||
|
||||
current = gtk_css_node_get_style (cssnode);
|
||||
if (current == NULL)
|
||||
|
@ -48,8 +48,6 @@ void _gtk_style_context_validate (GtkStyleContext *c
|
||||
const GtkBitmask*parent_changes);
|
||||
void _gtk_style_context_queue_invalidate (GtkStyleContext *context,
|
||||
GtkCssChange change);
|
||||
void gtk_style_context_set_invalid (GtkStyleContext *context,
|
||||
gboolean invalid);
|
||||
gboolean _gtk_style_context_check_region_name (const gchar *str);
|
||||
|
||||
gboolean _gtk_style_context_resolve_color (GtkStyleContext *context,
|
||||
|
Loading…
Reference in New Issue
Block a user