diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-01-26 21:10:47 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-01-26 21:14:09 -0500 |
commit | 5ee7606779aebebf661b4879bcbe7ad74cc8e12d (patch) | |
tree | 5f963eac7ca3a6b29901d49d7ec916826d8ab31f | |
parent | 25409c5a5a369968d93ff9fe45146a4abd922836 (diff) | |
download | gtk+-5ee7606779aebebf661b4879bcbe7ad74cc8e12d.tar.gz |
css: Support colors in cross fades
The CSS Image Spec (Level 4) allows colors in
cross-fade expressions to specify solid-color images.
Support this.
-rw-r--r-- | docs/reference/gtk/css-properties.md | 2 | ||||
-rw-r--r-- | gtk/gtkcssimagecrossfade.c | 20 |
2 files changed, 18 insertions, 4 deletions
diff --git a/docs/reference/gtk/css-properties.md b/docs/reference/gtk/css-properties.md index 6fde7d4518..8fa9819fc7 100644 --- a/docs/reference/gtk/css-properties.md +++ b/docs/reference/gtk/css-properties.md @@ -218,7 +218,7 @@ done with |background-size| [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#background-size) | | |background-position| [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#background-position) | | |background-repeat| [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#background-repeat) | | -|background-image| [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#background-image) | not supported: urls without quotes, colors in crossfades | +|background-image| [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#background-image) | not supported: urls without quotes | |box-shadow| [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#box-shadow) | | |background-blend-mode| [CSS Compositing and Blending Level 1](https://www.w3.org/TR/compositing-1/#propdef-background-blend-mode) | only affects multiple backgrounds | |background| [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#background) | | diff --git a/gtk/gtkcssimagecrossfade.c b/gtk/gtkcssimagecrossfade.c index 4ec2c3f0f1..fadd11331d 100644 --- a/gtk/gtkcssimagecrossfade.c +++ b/gtk/gtkcssimagecrossfade.c @@ -25,6 +25,9 @@ #include "gtkcssimagecrossfadeprivate.h" #include "gtkcssnumbervalueprivate.h" +#include "gtkcssimagefallbackprivate.h" +#include "gtkcsscolorvalueprivate.h" + typedef struct _CrossFadeEntry CrossFadeEntry; @@ -308,8 +311,19 @@ parse_image (GtkCssParser *parser, { GtkCssImage **image = option_data; - *image = _gtk_css_image_new_parse (parser); - if (*image == NULL) + if (_gtk_css_image_can_parse (parser)) + *image = _gtk_css_image_new_parse (parser); + else if (gtk_css_color_value_can_parse (parser)) + { + GtkCssValue *color; + + color = _gtk_css_color_value_parse (parser); + if (color == NULL) + return FALSE; + + *image = _gtk_css_image_fallback_new_for_color (color); + } + else return FALSE; return TRUE; @@ -325,7 +339,7 @@ gtk_css_image_cross_fade_parse_arg (GtkCssParser *parser, GtkCssImage *image = NULL; GtkCssParseOption options[] = { - { (void *) gtk_css_number_value_can_parse, parse_progress, &progress }, + { (void *)gtk_css_number_value_can_parse, parse_progress, &progress }, { NULL, parse_image, &image }, }; |