summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2012-07-11 06:56:07 +0200
committerBenjamin Otte <otte@redhat.com>2012-08-28 15:40:56 +0200
commit9b953829fbf1332d00c2ca8a99c7da5e4bda8c64 (patch)
treed11d83a1dbe54909d5ee729a77b55bfa4393649d
parent3f00801e9aedd971378a6aad70e945903db7a798 (diff)
downloadgtk+-9b953829fbf1332d00c2ca8a99c7da5e4bda8c64.tar.gz
css: Introduce _gtk_css_value_compute()
This commit is essentially a large reorganization. Instead of all value subtypes having their own compute function, there is the general _gtk_css_value_compute() function that then calls a vfunc on the subtype.
-rw-r--r--gtk/gtkcssarrayvalue.c59
-rw-r--r--gtk/gtkcssarrayvalueprivate.h3
-rw-r--r--gtk/gtkcssbgsizevalue.c25
-rw-r--r--gtk/gtkcssbgsizevalueprivate.h2
-rw-r--r--gtk/gtkcssbordervalue.c61
-rw-r--r--gtk/gtkcssbordervalueprivate.h3
-rw-r--r--gtk/gtkcsscornervalue.c39
-rw-r--r--gtk/gtkcsscornervalueprivate.h2
-rw-r--r--gtk/gtkcsseasevalue.c8
-rw-r--r--gtk/gtkcssenginevalue.c8
-rw-r--r--gtk/gtkcssenumvalue.c12
-rw-r--r--gtk/gtkcssimagelinear.c4
-rw-r--r--gtk/gtkcssimagevalue.c23
-rw-r--r--gtk/gtkcssinheritvalue.c9
-rw-r--r--gtk/gtkcssinitialvalue.c9
-rw-r--r--gtk/gtkcssnumbervalue.c121
-rw-r--r--gtk/gtkcssnumbervalueprivate.h2
-rw-r--r--gtk/gtkcsspositionvalue.c39
-rw-r--r--gtk/gtkcsspositionvalueprivate.h2
-rw-r--r--gtk/gtkcssrepeatvalue.c9
-rw-r--r--gtk/gtkcssrgbavalue.c8
-rw-r--r--gtk/gtkcssshadowsvalue.c41
-rw-r--r--gtk/gtkcssshadowsvalueprivate.h3
-rw-r--r--gtk/gtkcssshadowvalue.c45
-rw-r--r--gtk/gtkcssshadowvalueprivate.h3
-rw-r--r--gtk/gtkcssstringvalue.c9
-rw-r--r--gtk/gtkcssstylepropertyimpl.c46
-rw-r--r--gtk/gtkcsstypedvalue.c8
-rw-r--r--gtk/gtkcssvalue.c10
-rw-r--r--gtk/gtkcssvalueprivate.h5
-rw-r--r--gtk/gtksymboliccolor.c12
31 files changed, 355 insertions, 275 deletions
diff --git a/gtk/gtkcssarrayvalue.c b/gtk/gtkcssarrayvalue.c
index 4a52ef84db..985d195762 100644
--- a/gtk/gtkcssarrayvalue.c
+++ b/gtk/gtkcssarrayvalue.c
@@ -40,6 +40,33 @@ gtk_css_value_array_free (GtkCssValue *value)
g_slice_free1 (sizeof (GtkCssValue) + sizeof (GtkCssValue *) * (value->n_values - 1), value);
}
+static GtkCssValue *
+gtk_css_value_array_compute (GtkCssValue *value,
+ GtkStyleContext *context)
+{
+ GtkCssValue *result;
+ gboolean changed = FALSE;
+ guint i;
+
+ if (value->n_values == 0)
+ return _gtk_css_value_ref (value);
+
+ result = _gtk_css_array_value_new_from_array (value->values, value->n_values);
+ for (i = 0; i < value->n_values; i++)
+ {
+ result->values[i] = _gtk_css_value_compute (value->values[i], context);
+ changed |= (result->values[i] != value->values[i]);
+ }
+
+ if (!changed)
+ {
+ _gtk_css_value_unref (result);
+ return _gtk_css_value_ref (value);
+ }
+
+ return result;
+}
+
static gboolean
gtk_css_value_array_equal (const GtkCssValue *value1,
const GtkCssValue *value2)
@@ -89,6 +116,7 @@ gtk_css_value_array_print (const GtkCssValue *value,
static const GtkCssValueClass GTK_CSS_VALUE_ARRAY = {
gtk_css_value_array_free,
+ gtk_css_value_array_compute,
gtk_css_value_array_equal,
gtk_css_value_array_transition,
gtk_css_value_array_print
@@ -154,37 +182,6 @@ _gtk_css_array_value_parse (GtkCssParser *parser,
}
GtkCssValue *
-_gtk_css_array_value_compute (GtkCssValue *value,
- GtkCssValue * (* compute_func) (GtkCssValue *, GtkStyleContext *),
- GtkStyleContext *context)
-{
- GtkCssValue *result;
- gboolean changed = FALSE;
- guint i;
-
- g_return_val_if_fail (value->class == &GTK_CSS_VALUE_ARRAY, NULL);
- g_return_val_if_fail (compute_func != NULL, NULL);
-
- if (value->n_values == 0)
- return _gtk_css_value_ref (value);
-
- result = _gtk_css_array_value_new_from_array (value->values, value->n_values);
- for (i = 0; i < value->n_values; i++)
- {
- result->values[i] = (* compute_func) (value->values[i], context);
- changed |= (result->values[i] != value->values[i]);
- }
-
- if (!changed)
- {
- _gtk_css_value_unref (result);
- return _gtk_css_value_ref (value);
- }
-
- return result;
-}
-
-GtkCssValue *
_gtk_css_array_value_get_nth (const GtkCssValue *value,
guint i)
{
diff --git a/gtk/gtkcssarrayvalueprivate.h b/gtk/gtkcssarrayvalueprivate.h
index ad3ae3c428..3c0277c2a2 100644
--- a/gtk/gtkcssarrayvalueprivate.h
+++ b/gtk/gtkcssarrayvalueprivate.h
@@ -33,9 +33,6 @@ GtkCssValue * _gtk_css_array_value_parse (GtkCssParser *
GtkCssValue * (* parse_func) (GtkCssParser *),
gboolean allow_none);
-GtkCssValue * _gtk_css_array_value_compute (GtkCssValue *value,
- GtkCssValue * (* compute_func) (GtkCssValue *, GtkStyleContext *),
- GtkStyleContext *context);
GtkCssValue * _gtk_css_array_value_get_nth (const GtkCssValue *value,
guint i);
guint _gtk_css_array_value_get_n_values (const GtkCssValue *value);
diff --git a/gtk/gtkcssbgsizevalue.c b/gtk/gtkcssbgsizevalue.c
index 24e0fae039..2ba0eb110a 100644
--- a/gtk/gtkcssbgsizevalue.c
+++ b/gtk/gtkcssbgsizevalue.c
@@ -40,6 +40,17 @@ gtk_css_value_bg_size_free (GtkCssValue *value)
g_slice_free (GtkCssValue, value);
}
+GtkCssValue *
+gtk_css_value_bg_size_compute (GtkCssValue *value,
+ GtkStyleContext *context)
+{
+ if (value->x == NULL && value->y == NULL)
+ return _gtk_css_value_ref (value);
+
+ return _gtk_css_bg_size_value_new (value->x ? _gtk_css_value_compute (value->x, context) : NULL,
+ value->y ? _gtk_css_value_compute (value->y, context) : NULL);
+}
+
static gboolean
gtk_css_value_bg_size_equal (const GtkCssValue *value1,
const GtkCssValue *value2)
@@ -119,6 +130,7 @@ gtk_css_value_bg_size_print (const GtkCssValue *value,
static const GtkCssValueClass GTK_CSS_VALUE_BG_SIZE = {
gtk_css_value_bg_size_free,
+ gtk_css_value_bg_size_compute,
gtk_css_value_bg_size_equal,
gtk_css_value_bg_size_transition,
gtk_css_value_bg_size_print
@@ -243,16 +255,3 @@ _gtk_css_bg_size_value_compute_size (const GtkCssValue *value,
out_width, out_height);
}
-GtkCssValue *
-_gtk_css_bg_size_value_compute (GtkCssValue *value,
- GtkStyleContext *context)
-{
- g_return_val_if_fail (value->class == &GTK_CSS_VALUE_BG_SIZE, NULL);
-
- if (value->x == NULL && value->y == NULL)
- return _gtk_css_value_ref (value);
-
- return _gtk_css_bg_size_value_new (value->x ? _gtk_css_number_value_compute (value->x, context) : NULL,
- value->y ? _gtk_css_number_value_compute (value->y, context) : NULL);
-}
-
diff --git a/gtk/gtkcssbgsizevalueprivate.h b/gtk/gtkcssbgsizevalueprivate.h
index cae8d13285..5f31ff2208 100644
--- a/gtk/gtkcssbgsizevalueprivate.h
+++ b/gtk/gtkcssbgsizevalueprivate.h
@@ -36,8 +36,6 @@ void _gtk_css_bg_size_value_compute_size (const GtkCssValue *bg_
double area_height,
double *out_width,
double *out_height);
-GtkCssValue * _gtk_css_bg_size_value_compute (GtkCssValue *bg_size,
- GtkStyleContext *context);
G_END_DECLS
diff --git a/gtk/gtkcssbordervalue.c b/gtk/gtkcssbordervalue.c
index 92ae98a9c6..53ba12fcbe 100644
--- a/gtk/gtkcssbordervalue.c
+++ b/gtk/gtkcssbordervalue.c
@@ -41,6 +41,35 @@ gtk_css_value_border_free (GtkCssValue *value)
g_slice_free (GtkCssValue, value);
}
+static GtkCssValue *
+gtk_css_value_border_compute (GtkCssValue *value,
+ GtkStyleContext *context)
+{
+ GtkCssValue *computed;
+ gboolean changed = FALSE;
+ guint i;
+
+ computed = _gtk_css_border_value_new (NULL, NULL, NULL, NULL);
+ computed->fill = value->fill;
+
+ for (i = 0; i < 4; i++)
+ {
+ if (value->values[i])
+ {
+ computed->values[i] = _gtk_css_value_compute (value->values[i], context);
+ changed |= (computed->values[i] != value->values[i]);
+ }
+ }
+
+ if (!changed)
+ {
+ _gtk_css_value_unref (computed);
+ return _gtk_css_value_ref (value);
+ }
+
+ return computed;
+}
+
static gboolean
gtk_css_value_border_equal (const GtkCssValue *value1,
const GtkCssValue *value2)
@@ -99,6 +128,7 @@ gtk_css_value_border_print (const GtkCssValue *value,
static const GtkCssValueClass GTK_CSS_VALUE_BORDER = {
gtk_css_value_border_free,
+ gtk_css_value_border_compute,
gtk_css_value_border_equal,
gtk_css_value_border_transition,
gtk_css_value_border_print
@@ -202,34 +232,3 @@ _gtk_css_border_value_get_left (const GtkCssValue *value)
return value->values[GTK_CSS_LEFT];
}
-GtkCssValue *
-_gtk_css_border_value_compute (GtkCssValue *value,
- GtkStyleContext *context)
-{
- GtkCssValue *computed;
- gboolean changed = FALSE;
- guint i;
-
- g_return_val_if_fail (value->class == &GTK_CSS_VALUE_BORDER, NULL);
-
- computed = _gtk_css_border_value_new (NULL, NULL, NULL, NULL);
- computed->fill = value->fill;
-
- for (i = 0; i < 4; i++)
- {
- if (value->values[i])
- {
- computed->values[i] = _gtk_css_number_value_compute (value->values[i], context);
- changed |= (computed->values[i] != value->values[i]);
- }
- }
-
- if (!changed)
- {
- _gtk_css_value_unref (computed);
- return _gtk_css_value_ref (value);
- }
-
- return computed;
-}
-
diff --git a/gtk/gtkcssbordervalueprivate.h b/gtk/gtkcssbordervalueprivate.h
index 704e25c051..fe49904002 100644
--- a/gtk/gtkcssbordervalueprivate.h
+++ b/gtk/gtkcssbordervalueprivate.h
@@ -40,9 +40,6 @@ GtkCssValue * _gtk_css_border_value_get_right (const GtkCssValue *val
GtkCssValue * _gtk_css_border_value_get_bottom (const GtkCssValue *value);
GtkCssValue * _gtk_css_border_value_get_left (const GtkCssValue *value);
-GtkCssValue * _gtk_css_border_value_compute (GtkCssValue *border,
- GtkStyleContext *context);
-
G_END_DECLS
diff --git a/gtk/gtkcsscornervalue.c b/gtk/gtkcsscornervalue.c
index 5cf497481f..042c7a2059 100644
--- a/gtk/gtkcsscornervalue.c
+++ b/gtk/gtkcsscornervalue.c
@@ -36,6 +36,24 @@ gtk_css_value_corner_free (GtkCssValue *value)
g_slice_free (GtkCssValue, value);
}
+static GtkCssValue *
+gtk_css_value_corner_compute (GtkCssValue *corner,
+ GtkStyleContext *context)
+{
+ GtkCssValue *x, *y;
+
+ x = _gtk_css_value_compute (corner->x, context);
+ y = _gtk_css_value_compute (corner->y, context);
+ if (x == corner->x && y == corner->y)
+ {
+ _gtk_css_value_unref (x);
+ _gtk_css_value_unref (y);
+ return _gtk_css_value_ref (corner);
+ }
+
+ return _gtk_css_corner_value_new (x, y);
+}
+
static gboolean
gtk_css_value_corner_equal (const GtkCssValue *corner1,
const GtkCssValue *corner2)
@@ -78,6 +96,7 @@ gtk_css_value_corner_print (const GtkCssValue *corner,
static const GtkCssValueClass GTK_CSS_VALUE_CORNER = {
gtk_css_value_corner_free,
+ gtk_css_value_corner_compute,
gtk_css_value_corner_equal,
gtk_css_value_corner_transition,
gtk_css_value_corner_print
@@ -148,23 +167,3 @@ _gtk_css_corner_value_get_y (const GtkCssValue *corner,
return _gtk_css_number_value_get (corner->y, one_hundred_percent);
}
-GtkCssValue *
-_gtk_css_corner_value_compute (GtkCssValue *corner,
- GtkStyleContext *context)
-{
- GtkCssValue *x, *y;
-
- g_return_val_if_fail (corner->class == &GTK_CSS_VALUE_CORNER, NULL);
-
- x = _gtk_css_number_value_compute (corner->x, context);
- y = _gtk_css_number_value_compute (corner->y, context);
- if (x == corner->x && y == corner->y)
- {
- _gtk_css_value_unref (x);
- _gtk_css_value_unref (y);
- return _gtk_css_value_ref (corner);
- }
-
- return _gtk_css_corner_value_new (x, y);
-}
-
diff --git a/gtk/gtkcsscornervalueprivate.h b/gtk/gtkcsscornervalueprivate.h
index c9312fff76..c7d148368c 100644
--- a/gtk/gtkcsscornervalueprivate.h
+++ b/gtk/gtkcsscornervalueprivate.h
@@ -33,8 +33,6 @@ double _gtk_css_corner_value_get_x (const GtkCssValue *cor
double one_hundred_percent);
double _gtk_css_corner_value_get_y (const GtkCssValue *corner,
double one_hundred_percent);
-GtkCssValue * _gtk_css_corner_value_compute (GtkCssValue *corner,
- GtkStyleContext *context);
G_END_DECLS
diff --git a/gtk/gtkcsseasevalue.c b/gtk/gtkcsseasevalue.c
index 2b57fa14c6..8728c822b1 100644
--- a/gtk/gtkcsseasevalue.c
+++ b/gtk/gtkcsseasevalue.c
@@ -49,6 +49,13 @@ gtk_css_value_ease_free (GtkCssValue *value)
g_slice_free (GtkCssValue, value);
}
+static GtkCssValue *
+gtk_css_value_ease_compute (GtkCssValue *value,
+ GtkStyleContext *context)
+{
+ return _gtk_css_value_ref (value);
+}
+
static gboolean
gtk_css_value_ease_equal (const GtkCssValue *ease1,
const GtkCssValue *ease2)
@@ -125,6 +132,7 @@ gtk_css_value_ease_print (const GtkCssValue *ease,
static const GtkCssValueClass GTK_CSS_VALUE_EASE = {
gtk_css_value_ease_free,
+ gtk_css_value_ease_compute,
gtk_css_value_ease_equal,
gtk_css_value_ease_transition,
gtk_css_value_ease_print
diff --git a/gtk/gtkcssenginevalue.c b/gtk/gtkcssenginevalue.c
index ff4ba672db..437a0b6921 100644
--- a/gtk/gtkcssenginevalue.c
+++ b/gtk/gtkcssenginevalue.c
@@ -34,6 +34,13 @@ gtk_css_value_engine_free (GtkCssValue *value)
g_slice_free (GtkCssValue, value);
}
+static GtkCssValue *
+gtk_css_value_engine_compute (GtkCssValue *value,
+ GtkStyleContext *context)
+{
+ return _gtk_css_value_ref (value);
+}
+
static gboolean
gtk_css_value_engine_equal (const GtkCssValue *value1,
const GtkCssValue *value2)
@@ -67,6 +74,7 @@ gtk_css_value_engine_print (const GtkCssValue *value,
static const GtkCssValueClass GTK_CSS_VALUE_ENGINE = {
gtk_css_value_engine_free,
+ gtk_css_value_engine_compute,
gtk_css_value_engine_equal,
gtk_css_value_engine_transition,
gtk_css_value_engine_print
diff --git a/gtk/gtkcssenumvalue.c b/gtk/gtkcssenumvalue.c
index 56fb1e829f..d808ff7de8 100644
--- a/gtk/gtkcssenumvalue.c
+++ b/gtk/gtkcssenumvalue.c
@@ -35,6 +35,13 @@ gtk_css_value_enum_free (GtkCssValue *value)
g_slice_free (GtkCssValue, value);
}
+static GtkCssValue *
+gtk_css_value_enum_compute (GtkCssValue *value,
+ GtkStyleContext *context)
+{
+ return _gtk_css_value_ref (value);
+}
+
static gboolean
gtk_css_value_enum_equal (const GtkCssValue *enum1,
const GtkCssValue *enum2)
@@ -61,6 +68,7 @@ gtk_css_value_enum_print (const GtkCssValue *value,
static const GtkCssValueClass GTK_CSS_VALUE_BORDER_STYLE = {
gtk_css_value_enum_free,
+ gtk_css_value_enum_compute,
gtk_css_value_enum_equal,
gtk_css_value_enum_transition,
gtk_css_value_enum_print
@@ -115,6 +123,7 @@ _gtk_css_border_style_value_get (const GtkCssValue *value)
static const GtkCssValueClass GTK_CSS_VALUE_FONT_STYLE = {
gtk_css_value_enum_free,
+ gtk_css_value_enum_compute,
gtk_css_value_enum_equal,
gtk_css_value_enum_transition,
gtk_css_value_enum_print
@@ -162,6 +171,7 @@ _gtk_css_font_style_value_get (const GtkCssValue *value)
static const GtkCssValueClass GTK_CSS_VALUE_FONT_VARIANT = {
gtk_css_value_enum_free,
+ gtk_css_value_enum_compute,
gtk_css_value_enum_equal,
gtk_css_value_enum_transition,
gtk_css_value_enum_print
@@ -208,6 +218,7 @@ _gtk_css_font_variant_value_get (const GtkCssValue *value)
static const GtkCssValueClass GTK_CSS_VALUE_FONT_WEIGHT = {
gtk_css_value_enum_free,
+ gtk_css_value_enum_compute,
gtk_css_value_enum_equal,
gtk_css_value_enum_transition,
gtk_css_value_enum_print
@@ -275,6 +286,7 @@ _gtk_css_font_weight_value_get (const GtkCssValue *value)
static const GtkCssValueClass GTK_CSS_VALUE_AREA = {
gtk_css_value_enum_free,
+ gtk_css_value_enum_compute,
gtk_css_value_enum_equal,
gtk_css_value_enum_transition,
gtk_css_value_enum_print
diff --git a/gtk/gtkcssimagelinear.c b/gtk/gtkcssimagelinear.c
index 5c720d965a..ffb7775d16 100644
--- a/gtk/gtkcssimagelinear.c
+++ b/gtk/gtkcssimagelinear.c
@@ -421,7 +421,7 @@ gtk_css_image_linear_compute (GtkCssImage *image,
copy = g_object_new (GTK_TYPE_CSS_IMAGE_LINEAR, NULL);
copy->repeating = linear->repeating;
- copy->angle = _gtk_css_number_value_compute (linear->angle, context);
+ copy->angle = _gtk_css_value_compute (linear->angle, context);
fallback = _gtk_css_symbolic_value_new_take_symbolic_color (gtk_symbolic_color_new_literal (&transparent));
g_array_set_size (copy->stops, linear->stops->len);
@@ -438,7 +438,7 @@ gtk_css_image_linear_compute (GtkCssImage *image,
FALSE);
if (stop->offset)
- scopy->offset = _gtk_css_number_value_compute (stop->offset, context);
+ scopy->offset = _gtk_css_value_compute (stop->offset, context);
else
scopy->offset = NULL;
}
diff --git a/gtk/gtkcssimagevalue.c b/gtk/gtkcssimagevalue.c
index e67e9ea51a..6f65e2253e 100644
--- a/gtk/gtkcssimagevalue.c
+++ b/gtk/gtkcssimagevalue.c
@@ -33,6 +33,28 @@ gtk_css_value_image_free (GtkCssValue *value)
g_slice_free (GtkCssValue, value);
}
+static GtkCssValue *
+gtk_css_value_image_compute (GtkCssValue *value,
+ GtkStyleContext *context)
+{
+ GtkCssImage *image, *computed;
+
+ image = _gtk_css_image_value_get_image (value);
+
+ if (image == NULL)
+ return _gtk_css_value_ref (value);
+
+ computed = _gtk_css_image_compute (image, context);
+
+ if (computed == image)
+ {
+ g_object_unref (computed);
+ return _gtk_css_value_ref (value);
+ }
+
+ return _gtk_css_image_value_new (computed);
+}
+
static gboolean
gtk_css_value_image_equal (const GtkCssValue *value1,
const GtkCssValue *value2)
@@ -66,6 +88,7 @@ gtk_css_value_image_print (const GtkCssValue *value,
static const GtkCssValueClass GTK_CSS_VALUE_IMAGE = {
gtk_css_value_image_free,
+ gtk_css_value_image_compute,
gtk_css_value_image_equal,
gtk_css_value_image_transition,
gtk_css_value_image_print
diff --git a/gtk/gtkcssinheritvalue.c b/gtk/gtkcssinheritvalue.c
index 692ec5821f..52f21a0e41 100644
--- a/gtk/gtkcssinheritvalue.c
+++ b/gtk/gtkcssinheritvalue.c
@@ -30,6 +30,14 @@ gtk_css_value_inherit_free (GtkCssValue *value)
g_assert_not_reached ();
}
+static GtkCssValue *
+gtk_css_value_inherit_compute (GtkCssValue *value,
+ GtkStyleContext *context)
+{
+ /* This value should be caught further up */
+ g_return_val_if_reached (_gtk_css_value_ref (value));
+}
+
static gboolean
gtk_css_value_inherit_equal (const GtkCssValue *value1,
const GtkCssValue *value2)
@@ -54,6 +62,7 @@ gtk_css_value_inherit_print (const GtkCssValue *value,
static const GtkCssValueClass GTK_CSS_VALUE_INHERIT = {
gtk_css_value_inherit_free,
+ gtk_css_value_inherit_compute,
gtk_css_value_inherit_equal,
gtk_css_value_inherit_transition,
gtk_css_value_inherit_print
diff --git a/gtk/gtkcssinitialvalue.c b/gtk/gtkcssinitialvalue.c
index 640e4c5dd0..f838299de9 100644
--- a/gtk/gtkcssinitialvalue.c
+++ b/gtk/gtkcssinitialvalue.c
@@ -30,6 +30,14 @@ gtk_css_value_initial_free (GtkCssValue *value)
g_assert_not_reached ();
}
+static GtkCssValue *
+gtk_css_value_initial_compute (GtkCssValue *value,
+ GtkStyleContext *context)
+{
+ /* This value should be caught further up */
+ g_return_val_if_reached (_gtk_css_value_ref (value));
+}
+
static gboolean
gtk_css_value_initial_equal (const GtkCssValue *value1,
const GtkCssValue *value2)
@@ -54,6 +62,7 @@ gtk_css_value_initial_print (const GtkCssValue *value,
static const GtkCssValueClass GTK_CSS_VALUE_INITIAL = {
gtk_css_value_initial_free,
+ gtk_css_value_initial_compute,
gtk_css_value_initial_equal,
gtk_css_value_initial_transition,
gtk_css_value_initial_print
diff --git a/gtk/gtkcssnumbervalue.c b/gtk/gtkcssnumbervalue.c
index aab2bc2d56..c198e43764 100644
--- a/gtk/gtkcssnumbervalue.c
+++ b/gtk/gtkcssnumbervalue.c
@@ -33,6 +33,65 @@ gtk_css_value_number_free (GtkCssValue *value)
g_slice_free (GtkCssValue, value);
}
+static GtkCssValue *
+gtk_css_value_number_compute (GtkCssValue *number,
+ GtkStyleContext *context)
+{
+ switch (number->unit)
+ {
+ default:
+ g_assert_not_reached();
+ /* fall through */
+ case GTK_CSS_PERCENT:
+ case GTK_CSS_NUMBER:
+ case GTK_CSS_PX:
+ case GTK_CSS_DEG:
+ case GTK_CSS_S:
+ return _gtk_css_value_ref (number);
+ case GTK_CSS_PT:
+ return _gtk_css_number_value_new (number->value * 96.0 / 72.0,
+ GTK_CSS_PX);
+ case GTK_CSS_PC:
+ return _gtk_css_number_value_new (number->value * 96.0 / 72.0 * 12.0,
+ GTK_CSS_PX);
+ break;
+ case GTK_CSS_IN:
+ return _gtk_css_number_value_new (number->value * 96.0,
+ GTK_CSS_PX);
+ break;
+ case GTK_CSS_CM:
+ return _gtk_css_number_value_new (number->value * 96.0 * 0.39370078740157477,
+ GTK_CSS_PX);
+ break;
+ case GTK_CSS_MM:
+ return _gtk_css_number_value_new (number->value * 96.0 * 0.039370078740157477,
+ GTK_CSS_PX);
+ break;
+ case GTK_CSS_EM:
+ return _gtk_css_number_value_new (number->value *
+ _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_FONT_SIZE), 100),
+ GTK_CSS_PX);
+ break;
+ case GTK_CSS_EX:
+ /* for now we pretend ex is half of em */
+ return _gtk_css_number_value_new (number->value * 0.5 *
+ _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_FONT_SIZE), 100),
+ GTK_CSS_PX);
+ case GTK_CSS_RAD:
+ return _gtk_css_number_value_new (number->value * 360.0 / (2 * G_PI),
+ GTK_CSS_DEG);
+ case GTK_CSS_GRAD:
+ return _gtk_css_number_value_new (number->value * 360.0 / 400.0,
+ GTK_CSS_DEG);
+ case GTK_CSS_TURN:
+ return _gtk_css_number_value_new (number->value * 360.0,
+ GTK_CSS_DEG);
+ case GTK_CSS_MS:
+ return _gtk_css_number_value_new (number->value / 1000.0,
+ GTK_CSS_S);
+ }
+}
+
static gboolean
gtk_css_value_number_equal (const GtkCssValue *number1,
const GtkCssValue *number2)
@@ -88,6 +147,7 @@ gtk_css_value_number_print (const GtkCssValue *number,
static const GtkCssValueClass GTK_CSS_VALUE_NUMBER = {
gtk_css_value_number_free,
+ gtk_css_value_number_compute,
gtk_css_value_number_equal,
gtk_css_value_number_transition,
gtk_css_value_number_print
@@ -148,64 +208,3 @@ _gtk_css_number_value_get (const GtkCssValue *number,
return number->value;
}
-GtkCssValue *
-_gtk_css_number_value_compute (GtkCssValue *number,
- GtkStyleContext *context)
-{
- g_return_val_if_fail (number->class == &GTK_CSS_VALUE_NUMBER, NULL);
-
- switch (number->unit)
- {
- default:
- g_assert_not_reached();
- /* fall through */
- case GTK_CSS_PERCENT:
- case GTK_CSS_NUMBER:
- case GTK_CSS_PX:
- case GTK_CSS_DEG:
- case GTK_CSS_S:
- return _gtk_css_value_ref (number);
- case GTK_CSS_PT:
- return _gtk_css_number_value_new (number->value * 96.0 / 72.0,
- GTK_CSS_PX);
- case GTK_CSS_PC:
- return _gtk_css_number_value_new (number->value * 96.0 / 72.0 * 12.0,
- GTK_CSS_PX);
- break;
- case GTK_CSS_IN:
- return _gtk_css_number_value_new (number->value * 96.0,
- GTK_CSS_PX);
- break;
- case GTK_CSS_CM:
- return _gtk_css_number_value_new (number->value * 96.0 * 0.39370078740157477,
- GTK_CSS_PX);
- break;
- case GTK_CSS_MM:
- return _gtk_css_number_value_new (number->value * 96.0 * 0.039370078740157477,
- GTK_CSS_PX);
- break;
- case GTK_CSS_EM:
- return _gtk_css_number_value_new (number->value *
- _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_FONT_SIZE), 100),
- GTK_CSS_PX);
- break;
- case GTK_CSS_EX:
- /* for now we pretend ex is half of em */
- return _gtk_css_number_value_new (number->value * 0.5 *
- _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_FONT_SIZE), 100),
- GTK_CSS_PX);
- case GTK_CSS_RAD:
- return _gtk_css_number_value_new (number->value * 360.0 / (2 * G_PI),
- GTK_CSS_DEG);
- case GTK_CSS_GRAD:
- return _gtk_css_number_value_new (number->value * 360.0 / 400.0,
- GTK_CSS_DEG);
- case GTK_CSS_TURN:
- return _gtk_css_number_value_new (number->value * 360.0,
- GTK_CSS_DEG);
- case GTK_CSS_MS:
- return _gtk_css_number_value_new (number->value / 1000.0,
- GTK_CSS_S);
- }
-}
-
diff --git a/gtk/gtkcssnumbervalueprivate.h b/gtk/gtkcssnumbervalueprivate.h
index ead4115082..b9bb6994e6 100644
--- a/gtk/gtkcssnumbervalueprivate.h
+++ b/gtk/gtkcssnumbervalueprivate.h
@@ -45,8 +45,6 @@ GtkCssValue * _gtk_css_number_value_parse (GtkCssParser *par
GtkCssUnit _gtk_css_number_value_get_unit (const GtkCssValue *value);
double _gtk_css_number_value_get (const GtkCssValue *number,
double one_hundred_percent);
-GtkCssValue * _gtk_css_number_value_compute (GtkCssValue *number,
- GtkStyleContext *context);
G_END_DECLS
diff --git a/gtk/gtkcsspositionvalue.c b/gtk/gtkcsspositionvalue.c
index fd230ed917..e24420a05b 100644
--- a/gtk/gtkcsspositionvalue.c
+++ b/gtk/gtkcsspositionvalue.c
@@ -36,6 +36,24 @@ gtk_css_value_position_free (GtkCssValue *value)
g_slice_free (GtkCssValue, value);
}
+static GtkCssValue *
+gtk_css_value_position_compute (GtkCssValue *position,
+ GtkStyleContext *context)
+{
+ GtkCssValue *x, *y;
+
+ x = _gtk_css_value_compute (position->x, context);
+ y = _gtk_css_value_compute (position->y, context);
+ if (x == position->x && y == position->y)
+ {
+ _gtk_css_value_unref (x);
+ _gtk_css_value_unref (y);
+ return _gtk_css_value_ref (position);
+ }
+
+ return _gtk_css_position_value_new (x, y);
+}
+
static gboolean
gtk_css_value_position_equal (const GtkCssValue *position1,
const GtkCssValue *position2)
@@ -129,6 +147,7 @@ done:
static const GtkCssValueClass GTK_CSS_VALUE_POSITION = {
gtk_css_value_position_free,
+ gtk_css_value_position_compute,
gtk_css_value_position_equal,
gtk_css_value_position_transition,
gtk_css_value_position_print
@@ -270,23 +289,3 @@ _gtk_css_position_value_get_y (const GtkCssValue *position,
return _gtk_css_number_value_get (position->y, one_hundred_percent);
}
-GtkCssValue *
-_gtk_css_position_value_compute (GtkCssValue *position,
- GtkStyleContext *context)
-{
- GtkCssValue *x, *y;
-
- g_return_val_if_fail (position->class == &GTK_CSS_VALUE_POSITION, NULL);
-
- x = _gtk_css_number_value_compute (position->x, context);
- y = _gtk_css_number_value_compute (position->y, context);
- if (x == position->x && y == position->y)
- {
- _gtk_css_value_unref (x);
- _gtk_css_value_unref (y);
- return _gtk_css_value_ref (position);
- }
-
- return _gtk_css_position_value_new (x, y);
-}
-
diff --git a/gtk/gtkcsspositionvalueprivate.h b/gtk/gtkcsspositionvalueprivate.h
index 61a5b43074..ee3b1521cd 100644
--- a/gtk/gtkcsspositionvalueprivate.h
+++ b/gtk/gtkcsspositionvalueprivate.h
@@ -33,8 +33,6 @@ double _gtk_css_position_value_get_x (const GtkCssValue *p
double one_hundred_percent);
double _gtk_css_position_value_get_y (const GtkCssValue *position,
double one_hundred_percent);
-GtkCssValue * _gtk_css_position_value_compute (GtkCssValue *position,
- GtkStyleContext *context);
G_END_DECLS
diff --git a/gtk/gtkcssrepeatvalue.c b/gtk/gtkcssrepeatvalue.c
index 0ec1ef7aed..4151f9d48e 100644
--- a/gtk/gtkcssrepeatvalue.c
+++ b/gtk/gtkcssrepeatvalue.c
@@ -33,6 +33,13 @@ gtk_css_value_repeat_free (GtkCssValue *value)
g_slice_free (GtkCssValue, value);
}
+static GtkCssValue *
+gtk_css_value_repeat_compute (GtkCssValue *value,
+ GtkStyleContext *context)
+{
+ return _gtk_css_value_ref (value);
+}
+
static gboolean
gtk_css_value_repeat_equal (const GtkCssValue *repeat1,
const GtkCssValue *repeat2)
@@ -103,6 +110,7 @@ gtk_css_value_border_repeat_print (const GtkCssValue *repeat,
static const GtkCssValueClass GTK_CSS_VALUE_BACKGROUND_REPEAT = {
gtk_css_value_repeat_free,
+ gtk_css_value_repeat_compute,
gtk_css_value_repeat_equal,
gtk_css_value_repeat_transition,
gtk_css_value_background_repeat_print
@@ -110,6 +118,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_BACKGROUND_REPEAT = {
static const GtkCssValueClass GTK_CSS_VALUE_BORDER_REPEAT = {
gtk_css_value_repeat_free,
+ gtk_css_value_repeat_compute,
gtk_css_value_repeat_equal,
gtk_css_value_repeat_transition,
gtk_css_value_border_repeat_print
diff --git a/gtk/gtkcssrgbavalue.c b/gtk/gtkcssrgbavalue.c
index 0bae4de405..88b8ea0767 100644
--- a/gtk/gtkcssrgbavalue.c
+++ b/gtk/gtkcssrgbavalue.c
@@ -34,6 +34,13 @@ gtk_css_value_rgba_free (GtkCssValue *value)
g_slice_free (GtkCssValue, value);
}
+static GtkCssValue *
+gtk_css_value_rgba_compute (GtkCssValue *value,
+ GtkStyleContext *context)
+{
+ return _gtk_css_value_ref (value);
+}
+
static gboolean
gtk_css_value_rgba_equal (const GtkCssValue *rgba1,
const GtkCssValue *rgba2)
@@ -68,6 +75,7 @@ gtk_css_value_rgba_print (const GtkCssValue *rgba,
static const GtkCssValueClass GTK_CSS_VALUE_RGBA = {
gtk_css_value_rgba_free,
+ gtk_css_value_rgba_compute,
gtk_css_value_rgba_equal,
gtk_css_value_rgba_transition,
gtk_css_value_rgba_print
diff --git a/gtk/gtkcssshadowsvalue.c b/gtk/gtkcssshadowsvalue.c
index d4f7655b52..2b105a5cd5 100644
--- a/gtk/gtkcssshadowsvalue.c
+++ b/gtk/gtkcssshadowsvalue.c
@@ -47,6 +47,25 @@ gtk_css_value_shadows_free (GtkCssValue *value)
g_slice_free1 (sizeof (GtkCssValue) + sizeof (GtkCssValue *) * (value->len - 1), value);
}
+static GtkCssValue *
+gtk_css_value_shadows_compute (GtkCssValue *value,
+ GtkStyleContext *context)
+{
+ GtkCssValue *result;
+ guint i;
+
+ if (value->len == 0)
+ return _gtk_css_value_ref (value);
+
+ result = gtk_css_shadows_value_new (value->values, value->len);
+ for (i = 0; i < value->len; i++)
+ {
+ result->values[i] = _gtk_css_value_compute (value->values[i], context);
+ }
+
+ return result;
+}
+
static gboolean
gtk_css_value_shadows_equal (const GtkCssValue *value1,
const GtkCssValue *value2)
@@ -132,6 +151,7 @@ gtk_css_value_shadows_print (const GtkCssValue *value,
static const GtkCssValueClass GTK_CSS_VALUE_SHADOWS = {
gtk_css_value_shadows_free,
+ gtk_css_value_shadows_compute,
gtk_css_value_shadows_equal,
gtk_css_value_shadows_transition,
gtk_css_value_shadows_print
@@ -190,27 +210,6 @@ _gtk_css_shadows_value_parse (GtkCssParser *parser)
return result;
}
-GtkCssValue *
-_gtk_css_shadows_value_compute (GtkCssValue *value,
- GtkStyleContext *context)
-{
- GtkCssValue *result;
- guint i;
-
- g_return_val_if_fail (value->class == &GTK_CSS_VALUE_SHADOWS, NULL);
-
- if (value->len == 0)
- return _gtk_css_value_ref (value);
-
- result = gtk_css_shadows_value_new (value->values, value->len);
- for (i = 0; i < value->len; i++)
- {
- result->values[i] = _gtk_css_shadow_value_compute (value->values[i], context);
- }
-
- return result;
-}
-
void
_gtk_css_shadows_value_paint_layout (const GtkCssValue *shadows,
cairo_t *cr,
diff --git a/gtk/gtkcssshadowsvalueprivate.h b/gtk/gtkcssshadowsvalueprivate.h
index 0918278b4e..f77b22319a 100644
--- a/gtk/gtkcssshadowsvalueprivate.h
+++ b/gtk/gtkcssshadowsvalueprivate.h
@@ -33,9 +33,6 @@ G_BEGIN_DECLS
GtkCssValue * _gtk_css_shadows_value_new_none (void);
GtkCssValue * _gtk_css_shadows_value_parse (GtkCssParser *parser);
-GtkCssValue * _gtk_css_shadows_value_compute (GtkCssValue *shadows,
- GtkStyleContext *context);
-
void _gtk_css_shadows_value_paint_layout (const GtkCssValue *shadows,
cairo_t *cr,
PangoLayout *layout);
diff --git a/gtk/gtkcssshadowvalue.c b/gtk/gtkcssshadowvalue.c
index a722516e54..a1adfc9558 100644
--- a/gtk/gtkcssshadowvalue.c
+++ b/gtk/gtkcssshadowvalue.c
@@ -59,6 +59,28 @@ gtk_css_value_shadow_free (GtkCssValue *shadow)
g_slice_free (GtkCssValue, shadow);
}
+static GtkCssValue *
+gtk_css_value_shadow_compute (GtkCssValue *shadow,
+ GtkStyleContext *context)
+{
+ GdkRGBA transparent = { 0, 0, 0, 0 };
+ GtkCssValue *color, *fallback;
+
+ fallback = _gtk_css_symbolic_value_new_take_symbolic_color (gtk_symbolic_color_new_literal (&transparent));
+ color = _gtk_css_rgba_value_compute_from_symbolic (shadow->color,
+ fallback,
+ context,
+ FALSE);
+ _gtk_css_value_unref (fallback);
+
+ return gtk_css_shadow_value_new (_gtk_css_value_compute (shadow->hoffset, context),
+ _gtk_css_value_compute (shadow->voffset, context),
+ _gtk_css_value_compute (shadow->radius, context),
+ _gtk_css_value_compute (shadow->spread, context),
+ shadow->inset,
+ color);
+}
+
static gboolean
gtk_css_value_shadow_equal (const GtkCssValue *shadow1,
const GtkCssValue *shadow2)
@@ -117,6 +139,7 @@ gtk_css_value_shadow_print (const GtkCssValue *shadow,
static const GtkCssValueClass GTK_CSS_VALUE_SHADOW = {
gtk_css_value_shadow_free,
+ gtk_css_value_shadow_compute,
gtk_css_value_shadow_equal,
gtk_css_value_shadow_transition,
gtk_css_value_shadow_print
@@ -268,28 +291,6 @@ fail:
return NULL;
}
-GtkCssValue *
-_gtk_css_shadow_value_compute (GtkCssValue *shadow,
- GtkStyleContext *context)
-{
- GdkRGBA transparent = { 0, 0, 0, 0 };
- GtkCssValue *color, *fallback;
-
- fallback = _gtk_css_symbolic_value_new_take_symbolic_color (gtk_symbolic_color_new_literal (&transparent));
- color = _gtk_css_rgba_value_compute_from_symbolic (shadow->color,
- fallback,
- context,
- FALSE);
- _gtk_css_value_unref (fallback);
-
- return gtk_css_shadow_value_new (_gtk_css_number_value_compute (shadow->hoffset, context),
- _gtk_css_number_value_compute (shadow->voffset, context),
- _gtk_css_number_value_compute (shadow->radius, context),
- _gtk_css_number_value_compute (shadow->spread, context),
- shadow->inset,
- color);
-}
-
void
_gtk_css_shadow_value_paint_layout (const GtkCssValue *shadow,
cairo_t *cr,
diff --git a/gtk/gtkcssshadowvalueprivate.h b/gtk/gtkcssshadowvalueprivate.h
index 3683e11091..98efa67ab4 100644
--- a/gtk/gtkcssshadowvalueprivate.h
+++ b/gtk/gtkcssshadowvalueprivate.h
@@ -34,9 +34,6 @@ GtkCssValue * _gtk_css_shadow_value_new_for_transition (GtkCssValue
GtkCssValue * _gtk_css_shadow_value_parse (GtkCssParser *parser);
-GtkCssValue * _gtk_css_shadow_value_compute (GtkCssValue *shadow,
- GtkStyleContext *context);
-
void _gtk_css_shadow_value_paint_layout (const GtkCssValue *shadow,
cairo_t *cr,
PangoLayout *layout);
diff --git a/gtk/gtkcssstringvalue.c b/gtk/gtkcssstringvalue.c
index ec58ed99a6..b5813cd884 100644
--- a/gtk/gtkcssstringvalue.c
+++ b/gtk/gtkcssstringvalue.c
@@ -32,6 +32,13 @@ gtk_css_value_string_free (GtkCssValue *value)
g_slice_free (GtkCssValue, value);
}
+static GtkCssValue *
+gtk_css_value_string_compute (GtkCssValue *value,
+ GtkStyleContext *context)
+{
+ return _gtk_css_value_ref (value);
+}
+
static gboolean
gtk_css_value_string_equal (const GtkCssValue *value1,
const GtkCssValue *value2)
@@ -130,6 +137,7 @@ gtk_css_value_ident_print (const GtkCssValue *value,
static const GtkCssValueClass GTK_CSS_VALUE_STRING = {
gtk_css_value_string_free,
+ gtk_css_value_string_compute,
gtk_css_value_string_equal,
gtk_css_value_string_transition,
gtk_css_value_string_print
@@ -137,6 +145,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_STRING = {
static const GtkCssValueClass GTK_CSS_VALUE_IDENT = {
gtk_css_value_string_free,
+ gtk_css_value_string_compute,
gtk_css_value_string_equal,
gtk_css_value_string_transition,
gtk_css_value_ident_print
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index 6cf1d039e8..48a69f06a0 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -520,7 +520,7 @@ shadow_value_compute (GtkCssStyleProperty *property,
GtkStyleContext *context,
GtkCssValue *specified)
{
- return _gtk_css_shadows_value_compute (specified, context);
+ return _gtk_css_value_compute (specified, context);
}
static GtkCssValue *
@@ -535,7 +535,7 @@ border_corner_radius_value_compute (GtkCssStyleProperty *property,
GtkStyleContext *context,
GtkCssValue *specified)
{
- return _gtk_css_corner_value_compute (specified, context);
+ return _gtk_css_value_compute (specified, context);
}
static GtkCssValue *
@@ -561,22 +561,7 @@ css_image_value_compute (GtkCssStyleProperty *property,
GtkStyleContext *context,
GtkCssValue *specified)
{
- GtkCssImage *image, *computed;
-
- image = _gtk_css_image_value_get_image (specified);
-
- if (image == NULL)
- return _gtk_css_value_ref (specified);
-
- computed = _gtk_css_image_compute (image, context);
-
- if (computed == image)
- {
- g_object_unref (computed);
- return _gtk_css_value_ref (specified);
- }
-
- return _gtk_css_image_value_new (computed);
+ return _gtk_css_value_compute (specified, context);
}
static void
@@ -630,18 +615,11 @@ background_image_value_parse (GtkCssStyleProperty *property,
}
static GtkCssValue *
-background_image_value_compute_one (GtkCssValue *value,
- GtkStyleContext *context)
-{
- return css_image_value_compute (NULL, context, value);
-}
-
-static GtkCssValue *
background_image_value_compute (GtkCssStyleProperty *property,
GtkStyleContext *context,
GtkCssValue *specified)
{
- return _gtk_css_array_value_compute (specified, background_image_value_compute_one, context);
+ return _gtk_css_value_compute (specified, context);
}
static void
@@ -679,7 +657,7 @@ font_size_compute (GtkCssStyleProperty *property,
GtkStyleContext *context,
GtkCssValue *specified)
{
- return _gtk_css_number_value_compute (specified, context);
+ return _gtk_css_value_compute (specified, context);
}
static GtkCssValue *
@@ -696,7 +674,7 @@ outline_compute (GtkCssStyleProperty *property,
GtkStyleContext *context,
GtkCssValue *specified)
{
- return _gtk_css_number_value_compute (specified, context);
+ return _gtk_css_value_compute (specified, context);
}
static GtkCssValue *
@@ -744,7 +722,7 @@ compute_border (GtkCssStyleProperty *property,
GtkStyleContext *context,
GtkCssValue *specified)
{
- return _gtk_css_border_value_compute (specified, context);
+ return _gtk_css_value_compute (specified, context);
}
static GtkCssValue *
@@ -827,7 +805,7 @@ compute_margin (GtkCssStyleProperty *property,
GtkStyleContext *context,
GtkCssValue *specified)
{
- return _gtk_css_number_value_compute (specified, context);
+ return _gtk_css_value_compute (specified, context);
}
static GtkCssValue *
@@ -845,7 +823,7 @@ compute_padding (GtkCssStyleProperty *property,
GtkStyleContext *context,
GtkCssValue *specified)
{
- return _gtk_css_number_value_compute (specified, context);
+ return _gtk_css_value_compute (specified, context);
}
static GtkCssValue *
@@ -874,7 +852,7 @@ compute_border_width (GtkCssStyleProperty *property,
border_style == GTK_BORDER_STYLE_HIDDEN)
return _gtk_css_number_value_new (0, GTK_CSS_PX);
else
- return _gtk_css_number_value_compute (specified, context);
+ return _gtk_css_value_compute (specified, context);
}
static GtkCssValue *
@@ -910,7 +888,7 @@ background_size_compute (GtkCssStyleProperty *property,
GtkStyleContext *context,
GtkCssValue *specified)
{
- return _gtk_css_array_value_compute (specified, _gtk_css_bg_size_value_compute, context);
+ return _gtk_css_value_compute (specified, context);
}
static GtkCssValue *
@@ -925,7 +903,7 @@ background_position_compute (GtkCssStyleProperty *property,
GtkStyleContext *context,
GtkCssValue *specified)
{
- return _gtk_css_array_value_compute (specified, _gtk_css_position_value_compute, context);
+ return _gtk_css_value_compute (specified, context);
}
/*** REGISTRATION ***/
diff --git a/gtk/gtkcsstypedvalue.c b/gtk/gtkcsstypedvalue.c
index a16742790e..81287a48e6 100644
--- a/gtk/gtkcsstypedvalue.c
+++ b/gtk/gtkcsstypedvalue.c
@@ -33,6 +33,13 @@ gtk_css_value_typed_free (GtkCssValue *value)
g_slice_free (GtkCssValue, value);
}
+static GtkCssValue *
+gtk_css_value_typed_compute (GtkCssValue *value,
+ GtkStyleContext *context)
+{
+ return _gtk_css_value_ref (value);
+}
+
static gboolean
gtk_css_value_typed_equal (const GtkCssValue *value1,
const GtkCssValue *value2)
@@ -57,6 +64,7 @@ gtk_css_value_typed_print (const GtkCssValue *value,
static const GtkCssValueClass GTK_CSS_VALUE_TYPED = {
gtk_css_value_typed_free,
+ gtk_css_value_typed_compute,
gtk_css_value_typed_equal,
gtk_css_value_typed_transition,
gtk_css_value_typed_print
diff --git a/gtk/gtkcssvalue.c b/gtk/gtkcssvalue.c
index c24f703fe8..965d57359b 100644
--- a/gtk/gtkcssvalue.c
+++ b/gtk/gtkcssvalue.c
@@ -61,6 +61,16 @@ _gtk_css_value_unref (GtkCssValue *value)
value->class->free (value);
}
+GtkCssValue *
+_gtk_css_value_compute (GtkCssValue *value,
+ GtkStyleContext *context)
+{
+ g_return_val_if_fail (value != NULL, NULL);
+ g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
+
+ return value->class->compute (value, context);
+}
+
gboolean
_gtk_css_value_equal (const GtkCssValue *value1,
const GtkCssValue *value2)
diff --git a/gtk/gtkcssvalueprivate.h b/gtk/gtkcssvalueprivate.h
index 8cc8ba1ea8..93fcaf979b 100644
--- a/gtk/gtkcssvalueprivate.h
+++ b/gtk/gtkcssvalueprivate.h
@@ -23,6 +23,7 @@
#include <glib-object.h>
#include "gtkcsstypesprivate.h"
#include "gtksymboliccolor.h"
+#include "gtktypes.h"
G_BEGIN_DECLS
@@ -41,6 +42,8 @@ typedef struct _GtkCssValueClass GtkCssValueClass;
struct _GtkCssValueClass {
void (* free) (GtkCssValue *value);
+ GtkCssValue * (* compute) (GtkCssValue *value,
+ GtkStyleContext *context);
gboolean (* equal) (const GtkCssValue *value1,
const GtkCssValue *value2);
GtkCssValue * (* transition) (GtkCssValue *start,
@@ -59,6 +62,8 @@ GtkCssValue *_gtk_css_value_alloc (const GtkCssValueClass
GtkCssValue *_gtk_css_value_ref (GtkCssValue *value);
void _gtk_css_value_unref (GtkCssValue *value);
+GtkCssValue *_gtk_css_value_compute (GtkCssValue *value,
+ GtkStyleContext *context);
gboolean _gtk_css_value_equal (const GtkCssValue *value1,
const GtkCssValue *value2);
gboolean _gtk_css_value_equal0 (const GtkCssValue *value1,
diff --git a/gtk/gtksymboliccolor.c b/gtk/gtksymboliccolor.c
index 1c346f8342..6cfed74821 100644
--- a/gtk/gtksymboliccolor.c
+++ b/gtk/gtksymboliccolor.c
@@ -117,6 +117,17 @@ gtk_css_value_symbolic_free (GtkCssValue *value)
g_slice_free (GtkSymbolicColor, color);
}
+static GtkCssValue *
+gtk_css_value_symbolic_compute (GtkCssValue *value,
+ GtkStyleContext *context)
+{
+ /* for now we expect this to never be called
+ * because all cases are handled via
+ * _gtk_css_rgba_value_compute_from_symbolic()
+ */
+ g_return_val_if_reached (_gtk_css_value_ref (value));
+}
+
static gboolean
gtk_css_value_symbolic_equal (const GtkCssValue *value1,
const GtkCssValue *value2)
@@ -180,6 +191,7 @@ gtk_css_value_symbolic_print (const GtkCssValue *value,
static const GtkCssValueClass GTK_CSS_VALUE_SYMBOLIC = {
gtk_css_value_symbolic_free,
+ gtk_css_value_symbolic_compute,
gtk_css_value_symbolic_equal,
gtk_css_value_symbolic_transition,
gtk_css_value_symbolic_print