summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2015-01-25 06:14:48 +0100
committerBenjamin Otte <otte@redhat.com>2015-03-18 15:23:29 +0100
commit8c73799ca8e170f38eb6afe8604ac5973f6bf141 (patch)
tree448ff86f87fbcc5ed7b3e7891d3e258506b70286 /gtk
parent7bafb63ec3b04764f8986b82f1a6c6e1e73eea3b (diff)
downloadgtk+-8c73799ca8e170f38eb6afe8604ac5973f6bf141.tar.gz
stylecontext: Move relevant_changes tracking to GtkCssWidgetNode
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkcsswidgetnode.c18
-rw-r--r--gtk/gtkcsswidgetnodeprivate.h12
-rw-r--r--gtk/gtkstylecontext.c52
-rw-r--r--gtk/gtkstylecontextprivate.h4
4 files changed, 47 insertions, 39 deletions
diff --git a/gtk/gtkcsswidgetnode.c b/gtk/gtkcsswidgetnode.c
index 0a4b17bbcc..dd0a105045 100644
--- a/gtk/gtkcsswidgetnode.c
+++ b/gtk/gtkcsswidgetnode.c
@@ -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;
+}
+
diff --git a/gtk/gtkcsswidgetnodeprivate.h b/gtk/gtkcsswidgetnodeprivate.h
index 78c4337fd3..29286538dc 100644
--- a/gtk/gtkcsswidgetnodeprivate.h
+++ b/gtk/gtkcsswidgetnodeprivate.h
@@ -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
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 04591121ef..3b5e4cd07c 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -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);
@@ -2978,16 +2976,6 @@ _gtk_style_context_validate (GtkStyleContext *context,
}
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)
{
diff --git a/gtk/gtkstylecontextprivate.h b/gtk/gtkstylecontextprivate.h
index 59abbc673c..69996243e8 100644
--- a/gtk/gtkstylecontextprivate.h
+++ b/gtk/gtkstylecontextprivate.h
@@ -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,