g_slice_free (GtkCssValue, value);
}
+static GtkCssValue *
+gtk_css_value_bg_size_compute (GtkCssValue *value,
+ guint property_id,
+ GtkStyleProviderPrivate *provider,
+ GtkCssComputedValues *values,
+ GtkCssComputedValues *parent_values,
+ GtkCssDependencies *dependencies)
+{
+ GtkCssValue *x, *y;
+ GtkCssDependencies x_deps, y_deps;
+
+ if (value->x == NULL && value->y == NULL)
+ return _gtk_css_value_ref (value);
+
+ x_deps = y_deps = 0;
+ x = y = NULL;
+
+ if (value->x)
+ x = _gtk_css_value_compute (value->x, property_id, provider, values, parent_values, &x_deps);
+
+ if (value->y)
+ y = _gtk_css_value_compute (value->y, property_id, provider, values, parent_values, &y_deps);
+
+ *dependencies = _gtk_css_dependencies_union (x_deps, y_deps);
+
+ return _gtk_css_bg_size_value_new (value->x ? x : NULL,
+ value->y ? y : NULL);
+}
+
static gboolean
gtk_css_value_bg_size_equal (const GtkCssValue *value1,
const GtkCssValue *value2)
{
return value1->cover == value2->cover &&
- value2->contain == value2->contain &&
+ value1->contain == value2->contain &&
(value1->x == value2->x ||
(value1->x != NULL && value2->x != NULL &&
_gtk_css_value_equal (value1->x, value2->x))) &&
static GtkCssValue *
gtk_css_value_bg_size_transition (GtkCssValue *start,
GtkCssValue *end,
+ guint property_id,
double progress)
{
GtkCssValue *x, *y;
if (start->x)
{
- x = _gtk_css_value_transition (start->x, end->x, progress);
+ x = _gtk_css_value_transition (start->x, end->x, property_id, progress);
if (x == NULL)
return NULL;
}
if (start->y)
{
- y = _gtk_css_value_transition (start->y, end->y, progress);
+ y = _gtk_css_value_transition (start->y, end->y, property_id, progress);
if (y == NULL)
{
_gtk_css_value_unref (x);
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
g_return_if_fail (value->class == >K_CSS_VALUE_BG_SIZE);
if (value->contain || value->cover)
- gtk_css_bg_size_compute_size_for_cover_contain (value->cover,
- image,
- area_width, area_height,
- out_width, out_height);
+ {
+ gtk_css_bg_size_compute_size_for_cover_contain (value->cover,
+ image,
+ area_width, area_height,
+ out_width, out_height);
+ }
else
- _gtk_css_image_get_concrete_size (image,
- /* note: 0 does the right thing here for 'auto' */
- value->x ? _gtk_css_number_value_get (value->x, area_width) : 0,
- value->y ? _gtk_css_number_value_get (value->y, area_height) : 0,
- area_width, area_height,
- out_width, out_height);
-}
+ {
+ double x, y;
-GtkCssValue *
-_gtk_css_bg_size_value_compute (GtkCssValue *value,
- GtkStyleContext *context)
-{
- g_return_val_if_fail (value->class == >K_CSS_VALUE_BG_SIZE, NULL);
+ /* note: 0 does the right thing later for 'auto' */
+ x = value->x ? _gtk_css_number_value_get (value->x, area_width) : 0;
+ y = value->y ? _gtk_css_number_value_get (value->y, area_height) : 0;
- 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);
+ if ((x <= 0 && value->x) ||
+ (y <= 0 && value->y))
+ {
+ *out_width = 0;
+ *out_height = 0;
+ }
+ else
+ {
+ _gtk_css_image_get_concrete_size (image,
+ x, y,
+ area_width, area_height,
+ out_width, out_height);
+ }
+ }
}