[gtk/wip/baedert/css-values: 1/2] css: Set the is_computed flag for more values



commit b8bb14d468b8a7cb5e0812644e55e22e5f55bd28
Author: Timm Bäder <mail baedert org>
Date:   Sat Jan 11 13:40:13 2020 +0100

    css: Set the is_computed flag for more values
    
    With these changes, we skip roughly 85% of compute() calls during
    widget-factory startup

 gtk/gtkcssarrayvalue.c          | 17 +++++++--
 gtk/gtkcssbgsizevalue.c         |  2 ++
 gtk/gtkcssbordervalue.c         | 12 +++++++
 gtk/gtkcssdimensionvalue.c      |  7 +++-
 gtk/gtkcsseasevalue.c           |  6 ++--
 gtk/gtkcssenumvalue.c           | 77 +++++++++++++++++++++--------------------
 gtk/gtkcssfiltervalue.c         | 13 ++++++-
 gtk/gtkcssfontfeaturesvalue.c   |  1 +
 gtk/gtkcssfontvariationsvalue.c |  1 +
 gtk/gtkcsspalettevalue.c        |  2 ++
 gtk/gtkcsspositionvalue.c       |  2 ++
 gtk/gtkcssshadowsvalue.c        | 17 +++++++--
 gtk/gtkcssshadowvalue.c         |  5 +++
 gtk/gtkcssstringvalue.c         |  2 ++
 14 files changed, 117 insertions(+), 47 deletions(-)
---
diff --git a/gtk/gtkcssarrayvalue.c b/gtk/gtkcssarrayvalue.c
index d1e162fda9..a76bd954f7 100644
--- a/gtk/gtkcssarrayvalue.c
+++ b/gtk/gtkcssarrayvalue.c
@@ -392,17 +392,28 @@ _gtk_css_array_value_new_from_array (GtkCssValue **values,
                                      guint         n_values)
 {
   GtkCssValue *result;
-           
+  guint i;
+
   g_return_val_if_fail (values != NULL, NULL);
   g_return_val_if_fail (n_values > 0, NULL);
 
   if (n_values == 1)
     return values[0];
-         
+
   result = _gtk_css_value_alloc (&GTK_CSS_VALUE_ARRAY, sizeof (GtkCssValue) + sizeof (GtkCssValue *) * 
(n_values - 1));
   result->n_values = n_values;
   memcpy (&result->values[0], values, sizeof (GtkCssValue *) * n_values);
-            
+
+  result->is_computed = TRUE;
+  for (i = 0; i < n_values; i ++)
+    {
+      if (!gtk_css_value_is_computed (values[i]))
+        {
+          result->is_computed = FALSE;
+          break;
+        }
+    }
+
   return result;
 }
 
diff --git a/gtk/gtkcssbgsizevalue.c b/gtk/gtkcssbgsizevalue.c
index c60a1ed832..eb54840016 100644
--- a/gtk/gtkcssbgsizevalue.c
+++ b/gtk/gtkcssbgsizevalue.c
@@ -179,6 +179,8 @@ _gtk_css_bg_size_value_new (GtkCssValue *x,
   result = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_BG_SIZE);
   result->x = x;
   result->y = y;
+  result->is_computed = (!x || gtk_css_value_is_computed (x)) &&
+                        (!y || gtk_css_value_is_computed (y));
 
   return result;
 }
diff --git a/gtk/gtkcssbordervalue.c b/gtk/gtkcssbordervalue.c
index b00d674cb0..7e5c32b86b 100644
--- a/gtk/gtkcssbordervalue.c
+++ b/gtk/gtkcssbordervalue.c
@@ -163,6 +163,10 @@ _gtk_css_border_value_new (GtkCssValue *top,
   result->values[GTK_CSS_RIGHT] = right;
   result->values[GTK_CSS_BOTTOM] = bottom;
   result->values[GTK_CSS_LEFT] = left;
+  result->is_computed = (top && gtk_css_value_is_computed (top)) &&
+                        (right && gtk_css_value_is_computed (right)) &&
+                        (bottom && gtk_css_value_is_computed (bottom)) &&
+                        (left && gtk_css_value_is_computed (left));
 
   return result;
 }
@@ -213,6 +217,14 @@ _gtk_css_border_value_parse (GtkCssParser           *parser,
         result->values[i] = _gtk_css_value_ref (result->values[(i - 1) >> 1]);
     }
 
+  result->is_computed = TRUE;
+  for (; i < 4; i++)
+    if (result->values[i] && !gtk_css_value_is_computed (result->values[i]))
+      {
+        result->is_computed = FALSE;
+        break;
+      }
+
   return result;
 }
 
diff --git a/gtk/gtkcssdimensionvalue.c b/gtk/gtkcssdimensionvalue.c
index 0cd79e2b68..e540a7316c 100644
--- a/gtk/gtkcssdimensionvalue.c
+++ b/gtk/gtkcssdimensionvalue.c
@@ -283,7 +283,7 @@ gtk_css_dimension_value_new (double     value,
     { &GTK_CSS_VALUE_DIMENSION.value_class, 1, TRUE, GTK_CSS_PX, 64 },
   };
   static GtkCssValue percent_singletons[] = {
-    { &GTK_CSS_VALUE_DIMENSION.value_class, 1, FALSE, GTK_CSS_PERCENT, 0 },
+    { &GTK_CSS_VALUE_DIMENSION.value_class, 1, TRUE, GTK_CSS_PERCENT, 0 },
     { &GTK_CSS_VALUE_DIMENSION.value_class, 1, FALSE, GTK_CSS_PERCENT, 50 },
     { &GTK_CSS_VALUE_DIMENSION.value_class, 1, FALSE, GTK_CSS_PERCENT, 100 },
   };
@@ -363,6 +363,11 @@ gtk_css_dimension_value_new (double     value,
   result = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_DIMENSION.value_class);
   result->unit = unit;
   result->value = value;
+  result->is_computed = value == 0 ||
+                        unit == GTK_CSS_NUMBER ||
+                        unit == GTK_CSS_PX ||
+                        unit == GTK_CSS_DEG ||
+                        unit == GTK_CSS_S;
 
   return result;
 }
diff --git a/gtk/gtkcsseasevalue.c b/gtk/gtkcsseasevalue.c
index 7e7c6be7bd..5ea1c6285d 100644
--- a/gtk/gtkcsseasevalue.c
+++ b/gtk/gtkcsseasevalue.c
@@ -159,12 +159,13 @@ _gtk_css_ease_value_new_cubic_bezier (double x1,
   g_return_val_if_fail (x2 <= 1.0, NULL);
 
   value = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_EASE);
-  
+
   value->type = GTK_CSS_EASE_CUBIC_BEZIER;
   value->u.cubic.x1 = x1;
   value->u.cubic.y1 = y1;
   value->u.cubic.x2 = x2;
   value->u.cubic.y2 = y2;
+  value->is_computed = TRUE;
 
   return value;
 }
@@ -178,10 +179,11 @@ _gtk_css_ease_value_new_steps (guint n_steps,
   g_return_val_if_fail (n_steps > 0, NULL);
 
   value = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_EASE);
-  
+
   value->type = GTK_CSS_EASE_STEPS;
   value->u.steps.steps = n_steps;
   value->u.steps.start = start;
+  value->is_computed = TRUE;
 
   return value;
 }
diff --git a/gtk/gtkcssenumvalue.c b/gtk/gtkcssenumvalue.c
index 90e84834b4..d558964fc9 100644
--- a/gtk/gtkcssenumvalue.c
+++ b/gtk/gtkcssenumvalue.c
@@ -355,9 +355,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_STYLE = {
 };
 
 static GtkCssValue font_style_values[] = {
-  { &GTK_CSS_VALUE_FONT_STYLE, 1, FALSE, PANGO_STYLE_NORMAL, "normal" },
-  { &GTK_CSS_VALUE_FONT_STYLE, 1, FALSE, PANGO_STYLE_OBLIQUE, "oblique" },
-  { &GTK_CSS_VALUE_FONT_STYLE, 1, FALSE, PANGO_STYLE_ITALIC, "italic" }
+  { &GTK_CSS_VALUE_FONT_STYLE, 1, TRUE, PANGO_STYLE_NORMAL, "normal" },
+  { &GTK_CSS_VALUE_FONT_STYLE, 1, TRUE, PANGO_STYLE_OBLIQUE, "oblique" },
+  { &GTK_CSS_VALUE_FONT_STYLE, 1, TRUE, PANGO_STYLE_ITALIC, "italic" }
 };
 
 GtkCssValue *
@@ -504,15 +504,15 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_STRETCH = {
 };
 
 static GtkCssValue font_stretch_values[] = {
-  { &GTK_CSS_VALUE_FONT_STRETCH, 1, FALSE, PANGO_STRETCH_ULTRA_CONDENSED, "ultra-condensed" },
-  { &GTK_CSS_VALUE_FONT_STRETCH, 1, FALSE, PANGO_STRETCH_EXTRA_CONDENSED, "extra-condensed" },
-  { &GTK_CSS_VALUE_FONT_STRETCH, 1, FALSE, PANGO_STRETCH_CONDENSED, "condensed" },
-  { &GTK_CSS_VALUE_FONT_STRETCH, 1, FALSE, PANGO_STRETCH_SEMI_CONDENSED, "semi-condensed" },
-  { &GTK_CSS_VALUE_FONT_STRETCH, 1, FALSE, PANGO_STRETCH_NORMAL, "normal" },
-  { &GTK_CSS_VALUE_FONT_STRETCH, 1, FALSE, PANGO_STRETCH_SEMI_EXPANDED, "semi-expanded" },
-  { &GTK_CSS_VALUE_FONT_STRETCH, 1, FALSE, PANGO_STRETCH_EXPANDED, "expanded" },
-  { &GTK_CSS_VALUE_FONT_STRETCH, 1, FALSE, PANGO_STRETCH_EXTRA_EXPANDED, "extra-expanded" },
-  { &GTK_CSS_VALUE_FONT_STRETCH, 1, FALSE, PANGO_STRETCH_ULTRA_EXPANDED, "ultra-expanded" },
+  { &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_ULTRA_CONDENSED, "ultra-condensed" },
+  { &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_EXTRA_CONDENSED, "extra-condensed" },
+  { &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_CONDENSED, "condensed" },
+  { &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_SEMI_CONDENSED, "semi-condensed" },
+  { &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_NORMAL, "normal" },
+  { &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_SEMI_EXPANDED, "semi-expanded" },
+  { &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_EXPANDED, "expanded" },
+  { &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_EXTRA_EXPANDED, "extra-expanded" },
+  { &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_ULTRA_EXPANDED, "ultra-expanded" },
 };
 
 GtkCssValue *
@@ -561,9 +561,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_TEXT_DECORATION_LINE = {
 };
 
 static GtkCssValue text_decoration_line_values[] = {
-  { &GTK_CSS_VALUE_TEXT_DECORATION_LINE, 1, FALSE, GTK_CSS_TEXT_DECORATION_LINE_NONE, "none" },
-  { &GTK_CSS_VALUE_TEXT_DECORATION_LINE, 1, FALSE, GTK_CSS_TEXT_DECORATION_LINE_UNDERLINE, "underline" },
-  { &GTK_CSS_VALUE_TEXT_DECORATION_LINE, 1, FALSE, GTK_CSS_TEXT_DECORATION_LINE_LINE_THROUGH, "line-through" 
},
+  { &GTK_CSS_VALUE_TEXT_DECORATION_LINE, 1, TRUE, GTK_CSS_TEXT_DECORATION_LINE_NONE, "none" },
+  { &GTK_CSS_VALUE_TEXT_DECORATION_LINE, 1, TRUE, GTK_CSS_TEXT_DECORATION_LINE_UNDERLINE, "underline" },
+  { &GTK_CSS_VALUE_TEXT_DECORATION_LINE, 1, TRUE, GTK_CSS_TEXT_DECORATION_LINE_LINE_THROUGH, "line-through" 
},
 };
 
 GtkCssValue *
@@ -612,9 +612,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_TEXT_DECORATION_STYLE = {
 };
 
 static GtkCssValue text_decoration_style_values[] = {
-  { &GTK_CSS_VALUE_TEXT_DECORATION_STYLE, 1, FALSE, GTK_CSS_TEXT_DECORATION_STYLE_SOLID, "solid" },
-  { &GTK_CSS_VALUE_TEXT_DECORATION_STYLE, 1, FALSE, GTK_CSS_TEXT_DECORATION_STYLE_DOUBLE, "double" },
-  { &GTK_CSS_VALUE_TEXT_DECORATION_STYLE, 1, FALSE, GTK_CSS_TEXT_DECORATION_STYLE_WAVY, "wavy" },
+  { &GTK_CSS_VALUE_TEXT_DECORATION_STYLE, 1, TRUE, GTK_CSS_TEXT_DECORATION_STYLE_SOLID, "solid" },
+  { &GTK_CSS_VALUE_TEXT_DECORATION_STYLE, 1, TRUE, GTK_CSS_TEXT_DECORATION_STYLE_DOUBLE, "double" },
+  { &GTK_CSS_VALUE_TEXT_DECORATION_STYLE, 1, TRUE, GTK_CSS_TEXT_DECORATION_STYLE_WAVY, "wavy" },
 };
 
 GtkCssValue *
@@ -720,10 +720,10 @@ static const GtkCssValueClass GTK_CSS_VALUE_DIRECTION = {
 };
 
 static GtkCssValue direction_values[] = {
-  { &GTK_CSS_VALUE_DIRECTION, 1, FALSE, GTK_CSS_DIRECTION_NORMAL, "normal" },
-  { &GTK_CSS_VALUE_DIRECTION, 1, FALSE, GTK_CSS_DIRECTION_REVERSE, "reverse" },
-  { &GTK_CSS_VALUE_DIRECTION, 1, FALSE, GTK_CSS_DIRECTION_ALTERNATE, "alternate" },
-  { &GTK_CSS_VALUE_DIRECTION, 1, FALSE, GTK_CSS_DIRECTION_ALTERNATE_REVERSE, "alternate-reverse" }
+  { &GTK_CSS_VALUE_DIRECTION, 1, TRUE, GTK_CSS_DIRECTION_NORMAL, "normal" },
+  { &GTK_CSS_VALUE_DIRECTION, 1, TRUE, GTK_CSS_DIRECTION_REVERSE, "reverse" },
+  { &GTK_CSS_VALUE_DIRECTION, 1, TRUE, GTK_CSS_DIRECTION_ALTERNATE, "alternate" },
+  { &GTK_CSS_VALUE_DIRECTION, 1, TRUE, GTK_CSS_DIRECTION_ALTERNATE_REVERSE, "alternate-reverse" }
 };
 
 GtkCssValue *
@@ -952,9 +952,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_KERNING = {
 };
 
 static GtkCssValue font_kerning_values[] = {
-  { &GTK_CSS_VALUE_FONT_KERNING, 1, FALSE, GTK_CSS_FONT_KERNING_AUTO, "auto" },
-  { &GTK_CSS_VALUE_FONT_KERNING, 1, FALSE, GTK_CSS_FONT_KERNING_NORMAL, "normal" },
-  { &GTK_CSS_VALUE_FONT_KERNING, 1, FALSE, GTK_CSS_FONT_KERNING_NONE, "none" }
+  { &GTK_CSS_VALUE_FONT_KERNING, 1, TRUE, GTK_CSS_FONT_KERNING_AUTO, "auto" },
+  { &GTK_CSS_VALUE_FONT_KERNING, 1, TRUE, GTK_CSS_FONT_KERNING_NORMAL, "normal" },
+  { &GTK_CSS_VALUE_FONT_KERNING, 1, TRUE, GTK_CSS_FONT_KERNING_NONE, "none" }
 };
 
 GtkCssValue *
@@ -1009,9 +1009,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_VARIANT_POSITION = {
 };
 
 static GtkCssValue font_variant_position_values[] = {
-  { &GTK_CSS_VALUE_FONT_VARIANT_POSITION, 1, FALSE, GTK_CSS_FONT_VARIANT_POSITION_NORMAL, "normal" },
-  { &GTK_CSS_VALUE_FONT_VARIANT_POSITION, 1, FALSE, GTK_CSS_FONT_VARIANT_POSITION_SUB, "sub" },
-  { &GTK_CSS_VALUE_FONT_VARIANT_POSITION, 1, FALSE, GTK_CSS_FONT_VARIANT_POSITION_SUPER, "super" }
+  { &GTK_CSS_VALUE_FONT_VARIANT_POSITION, 1, TRUE, GTK_CSS_FONT_VARIANT_POSITION_NORMAL, "normal" },
+  { &GTK_CSS_VALUE_FONT_VARIANT_POSITION, 1, TRUE, GTK_CSS_FONT_VARIANT_POSITION_SUB, "sub" },
+  { &GTK_CSS_VALUE_FONT_VARIANT_POSITION, 1, TRUE, GTK_CSS_FONT_VARIANT_POSITION_SUPER, "super" }
 };
 
 GtkCssValue *
@@ -1066,13 +1066,13 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_VARIANT_CAPS = {
 };
 
 static GtkCssValue font_variant_caps_values[] = {
-  { &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, FALSE, GTK_CSS_FONT_VARIANT_CAPS_NORMAL, "normal" },
-  { &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, FALSE, GTK_CSS_FONT_VARIANT_CAPS_SMALL_CAPS, "small-caps" },
-  { &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, FALSE, GTK_CSS_FONT_VARIANT_CAPS_ALL_SMALL_CAPS, "all-small-caps" },
-  { &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, FALSE, GTK_CSS_FONT_VARIANT_CAPS_PETITE_CAPS, "petite-caps" },
-  { &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, FALSE, GTK_CSS_FONT_VARIANT_CAPS_ALL_PETITE_CAPS, "all-petite-caps" 
},
-  { &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, FALSE, GTK_CSS_FONT_VARIANT_CAPS_UNICASE, "unicase" },
-  { &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, FALSE, GTK_CSS_FONT_VARIANT_CAPS_TITLING_CAPS, "titling-caps" }
+  { &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, GTK_CSS_FONT_VARIANT_CAPS_NORMAL, "normal" },
+  { &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, GTK_CSS_FONT_VARIANT_CAPS_SMALL_CAPS, "small-caps" },
+  { &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, GTK_CSS_FONT_VARIANT_CAPS_ALL_SMALL_CAPS, "all-small-caps" },
+  { &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, GTK_CSS_FONT_VARIANT_CAPS_PETITE_CAPS, "petite-caps" },
+  { &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, GTK_CSS_FONT_VARIANT_CAPS_ALL_PETITE_CAPS, "all-petite-caps" 
},
+  { &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, GTK_CSS_FONT_VARIANT_CAPS_UNICASE, "unicase" },
+  { &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, GTK_CSS_FONT_VARIANT_CAPS_TITLING_CAPS, "titling-caps" }
 };
 
 GtkCssValue *
@@ -1127,8 +1127,8 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_VARIANT_ALTERNATE = {
 };
 
 static GtkCssValue font_variant_alternate_values[] = {
-  { &GTK_CSS_VALUE_FONT_VARIANT_ALTERNATE, 1, FALSE, GTK_CSS_FONT_VARIANT_ALTERNATE_NORMAL, "normal" },
-  { &GTK_CSS_VALUE_FONT_VARIANT_ALTERNATE, 1, FALSE, GTK_CSS_FONT_VARIANT_ALTERNATE_HISTORICAL_FORMS, 
"historical-forms" }
+  { &GTK_CSS_VALUE_FONT_VARIANT_ALTERNATE, 1, TRUE, GTK_CSS_FONT_VARIANT_ALTERNATE_NORMAL, "normal" },
+  { &GTK_CSS_VALUE_FONT_VARIANT_ALTERNATE, 1, TRUE, GTK_CSS_FONT_VARIANT_ALTERNATE_HISTORICAL_FORMS, 
"historical-forms" }
 };
 
 GtkCssValue *
@@ -1271,6 +1271,7 @@ _gtk_css_font_variant_ligature_value_new (GtkCssFontVariantLigature ligatures)
   value = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_FONT_VARIANT_LIGATURE);
   value->value = ligatures;
   value->name = NULL;
+  value->is_computed = TRUE;
 
   return value;
 }
@@ -1374,6 +1375,7 @@ _gtk_css_font_variant_numeric_value_new (GtkCssFontVariantNumeric numeric)
   value = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_FONT_VARIANT_NUMERIC);
   value->value = numeric;
   value->name = NULL;
+  value->is_computed = TRUE;
 
   return value;
 }
@@ -1517,6 +1519,7 @@ _gtk_css_font_variant_east_asian_value_new (GtkCssFontVariantEastAsian east_asia
   value = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_FONT_VARIANT_EAST_ASIAN);
   value->value = east_asian;
   value->name = NULL;
+  value->is_computed = TRUE;
 
   return value;
 }
diff --git a/gtk/gtkcssfiltervalue.c b/gtk/gtkcssfiltervalue.c
index 8129cf971c..453803000e 100644
--- a/gtk/gtkcssfiltervalue.c
+++ b/gtk/gtkcssfiltervalue.c
@@ -778,6 +778,7 @@ gtk_css_filter_value_parse (GtkCssParser *parser)
   GtkCssValue *value;
   GArray *array;
   guint i;
+  gboolean computed = TRUE;
 
   if (gtk_css_parser_try_ident (parser, "none"))
     return gtk_css_filter_value_new_none ();
@@ -794,6 +795,7 @@ gtk_css_filter_value_parse (GtkCssParser *parser)
             goto fail;
 
           filter.type = GTK_CSS_FILTER_BLUR;
+          computed = computed && gtk_css_value_is_computed (filter.blur.value);
         }
       else if (gtk_css_parser_has_function (parser, "brightness"))
         {
@@ -801,6 +803,7 @@ gtk_css_filter_value_parse (GtkCssParser *parser)
             goto fail;
 
           filter.type = GTK_CSS_FILTER_BRIGHTNESS;
+          computed = computed && gtk_css_value_is_computed (filter.brightness.value);
         }
       else if (gtk_css_parser_has_function (parser, "contrast"))
         {
@@ -808,6 +811,7 @@ gtk_css_filter_value_parse (GtkCssParser *parser)
             goto fail;
 
           filter.type = GTK_CSS_FILTER_CONTRAST;
+          computed = computed && gtk_css_value_is_computed (filter.contrast.value);
         }
       else if (gtk_css_parser_has_function (parser, "grayscale"))
         {
@@ -815,13 +819,15 @@ gtk_css_filter_value_parse (GtkCssParser *parser)
             goto fail;
 
           filter.type = GTK_CSS_FILTER_GRAYSCALE;
+          computed = computed && gtk_css_value_is_computed (filter.grayscale.value);
         }
       else if (gtk_css_parser_has_function (parser, "hue-rotate"))
         {
-          if (!gtk_css_parser_consume_function (parser, 1, 1, gtk_css_filter_parse_angle, 
&filter.blur.value))
+          if (!gtk_css_parser_consume_function (parser, 1, 1, gtk_css_filter_parse_angle, 
&filter.hue_rotate.value))
             goto fail;
 
           filter.type = GTK_CSS_FILTER_HUE_ROTATE;
+          computed = computed && gtk_css_value_is_computed (filter.hue_rotate.value);
         }
       else if (gtk_css_parser_has_function (parser, "invert"))
         {
@@ -829,6 +835,7 @@ gtk_css_filter_value_parse (GtkCssParser *parser)
             goto fail;
 
           filter.type = GTK_CSS_FILTER_INVERT;
+          computed = computed && gtk_css_value_is_computed (filter.invert.value);
         }
       else if (gtk_css_parser_has_function (parser, "opacity"))
         {
@@ -836,6 +843,7 @@ gtk_css_filter_value_parse (GtkCssParser *parser)
             goto fail;
 
           filter.type = GTK_CSS_FILTER_OPACITY;
+          computed = computed && gtk_css_value_is_computed (filter.opacity.value);
         }
       else if (gtk_css_parser_has_function (parser, "saturate"))
         {
@@ -843,6 +851,7 @@ gtk_css_filter_value_parse (GtkCssParser *parser)
             goto fail;
 
           filter.type = GTK_CSS_FILTER_SATURATE;
+          computed = computed && gtk_css_value_is_computed (filter.saturate.value);
         }
       else if (gtk_css_parser_has_function (parser, "sepia"))
         {
@@ -850,6 +859,7 @@ gtk_css_filter_value_parse (GtkCssParser *parser)
             goto fail;
 
           filter.type = GTK_CSS_FILTER_SEPIA;
+          computed = computed && gtk_css_value_is_computed (filter.sepia.value);
         }
       else
         {
@@ -867,6 +877,7 @@ gtk_css_filter_value_parse (GtkCssParser *parser)
 
   value = gtk_css_filter_value_alloc (array->len);
   memcpy (value->filters, array->data, sizeof (GtkCssFilter) * array->len);
+  value->is_computed = computed;
 
   g_array_free (array, TRUE);
 
diff --git a/gtk/gtkcssfontfeaturesvalue.c b/gtk/gtkcssfontfeaturesvalue.c
index f42b7ec212..9e1b0ad267 100644
--- a/gtk/gtkcssfontfeaturesvalue.c
+++ b/gtk/gtkcssfontfeaturesvalue.c
@@ -173,6 +173,7 @@ gtk_css_font_features_value_new_empty (void)
   result->features = g_hash_table_new_full (g_str_hash, g_str_equal,
                                         g_free,
                                         (GDestroyNotify) _gtk_css_value_unref);
+  result->is_computed = TRUE;
 
   return result;
 }
diff --git a/gtk/gtkcssfontvariationsvalue.c b/gtk/gtkcssfontvariationsvalue.c
index a803458cad..174cacf417 100644
--- a/gtk/gtkcssfontvariationsvalue.c
+++ b/gtk/gtkcssfontvariationsvalue.c
@@ -173,6 +173,7 @@ gtk_css_font_variations_value_new_empty (void)
   result->axes = g_hash_table_new_full (g_str_hash, g_str_equal,
                                         g_free,
                                         (GDestroyNotify) _gtk_css_value_unref);
+  result->is_computed = TRUE;
 
   return result;
 }
diff --git a/gtk/gtkcsspalettevalue.c b/gtk/gtkcsspalettevalue.c
index e7daca9a74..8245be9123 100644
--- a/gtk/gtkcsspalettevalue.c
+++ b/gtk/gtkcsspalettevalue.c
@@ -326,6 +326,8 @@ gtk_css_palette_value_parse (GtkCssParser *parser)
         return NULL;
       }
 
+    result->is_computed = result->is_computed && gtk_css_value_is_computed (color);
+
     g_ptr_array_add (names, ident);
     g_ptr_array_add (colors, color);
   } while (gtk_css_parser_try_token (parser, GTK_CSS_TOKEN_COMMA));
diff --git a/gtk/gtkcsspositionvalue.c b/gtk/gtkcsspositionvalue.c
index 853158a056..4164d18ca2 100644
--- a/gtk/gtkcsspositionvalue.c
+++ b/gtk/gtkcsspositionvalue.c
@@ -169,6 +169,8 @@ _gtk_css_position_value_new (GtkCssValue *x,
   result = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_POSITION);
   result->x = x;
   result->y = y;
+  result->is_computed = gtk_css_value_is_computed (x) &&
+                        gtk_css_value_is_computed (y);
 
   return result;
 }
diff --git a/gtk/gtkcssshadowsvalue.c b/gtk/gtkcssshadowsvalue.c
index 92bac77d9b..e5484e1a8c 100644
--- a/gtk/gtkcssshadowsvalue.c
+++ b/gtk/gtkcssshadowsvalue.c
@@ -223,14 +223,25 @@ gtk_css_shadows_value_new (GtkCssValue **values,
                            guint         len)
 {
   GtkCssValue *result;
-           
+  guint i;
+
   g_return_val_if_fail (values != NULL, NULL);
   g_return_val_if_fail (len > 0, NULL);
-         
+
   result = _gtk_css_value_alloc (&GTK_CSS_VALUE_SHADOWS, sizeof (GtkCssValue) + sizeof (GtkCssValue *) * 
(len - 1));
   result->len = len;
   memcpy (&result->values[0], values, sizeof (GtkCssValue *) * len);
-            
+
+  result->is_computed = TRUE;
+  for (i = 0; i < len; i++)
+    {
+      if (!gtk_css_value_is_computed (values[i]))
+        {
+          result->is_computed = FALSE;
+          break;
+        }
+    }
+
   return result;
 }
 
diff --git a/gtk/gtkcssshadowvalue.c b/gtk/gtkcssshadowvalue.c
index 709aff4023..cc123dc8cc 100644
--- a/gtk/gtkcssshadowvalue.c
+++ b/gtk/gtkcssshadowvalue.c
@@ -183,6 +183,11 @@ gtk_css_shadow_value_new (GtkCssValue *hoffset,
   retval->spread = spread;
   retval->inset = inset;
   retval->color = color;
+  retval->is_computed = gtk_css_value_is_computed (hoffset) &&
+                        gtk_css_value_is_computed (voffset) &&
+                        gtk_css_value_is_computed (radius) &&
+                        gtk_css_value_is_computed (spread) &&
+                        gtk_css_value_is_computed (color);
 
   return retval;
 }
diff --git a/gtk/gtkcssstringvalue.c b/gtk/gtkcssstringvalue.c
index 286b86e0d9..c211c33afa 100644
--- a/gtk/gtkcssstringvalue.c
+++ b/gtk/gtkcssstringvalue.c
@@ -151,6 +151,7 @@ _gtk_css_string_value_new_take (char *string)
 
   result = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_STRING);
   result->string = string;
+  result->is_computed = TRUE;
 
   return result;
 }
@@ -191,6 +192,7 @@ _gtk_css_ident_value_new_take (char *ident)
 
   result = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_IDENT);
   result->string = ident;
+  result->is_computed = TRUE;
 
   return result;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]