From 60eff87d0884cf5ae7dc0a5de81ab8283d50abc0 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 11 Apr 2012 12:37:44 +0200 Subject: [PATCH] stylecontext: Shuffle around code This has two goals: 1) Move invalidation code out of a nested if branch. Invalidation is actually the most important thing this function does. 2) Have the changes bitmask available. It will needed for invalidate calls to children later. --- gtk/gtkstylecontext.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 73db2846c3..40d24f5ee9 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -2939,6 +2939,7 @@ _gtk_style_context_validate (GtkStyleContext *context, GtkCssChange change) { GtkStyleContextPrivate *priv; + GtkBitmask *changes; GSList *list; g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); @@ -2990,27 +2991,31 @@ _gtk_style_context_validate (GtkStyleContext *context, if (old) { - GtkBitmask *bitmask; - new = style_data_lookup (context)->store; - bitmask = _gtk_css_computed_values_get_difference (new, old); - if (!_gtk_bitmask_is_empty (bitmask)) - gtk_style_context_do_invalidate (context); + changes = _gtk_css_computed_values_get_difference (new, old); - _gtk_bitmask_free (bitmask); g_object_unref (old); } else - gtk_style_context_do_invalidate (context); - + { + changes = _gtk_bitmask_new (); + changes = _gtk_bitmask_invert_range (changes, 0, _gtk_css_style_property_get_n_properties ()); + } } + else + changes = _gtk_bitmask_new (); + + if (!_gtk_bitmask_is_empty (changes)) + gtk_style_context_do_invalidate (context); change = _gtk_css_change_for_child (change); for (list = priv->children; list; list = list->next) { _gtk_style_context_validate (list->data, timestamp, change); } + + _gtk_bitmask_free (changes); } void