From 496c75617cbf442c57120c31e78b796482ecea3d Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 26 Jun 2024 14:17:13 -0400 Subject: [PATCH] css: Make recomputing animated styles make more sense When we look for what values need recomputing, we also determine what value we are going to use to recompute. For values that contain variables, that is the 'original' value, as returned by gtk_css_style_get_original_value. For values that we recompute because they may contain currentcolor, that is the specified value as returned by gtk_css_animated_style_get_intrinsic_value. The one issue here is that we currently don't preserve currentcolor in the computed value, so recomputing the value does not do us any good in the color case. That will be fixed separately. --- gtk/gtkcssanimatedstyle.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/gtk/gtkcssanimatedstyle.c b/gtk/gtkcssanimatedstyle.c index 0a7ae28ec4..7e2fcdf974 100644 --- a/gtk/gtkcssanimatedstyle.c +++ b/gtk/gtkcssanimatedstyle.c @@ -74,7 +74,6 @@ gtk_css_ ## NAME ## _values_recompute (GtkCssAnimatedStyle *animated, \ GtkCssAnimationChange change) \ { \ GtkCssStyle *style = (GtkCssStyle *)animated; \ - GtkCssValue **values = (GtkCssValue **)((guint8*)(animated->style->NAME) + sizeof (GtkCssValues)); \ int i; \ \ for (i = 0; i < G_N_ELEMENTS (NAME ## _props); i++) \ @@ -82,28 +81,31 @@ gtk_css_ ## NAME ## _values_recompute (GtkCssAnimatedStyle *animated, \ guint id = NAME ## _props[i]; \ GtkCssValue *original, *computed; \ gboolean needs_recompute = FALSE; \ -\ - if (values[i] == NULL) \ - continue; \ \ original = gtk_css_style_get_original_value (style, id); \ - if (original == NULL) \ - continue; \ \ if ((change & GTK_CSS_ANIMATION_CHANGE_VARIABLES) && \ + original && \ gtk_css_value_contains_variables (original)) \ - needs_recompute = TRUE; \ + { \ + needs_recompute = TRUE; \ + } \ \ if ((change & GTK_CSS_ANIMATION_CHANGE_COLOR) && \ property_has_color (id)) \ - needs_recompute = TRUE; \ + { \ + needs_recompute = TRUE; \ + if (original == NULL) \ + original = gtk_css_animated_style_get_intrinsic_value (animated, id); \ + } \ \ if (!needs_recompute) \ continue; \ \ - computed = gtk_css_value_compute (original, \ - id, \ - context); \ + if (original == NULL) \ + continue; \ +\ + computed = gtk_css_value_compute (original, id, context); \ if (computed == NULL) \ continue; \ \