summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2016-02-05 19:01:48 +0100
committerBenjamin Otte <otte@redhat.com>2016-02-05 19:31:47 +0100
commit0c126012083e55532e1da961edc4fad3303186f3 (patch)
tree9f9d6f8420fac82b6aa22931f820df38781ec0aa
parent982da040b234f8c2da349a45111972d04c98f4a8 (diff)
downloadgtk+-0c126012083e55532e1da961edc4fad3303186f3.tar.gz
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.
-rw-r--r--gtk/gtkcssimageradial.c36
-rw-r--r--testsuite/css/parser/Makefile.am3
-rw-r--r--testsuite/css/parser/radial-positions.css9
-rw-r--r--testsuite/css/parser/radial-positions.errors3
-rw-r--r--testsuite/css/parser/radial-positions.ref.css0
5 files changed, 35 insertions, 16 deletions
diff --git a/gtk/gtkcssimageradial.c b/gtk/gtkcssimageradial.c
index 3a3b343f8e..cb60d392e9 100644
--- a/gtk/gtkcssimageradial.c
+++ b/gtk/gtkcssimageradial.c
@@ -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)
diff --git a/testsuite/css/parser/Makefile.am b/testsuite/css/parser/Makefile.am
index 6c5a6d9cf3..a90b869798 100644
--- a/testsuite/css/parser/Makefile.am
+++ b/testsuite/css/parser/Makefile.am
@@ -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 \
diff --git a/testsuite/css/parser/radial-positions.css b/testsuite/css/parser/radial-positions.css
new file mode 100644
index 0000000000..4a4adc855f
--- /dev/null
+++ b/testsuite/css/parser/radial-positions.css
@@ -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);
+}
diff --git a/testsuite/css/parser/radial-positions.errors b/testsuite/css/parser/radial-positions.errors
new file mode 100644
index 0000000000..92c2e07edf
--- /dev/null
+++ b/testsuite/css/parser/radial-positions.errors
@@ -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
diff --git a/testsuite/css/parser/radial-positions.ref.css b/testsuite/css/parser/radial-positions.ref.css
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testsuite/css/parser/radial-positions.ref.css