summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk/gtkcssshadowsvalue.c31
-rw-r--r--gtk/gtkcssshadowvalue.c15
2 files changed, 41 insertions, 5 deletions
diff --git a/gtk/gtkcssshadowsvalue.c b/gtk/gtkcssshadowsvalue.c
index 083b536243..b58dde3f11 100644
--- a/gtk/gtkcssshadowsvalue.c
+++ b/gtk/gtkcssshadowsvalue.c
@@ -57,19 +57,40 @@ gtk_css_value_shadows_compute (GtkCssValue *value,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
- GtkCssValue *result;
- guint i;
+ GtkCssValue *result, *tmp;
+ guint i, j;
if (value->len == 0)
return _gtk_css_value_ref (value);
- result = gtk_css_shadows_value_new (value->values, value->len);
+ result = NULL;
for (i = 0; i < value->len; i++)
{
- result->values[i] = _gtk_css_value_compute (value->values[i], property_id, provider, style, parent_style);
+ tmp = _gtk_css_value_compute (value->values[i], property_id, provider, style, parent_style);
+
+ if (result)
+ {
+ result->values[i] = tmp;
+ }
+ else if (tmp != value->values[i])
+ {
+ result = gtk_css_shadows_value_new (value->values, value->len);
+ for (j = 0; j < i; j++)
+ {
+ _gtk_css_value_ref (result->values[j]);
+ }
+ result->values[i] = tmp;
+ }
+ else
+ {
+ _gtk_css_value_unref (tmp);
+ }
}
- return result;
+ if (result != NULL)
+ return result;
+ else
+ return _gtk_css_value_ref (value);
}
static gboolean
diff --git a/gtk/gtkcssshadowvalue.c b/gtk/gtkcssshadowvalue.c
index c06de2d0f1..93b4dcf927 100644
--- a/gtk/gtkcssshadowvalue.c
+++ b/gtk/gtkcssshadowvalue.c
@@ -77,6 +77,21 @@ gtk_css_value_shadow_compute (GtkCssValue *shadow,
spread = _gtk_css_value_compute (shadow->spread, property_id, provider, style, parent_style),
color = _gtk_css_value_compute (shadow->color, property_id, provider, style, parent_style);
+ if (hoffset == shadow->hoffset &&
+ voffset == shadow->voffset &&
+ radius == shadow->radius &&
+ spread == shadow->spread &&
+ color == shadow->color)
+ {
+ _gtk_css_value_unref (hoffset);
+ _gtk_css_value_unref (voffset);
+ _gtk_css_value_unref (radius);
+ _gtk_css_value_unref (spread);
+ _gtk_css_value_unref (color);
+
+ return _gtk_css_value_ref (shadow);
+ }
+
return gtk_css_shadow_value_new (hoffset, voffset, radius, spread, shadow->inset, color);
}