From c38095faed24bd168916a720ade9071a629e5b34 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 11 Oct 2014 20:02:27 +0200 Subject: [PATCH] stylecontext: Don't cache the root values Those are the ones that are special and get animated. Caching them only causes confusion. --- gtk/gtkstylecontext.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index e48aedd88a..5705ec6b74 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -704,6 +704,17 @@ gtk_style_context_impl_get_property (GObject *object, } } +/* returns TRUE if someone called gtk_style_context_save() but hasn’t + * called gtk_style_context_restore() yet. + * In those situations we don’t invalidate the context when somebody + * changes state/regions/classes. + */ +static gboolean +gtk_style_context_is_saved (GtkStyleContext *context) +{ + return context->priv->info->next != NULL; +} + static void style_info_add_to_widget_path (GtkStyleInfo *info, GtkWidgetPath *path, @@ -810,13 +821,17 @@ style_values_lookup (GtkStyleContext *context) } values = _gtk_css_computed_values_new (); - style_info_set_values (info, values); - g_hash_table_insert (priv->style_values, - style_info_copy (info), - values); + style_info_set_values (info, values); + if (gtk_style_context_is_saved (context)) + g_hash_table_insert (priv->style_values, + style_info_copy (info), + g_object_ref (values)); + build_properties (context, values, info, NULL); + g_object_unref (values); + return values; } @@ -861,17 +876,6 @@ gtk_style_context_set_invalid (GtkStyleContext *context, } } -/* returns TRUE if someone called gtk_style_context_save() but hasn’t - * called gtk_style_context_restore() yet. - * In those situations we don’t invalidate the context when somebody - * changes state/regions/classes. - */ -static gboolean -gtk_style_context_is_saved (GtkStyleContext *context) -{ - return context->priv->info->next != NULL; -} - static void gtk_style_context_queue_invalidate_internal (GtkStyleContext *context, GtkCssChange change) @@ -3080,10 +3084,6 @@ _gtk_style_context_validate (GtkStyleContext *context, if (current) { changes = _gtk_css_computed_values_get_difference (values, current); - - /* In the case where we keep the cache, we want unanimated values */ - if (values != current) - _gtk_css_computed_values_cancel_animations (current); } else { @@ -3094,6 +3094,8 @@ _gtk_style_context_validate (GtkStyleContext *context, else { changes = _gtk_css_computed_values_compute_dependencies (current, parent_changes); + if (!_gtk_bitmask_is_empty (changes)) + build_properties (context, current, info, changes); gtk_style_context_update_cache (context, parent_changes); }