diff options
author | Benjamin Otte <otte@redhat.com> | 2014-12-23 08:19:39 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2014-12-23 08:20:54 +0100 |
commit | e0a26eeef041e0e8a89d1824362206de29194555 (patch) | |
tree | 43fc4da541e63ee2f2bcffcd74eee6f68b1c7354 | |
parent | 5b43e372bcd843a83384c3489e5ccdfac23b5432 (diff) | |
download | gtk+-wip/cssstyle.tar.gz |
stylecontext: Fix cache updatingwip/cssstyle
After the parent changes in commit
3a337156d11a86c7a88f1f30a09276fdf6f63008 we need to refresh the cached
styles after the current style. After all, they now depend on the base
style.
-rw-r--r-- | gtk/gtkstylecontext.c | 69 |
1 files changed, 38 insertions, 31 deletions
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 9cb683fe6a..40914f55bb 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -2668,33 +2668,6 @@ gtk_style_context_clear_cache (GtkStyleContext *context) } static void -gtk_style_context_update_cache (GtkStyleContext *context, - const GtkBitmask *parent_changes) -{ - GtkStyleContextPrivate *priv; - GHashTableIter iter; - gpointer key, value; - - if (_gtk_bitmask_is_empty (parent_changes)) - return; - - priv = context->priv; - - g_hash_table_iter_init (&iter, priv->style_values); - while (g_hash_table_iter_next (&iter, &key, &value)) - { - const GtkCssNodeDeclaration *decl = key; - GtkCssStyle *values = value; - - values = update_properties (context, values, decl, parent_changes); - - g_hash_table_iter_replace (&iter, values); - } - - gtk_style_context_clear_property_cache (context); -} - -static void gtk_style_context_do_invalidate (GtkStyleContext *context, const GtkBitmask *changes) { @@ -2734,6 +2707,41 @@ gtk_style_context_style_needs_full_revalidate (GtkCssStyle *style, return FALSE; } +static void +gtk_style_context_update_cache (GtkStyleContext *context, + GtkCssChange change, + const GtkBitmask *parent_changes) +{ + GtkStyleContextPrivate *priv; + GHashTableIter iter; + gpointer key, value; + + if (_gtk_bitmask_is_empty (parent_changes)) + return; + + priv = context->priv; + + g_hash_table_iter_init (&iter, priv->style_values); + while (g_hash_table_iter_next (&iter, &key, &value)) + { + const GtkCssNodeDeclaration *decl = key; + GtkCssStyle *style = value; + + if (gtk_style_context_style_needs_full_revalidate (style, change)) + { + g_hash_table_iter_remove (&iter); + } + else + { + style = update_properties (context, style, decl, parent_changes); + + g_hash_table_iter_replace (&iter, style); + } + } + + gtk_style_context_clear_property_cache (context); +} + static gboolean gtk_style_context_should_create_transitions (GtkStyleContext *context) { @@ -2808,8 +2816,6 @@ _gtk_style_context_validate (GtkStyleContext *context, { GtkCssStyle *values; - gtk_style_context_clear_cache (context); - style_info_set_values (info, NULL); values = style_values_lookup (context); @@ -2827,8 +2833,6 @@ _gtk_style_context_validate (GtkStyleContext *context, } else { - gtk_style_context_update_cache (context, parent_changes); - if (!_gtk_bitmask_is_empty (parent_changes)) { GtkCssStyle *new_values; @@ -2883,6 +2887,9 @@ _gtk_style_context_validate (GtkStyleContext *context, gtk_style_context_do_invalidate (context, changes); change = _gtk_css_change_for_child (change); + + gtk_style_context_update_cache (context, change, changes); + for (list = priv->children; list; list = list->next) { _gtk_style_context_validate (list->data, timestamp, change, changes); |