diff --git a/gtk/gtkcssimage.c b/gtk/gtkcssimage.c index 91507c0af4..4b9c781d80 100644 --- a/gtk/gtkcssimage.c +++ b/gtk/gtkcssimage.c @@ -115,6 +115,12 @@ gtk_css_image_real_get_dynamic_image (GtkCssImage *image, return g_object_ref (image); } +static gboolean +gtk_css_image_real_is_computed (GtkCssImage *image) +{ + return FALSE; +} + static void _gtk_css_image_class_init (GtkCssImageClass *klass) { @@ -127,6 +133,7 @@ _gtk_css_image_class_init (GtkCssImageClass *klass) klass->is_invalid = gtk_css_image_real_is_invalid; klass->is_dynamic = gtk_css_image_real_is_dynamic; klass->get_dynamic_image = gtk_css_image_real_get_dynamic_image; + klass->is_computed = gtk_css_image_real_is_computed; } static void @@ -565,3 +572,10 @@ _gtk_css_image_new_parse (GtkCssParser *parser) return image; } +gboolean +gtk_css_image_is_computed (GtkCssImage *image) +{ + GtkCssImageClass *klass = GTK_CSS_IMAGE_GET_CLASS (image); + + return klass->is_computed (image); +} diff --git a/gtk/gtkcssimagecrossfade.c b/gtk/gtkcssimagecrossfade.c index 57bc96d386..2d281b26cc 100644 --- a/gtk/gtkcssimagecrossfade.c +++ b/gtk/gtkcssimagecrossfade.c @@ -414,6 +414,22 @@ gtk_css_image_cross_fade_dispose (GObject *object) G_OBJECT_CLASS (gtk_css_image_cross_fade_parent_class)->dispose (object); } +static gboolean +gtk_css_image_cross_fade_is_computed (GtkCssImage *image) +{ + GtkCssImageCrossFade *cross_fade = GTK_CSS_IMAGE_CROSS_FADE (image); + guint i; + + for (i = 0; i < cross_fade->images->len; i++) + { + const CrossFadeEntry *entry = &g_array_index (cross_fade->images, CrossFadeEntry, i); + if (!gtk_css_image_is_computed (entry->image)) + return FALSE; + } + + return TRUE; +} + static void gtk_css_image_cross_fade_class_init (GtkCssImageCrossFadeClass *klass) { @@ -429,6 +445,7 @@ gtk_css_image_cross_fade_class_init (GtkCssImageCrossFadeClass *klass) image_class->get_dynamic_image = gtk_css_image_cross_fade_get_dynamic_image; image_class->parse = gtk_css_image_cross_fade_parse; image_class->print = gtk_css_image_cross_fade_print; + image_class->is_computed = gtk_css_image_cross_fade_is_computed; object_class->dispose = gtk_css_image_cross_fade_dispose; } diff --git a/gtk/gtkcssimagefallback.c b/gtk/gtkcssimagefallback.c index 879703b0d9..d922da942b 100644 --- a/gtk/gtkcssimagefallback.c +++ b/gtk/gtkcssimagefallback.c @@ -270,6 +270,30 @@ gtk_css_image_fallback_equal (GtkCssImage *image1, fallback2->images[fallback2->used]); } +static gboolean +gtk_css_image_fallback_is_computed (GtkCssImage *image) +{ + GtkCssImageFallback *fallback = GTK_CSS_IMAGE_FALLBACK (image); + + if (fallback->used < 0) + { + guint i; + + if (fallback->color && !fallback->images) + return gtk_css_value_is_computed (fallback->color); + + for (i = 0; i < fallback->n_images; i++) + { + if (!gtk_css_image_is_computed (fallback->images[i])) + { + return FALSE; + } + } + } + + return TRUE; +} + static void _gtk_css_image_fallback_class_init (GtkCssImageFallbackClass *klass) { @@ -284,6 +308,7 @@ _gtk_css_image_fallback_class_init (GtkCssImageFallbackClass *klass) image_class->compute = gtk_css_image_fallback_compute; image_class->print = gtk_css_image_fallback_print; image_class->equal = gtk_css_image_fallback_equal; + image_class->is_computed = gtk_css_image_fallback_is_computed; object_class->dispose = gtk_css_image_fallback_dispose; } diff --git a/gtk/gtkcssimagelinear.c b/gtk/gtkcssimagelinear.c index 52e9a33e2a..13f848d945 100644 --- a/gtk/gtkcssimagelinear.c +++ b/gtk/gtkcssimagelinear.c @@ -662,6 +662,35 @@ gtk_css_image_linear_dispose (GObject *object) G_OBJECT_CLASS (_gtk_css_image_linear_parent_class)->dispose (object); } +static gboolean +gtk_css_image_linear_is_computed (GtkCssImage *image) +{ + GtkCssImageLinear *linear = GTK_CSS_IMAGE_LINEAR (image); + guint i; + gboolean computed = TRUE; + + computed = !linear->angle || gtk_css_value_is_computed (linear->angle); + + for (i = 0; i < linear->n_stops; i ++) + { + const GtkCssImageLinearColorStop *stop = &linear->color_stops[i]; + + if (stop->offset && !gtk_css_value_is_computed (stop->offset)) + { + computed = FALSE; + break; + } + + if (!gtk_css_value_is_computed (stop->color)) + { + computed = FALSE; + break; + } + } + + return computed; +} + static void _gtk_css_image_linear_class_init (GtkCssImageLinearClass *klass) { @@ -674,6 +703,7 @@ _gtk_css_image_linear_class_init (GtkCssImageLinearClass *klass) image_class->compute = gtk_css_image_linear_compute; image_class->equal = gtk_css_image_linear_equal; image_class->transition = gtk_css_image_linear_transition; + image_class->is_computed = gtk_css_image_linear_is_computed; object_class->dispose = gtk_css_image_linear_dispose; } diff --git a/gtk/gtkcssimageprivate.h b/gtk/gtkcssimageprivate.h index f39d73ae8d..b467112e6e 100644 --- a/gtk/gtkcssimageprivate.h +++ b/gtk/gtkcssimageprivate.h @@ -89,6 +89,7 @@ struct _GtkCssImageClass /* print to CSS */ void (* print) (GtkCssImage *image, GString *string); + gboolean (* is_computed) (GtkCssImage *image); }; GType _gtk_css_image_get_type (void) G_GNUC_CONST; @@ -139,6 +140,8 @@ cairo_surface_t * cairo_surface_t *target, int surface_width, int surface_height); +gboolean gtk_css_image_is_computed (GtkCssImage *image); + G_END_DECLS diff --git a/gtk/gtkcssimageradial.c b/gtk/gtkcssimageradial.c index 7a7b50c685..46e6da1584 100644 --- a/gtk/gtkcssimageradial.c +++ b/gtk/gtkcssimageradial.c @@ -710,6 +710,37 @@ gtk_css_image_radial_dispose (GObject *object) G_OBJECT_CLASS (_gtk_css_image_radial_parent_class)->dispose (object); } +static gboolean +gtk_css_image_radial_is_computed (GtkCssImage *image) +{ + GtkCssImageRadial *radial = GTK_CSS_IMAGE_RADIAL (image); + guint i; + gboolean computed = TRUE; + + computed = computed && (!radial->position || gtk_css_value_is_computed (radial->position)); + computed = computed && (!radial->sizes[0] || gtk_css_value_is_computed (radial->sizes[0])); + computed = computed && (!radial->sizes[1] || gtk_css_value_is_computed (radial->sizes[1])); + + if (computed) + for (i = 0; i < radial->n_stops; i ++) + { + const GtkCssImageRadialColorStop *stop = &radial->color_stops[i]; + + if (stop->offset && !gtk_css_value_is_computed (stop->offset)) + { + computed = FALSE; + break; + } + + if (!gtk_css_value_is_computed (stop->color)) + { + computed = FALSE; + break; + } + } + + return computed; +} static void _gtk_css_image_radial_class_init (GtkCssImageRadialClass *klass) { @@ -722,6 +753,7 @@ _gtk_css_image_radial_class_init (GtkCssImageRadialClass *klass) image_class->compute = gtk_css_image_radial_compute; image_class->transition = gtk_css_image_radial_transition; image_class->equal = gtk_css_image_radial_equal; + image_class->is_computed = gtk_css_image_radial_is_computed; object_class->dispose = gtk_css_image_radial_dispose; } diff --git a/gtk/gtkcssimagevalue.c b/gtk/gtkcssimagevalue.c index addbe928be..ceeba6cafc 100644 --- a/gtk/gtkcssimagevalue.c +++ b/gtk/gtkcssimagevalue.c @@ -144,6 +144,7 @@ _gtk_css_image_value_new (GtkCssImage *image) value = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_IMAGE); value->image = image; + value->is_computed = gtk_css_image_is_computed (image); return value; }