css: Parse text-shadow values properly

We used to accept the same syntax for text-shadow and icon-shadow as
we accept for box-shadow. However, box-shadow does accept a spread and
the inset keyword while the others should not.
This commit is contained in:
Benjamin Otte 2014-06-10 01:04:55 +02:00
parent fc00381d30
commit 3759190c26
5 changed files with 22 additions and 10 deletions

View File

@ -213,7 +213,8 @@ gtk_css_shadows_value_new (GtkCssValue **values,
}
GtkCssValue *
_gtk_css_shadows_value_parse (GtkCssParser *parser)
_gtk_css_shadows_value_parse (GtkCssParser *parser,
gboolean box_shadow_mode)
{
GtkCssValue *value, *result;
GPtrArray *values;
@ -224,7 +225,7 @@ _gtk_css_shadows_value_parse (GtkCssParser *parser)
values = g_ptr_array_new ();
do {
value = _gtk_css_shadow_value_parse (parser);
value = _gtk_css_shadow_value_parse (parser, box_shadow_mode);
if (value == NULL)
{

View File

@ -31,7 +31,8 @@
G_BEGIN_DECLS
GtkCssValue * _gtk_css_shadows_value_new_none (void);
GtkCssValue * _gtk_css_shadows_value_parse (GtkCssParser *parser);
GtkCssValue * _gtk_css_shadows_value_parse (GtkCssParser *parser,
gboolean box_shadow_mode);
gboolean _gtk_css_shadows_value_is_none (const GtkCssValue *shadows);

View File

@ -209,7 +209,8 @@ value_is_done_parsing (GtkCssParser *parser)
}
GtkCssValue *
_gtk_css_shadow_value_parse (GtkCssParser *parser)
_gtk_css_shadow_value_parse (GtkCssParser *parser,
gboolean box_shadow_mode)
{
enum {
HOFFSET,
@ -223,7 +224,8 @@ _gtk_css_shadow_value_parse (GtkCssParser *parser)
gboolean inset;
guint i;
inset = _gtk_css_parser_try (parser, "inset", TRUE);
if (box_shadow_mode)
inset = _gtk_css_parser_try (parser, "inset", TRUE);
do
{
@ -254,7 +256,7 @@ _gtk_css_shadow_value_parse (GtkCssParser *parser)
else
values[RADIUS] = _gtk_css_number_value_new (0.0, GTK_CSS_PX);
if (_gtk_css_parser_has_number (parser))
if (box_shadow_mode && _gtk_css_parser_has_number (parser))
{
values[SPREAD] = _gtk_css_number_value_parse (parser,
GTK_CSS_PARSE_LENGTH
@ -265,7 +267,7 @@ _gtk_css_shadow_value_parse (GtkCssParser *parser)
else
values[SPREAD] = _gtk_css_number_value_new (0.0, GTK_CSS_PX);
}
else if (!inset && _gtk_css_parser_try (parser, "inset", TRUE))
else if (!inset && box_shadow_mode && _gtk_css_parser_try (parser, "inset", TRUE))
{
if (values[HOFFSET] == NULL)
goto fail;

View File

@ -32,7 +32,8 @@ G_BEGIN_DECLS
GtkCssValue * _gtk_css_shadow_value_new_for_transition (GtkCssValue *target);
GtkCssValue * _gtk_css_shadow_value_parse (GtkCssParser *parser);
GtkCssValue * _gtk_css_shadow_value_parse (GtkCssParser *parser,
gboolean box_shadow_mode);
gboolean _gtk_css_shadow_value_get_inset (const GtkCssValue *shadow);

View File

@ -582,11 +582,18 @@ bindings_value_assign (GtkCssStyleProperty *property,
return result;
}
static GtkCssValue *
box_shadow_value_parse (GtkCssStyleProperty *property,
GtkCssParser *parser)
{
return _gtk_css_shadows_value_parse (parser, TRUE);
}
static GtkCssValue *
shadow_value_parse (GtkCssStyleProperty *property,
GtkCssParser *parser)
{
return _gtk_css_shadows_value_parse (parser);
return _gtk_css_shadows_value_parse (parser, FALSE);
}
static GtkCssValue *
@ -1014,7 +1021,7 @@ _gtk_css_style_property_init_properties (void)
GTK_CSS_PROPERTY_BOX_SHADOW,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
shadow_value_parse,
box_shadow_value_parse,
NULL,
NULL,
_gtk_css_shadows_value_new_none ());