forked from AuroraMiddleware/gtk
cssimageradial: Only allow at "<position>" after other props
Don't allow syntax like at top left circle but follow the spec about requiring the at <position> right before the comma. This is porbably because circle at 10px 10px could be interpreted as circle 10px at 10px with the now disallowed syntax, too. Test included.
This commit is contained in:
parent
982da040b2
commit
0c12601208
@ -234,7 +234,6 @@ gtk_css_image_radial_parse (GtkCssImage *image,
|
||||
GtkCssImageRadial *radial = GTK_CSS_IMAGE_RADIAL (image);
|
||||
gboolean has_shape = FALSE;
|
||||
gboolean has_size = FALSE;
|
||||
gboolean has_position = FALSE;
|
||||
gboolean found_one = FALSE;
|
||||
guint i;
|
||||
static struct {
|
||||
@ -269,13 +268,6 @@ gtk_css_image_radial_parse (GtkCssImage *image,
|
||||
radial->circle = FALSE;
|
||||
found_one = has_shape = TRUE;
|
||||
}
|
||||
else if (!has_position && _gtk_css_parser_try (parser, "at", TRUE))
|
||||
{
|
||||
radial->position = _gtk_css_position_value_parse (parser);
|
||||
if (!radial->position)
|
||||
return FALSE;
|
||||
found_one = has_position = TRUE;
|
||||
}
|
||||
else if (!has_size)
|
||||
{
|
||||
for (i = 0; i < G_N_ELEMENTS (names); i++)
|
||||
@ -298,18 +290,30 @@ gtk_css_image_radial_parse (GtkCssImage *image,
|
||||
}
|
||||
}
|
||||
|
||||
} while (found_one && !(has_shape && has_size && has_position));
|
||||
} while (found_one && !(has_shape && has_size));
|
||||
|
||||
if ((has_shape || has_size || has_position) &&
|
||||
!_gtk_css_parser_try (parser, ",", TRUE))
|
||||
if (_gtk_css_parser_try (parser, "at", TRUE))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Expected a comma here");
|
||||
return FALSE;
|
||||
radial->position = _gtk_css_position_value_parse (parser);
|
||||
if (!radial->position)
|
||||
return FALSE;
|
||||
if (!_gtk_css_parser_try (parser, ",", TRUE))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Expected a comma here");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!has_position)
|
||||
else
|
||||
{
|
||||
radial->position = _gtk_css_position_value_new (_gtk_css_number_value_new (50, GTK_CSS_PERCENT), _gtk_css_number_value_new (50, GTK_CSS_PERCENT));
|
||||
radial->position = _gtk_css_position_value_new (_gtk_css_number_value_new (50, GTK_CSS_PERCENT),
|
||||
_gtk_css_number_value_new (50, GTK_CSS_PERCENT));
|
||||
|
||||
if ((has_shape || has_size) &&
|
||||
!_gtk_css_parser_try (parser, ",", TRUE))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Expected a comma here");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!has_size)
|
||||
|
@ -410,6 +410,9 @@ test_data = \
|
||||
radial-background-position-error.css \
|
||||
radial-background-position-error.errors \
|
||||
radial-background-position-error.ref.css \
|
||||
radial-positions.css \
|
||||
radial-positions.errors \
|
||||
radial-positions.ref.css \
|
||||
selector.css \
|
||||
selector.ref.css \
|
||||
shadow.css \
|
||||
|
9
testsuite/css/parser/radial-positions.css
Normal file
9
testsuite/css/parser/radial-positions.css
Normal file
@ -0,0 +1,9 @@
|
||||
a {
|
||||
background-image: radial-gradient(at left circle, red, blue);
|
||||
}
|
||||
b {
|
||||
background-image: radial-gradient(10px at left circle, red, blue);
|
||||
}
|
||||
c {
|
||||
background-image: radial-gradient(at 10px 10px circle, red, blue);
|
||||
}
|
3
testsuite/css/parser/radial-positions.errors
Normal file
3
testsuite/css/parser/radial-positions.errors
Normal file
@ -0,0 +1,3 @@
|
||||
radial-positions.css:2: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
|
||||
radial-positions.css:5: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
|
||||
radial-positions.css:8: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
|
0
testsuite/css/parser/radial-positions.ref.css
Normal file
0
testsuite/css/parser/radial-positions.ref.css
Normal file
Loading…
Reference in New Issue
Block a user