Merge branch 'css-crossfade-color' into 'master'

Css crossfade color

See merge request GNOME/gtk!3122
This commit is contained in:
Matthias Clasen 2021-01-27 03:11:17 +00:00
commit 30043e072e
4 changed files with 40 additions and 13 deletions

View File

@ -18,9 +18,9 @@ Length
Percentage
: %, calc()
Angle
: deg | grad | turn, calc()
: deg, grad, turn, calc()
Time
: s | ms, calc()
: s, ms, calc()
Length values with the em or ex units are resolved using the font
size value, unless they occur in setting the font-size itself, in
@ -32,7 +32,7 @@ not quite the same as the CSS definition of rem.
The calc() notation adds considerable expressive power. There are limits
on what types can be combined in such an expression (e.g. it does not make
sense to add a number and a time). For the full details, see the
[CSS3 VAlues and Units](https://www.w3.org/TR/css3-values/#calc-notation)
[CSS3 Values and Units](https://www.w3.org/TR/css3-values/#calc-notation)
spec.
A common pattern among shorthand properties (called 'four sides') is one
@ -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) | |

View File

@ -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;
if (_gtk_css_image_can_parse (parser))
*image = _gtk_css_image_new_parse (parser);
if (*image == NULL)
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 },
};

View File

@ -148,7 +148,7 @@ gtk_css_image_fallback_compute (GtkCssImage *image,
GtkCssValue *computed_color = NULL;
if (fallback->color)
computed_color= _gtk_css_value_compute (fallback->color,
computed_color = _gtk_css_value_compute (fallback->color,
property_id,
provider,
style,
@ -331,3 +331,14 @@ _gtk_css_image_fallback_init (GtkCssImageFallback *image_fallback)
{
image_fallback->used = -1;
}
GtkCssImage *
_gtk_css_image_fallback_new_for_color (GtkCssValue *color)
{
GtkCssImageFallback *image;
image = g_object_new (GTK_TYPE_CSS_IMAGE_FALLBACK, NULL);
image->color = gtk_css_value_ref (color);
return (GtkCssImage *)image;
}

View File

@ -54,6 +54,8 @@ struct _GtkCssImageFallbackClass
GType _gtk_css_image_fallback_get_type (void) G_GNUC_CONST;
GtkCssImage *_gtk_css_image_fallback_new_for_color (GtkCssValue *color);
G_END_DECLS
#endif /* __GTK_CSS_IMAGE_FALLBACK_PRIVATE_H__ */