mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-30 15:31:34 +00:00
stylecontext: Move relevant_changes tracking to GtkCssWidgetNode
This commit is contained in:
parent
7bafb63ec3
commit
8c73799ca8
@ -31,11 +31,13 @@ gtk_css_widget_node_invalidate (GtkCssNode *node,
|
||||
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
|
||||
GtkStyleContext *context;
|
||||
|
||||
widget_node->pending_changes |= change;
|
||||
|
||||
if (widget_node->widget == NULL)
|
||||
return;
|
||||
|
||||
context = gtk_widget_get_style_context (widget_node->widget);
|
||||
_gtk_style_context_invalidate_root_node (context, change);
|
||||
gtk_style_context_set_invalid (context, TRUE);
|
||||
}
|
||||
|
||||
static GtkWidgetPath *
|
||||
@ -119,3 +121,17 @@ gtk_css_widget_node_get_widget (GtkCssWidgetNode *node)
|
||||
|
||||
return node->widget;
|
||||
}
|
||||
|
||||
GtkCssChange
|
||||
gtk_css_widget_node_reset_change (GtkCssWidgetNode *node)
|
||||
{
|
||||
GtkCssChange result;
|
||||
|
||||
gtk_internal_return_val_if_fail (GTK_IS_CSS_WIDGET_NODE (node), 0);
|
||||
|
||||
result = node->pending_changes;
|
||||
node->pending_changes = 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,8 @@ struct _GtkCssWidgetNode
|
||||
GtkCssNode node;
|
||||
|
||||
GtkWidget *widget;
|
||||
|
||||
GtkCssChange pending_changes;
|
||||
};
|
||||
|
||||
struct _GtkCssWidgetNodeClass
|
||||
@ -45,13 +47,15 @@ struct _GtkCssWidgetNodeClass
|
||||
GtkCssNodeClass node_class;
|
||||
};
|
||||
|
||||
GType gtk_css_widget_node_get_type (void) G_GNUC_CONST;
|
||||
GType gtk_css_widget_node_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkCssNode * gtk_css_widget_node_new (GtkWidget *widget);
|
||||
GtkCssNode * gtk_css_widget_node_new (GtkWidget *widget);
|
||||
|
||||
void gtk_css_widget_node_widget_destroyed (GtkCssWidgetNode *node);
|
||||
void gtk_css_widget_node_widget_destroyed (GtkCssWidgetNode *node);
|
||||
|
||||
GtkWidget * gtk_css_widget_node_get_widget (GtkCssWidgetNode *node);
|
||||
GtkWidget * gtk_css_widget_node_get_widget (GtkCssWidgetNode *node);
|
||||
|
||||
GtkCssChange gtk_css_widget_node_reset_change (GtkCssWidgetNode *node);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -161,8 +161,6 @@ struct _GtkStyleContextPrivate
|
||||
guint frame_clock_update_id;
|
||||
GdkFrameClock *frame_clock;
|
||||
|
||||
GtkCssChange pending_changes;
|
||||
|
||||
const GtkBitmask *invalidating_context;
|
||||
guint animating : 1;
|
||||
guint invalid : 1;
|
||||
@ -846,7 +844,7 @@ gtk_style_context_lookup_style_for_state (GtkStyleContext *context,
|
||||
return values;
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
gtk_style_context_set_invalid (GtkStyleContext *context,
|
||||
gboolean invalid)
|
||||
{
|
||||
@ -2850,7 +2848,25 @@ _gtk_style_context_validate (GtkStyleContext *context,
|
||||
|
||||
priv = context->priv;
|
||||
|
||||
change |= priv->pending_changes;
|
||||
if (G_UNLIKELY (gtk_style_context_is_saved (context)))
|
||||
{
|
||||
cssnode = gtk_style_context_get_root (context);
|
||||
if (GTK_IS_CSS_WIDGET_NODE (cssnode))
|
||||
{
|
||||
GtkWidget *widget = gtk_css_widget_node_get_widget (GTK_CSS_WIDGET_NODE (cssnode));
|
||||
g_warning ("unmatched gtk_style_context_save/restore() detected while validating context for %s %p",
|
||||
gtk_widget_get_name (widget), widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("unmatched gtk_style_context_save/restore() detected while validating context");
|
||||
}
|
||||
}
|
||||
else
|
||||
cssnode = priv->cssnode;
|
||||
|
||||
if (GTK_IS_CSS_WIDGET_NODE (cssnode))
|
||||
change |= gtk_css_widget_node_reset_change (GTK_CSS_WIDGET_NODE (cssnode));
|
||||
|
||||
/* If you run your application with
|
||||
* GTK_DEBUG=no-css-cache
|
||||
@ -2870,24 +2886,6 @@ _gtk_style_context_validate (GtkStyleContext *context,
|
||||
if (!priv->invalid && change == 0 && _gtk_bitmask_is_empty (parent_changes))
|
||||
return;
|
||||
|
||||
if (G_UNLIKELY (gtk_style_context_is_saved (context)))
|
||||
{
|
||||
cssnode = gtk_style_context_get_root (context);
|
||||
if (GTK_IS_CSS_WIDGET_NODE (cssnode))
|
||||
{
|
||||
GtkWidget *widget = gtk_css_widget_node_get_widget (GTK_CSS_WIDGET_NODE (cssnode));
|
||||
g_warning ("unmatched gtk_style_context_save/restore() detected while validating context for %s %p",
|
||||
gtk_widget_get_name (widget), widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("unmatched gtk_style_context_save/restore() detected while validating context");
|
||||
}
|
||||
}
|
||||
else
|
||||
cssnode = priv->cssnode;
|
||||
|
||||
priv->pending_changes = 0;
|
||||
gtk_style_context_set_invalid (context, FALSE);
|
||||
|
||||
current = gtk_css_node_get_style (cssnode);
|
||||
@ -2977,16 +2975,6 @@ _gtk_style_context_validate (GtkStyleContext *context,
|
||||
_gtk_bitmask_free (changes);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_style_context_invalidate_root_node (GtkStyleContext *context,
|
||||
GtkCssChange change)
|
||||
{
|
||||
GtkStyleContextPrivate *priv = context->priv;
|
||||
|
||||
priv->pending_changes |= change;
|
||||
gtk_style_context_set_invalid (context, TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_style_context_queue_invalidate (GtkStyleContext *context,
|
||||
GtkCssChange change)
|
||||
|
@ -48,8 +48,8 @@ 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_invalidate_root_node (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