[gtk+] styleproperty: Parse shadow options in any order
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] styleproperty: Parse shadow options in any order
- Date: Sat, 11 Jun 2011 07:31:22 +0000 (UTC)
commit 590aadd05679871945044f739fedbbf19a88f88b
Author: Benjamin Otte <otte redhat com>
Date: Sat Jun 11 05:24:54 2011 +0200
styleproperty: Parse shadow options in any order
The CSS spec allows random ordering of various properties, so we should,
too.
gtk/gtkstyleproperty.c | 66 ++++++++++++++++++++++++++++++++++-------------
1 files changed, 48 insertions(+), 18 deletions(-)
---
diff --git a/gtk/gtkstyleproperty.c b/gtk/gtkstyleproperty.c
index 17415eb..895ba62 100644
--- a/gtk/gtkstyleproperty.c
+++ b/gtk/gtkstyleproperty.c
@@ -884,38 +884,68 @@ shadow_value_parse (GtkCssParser *parser,
GFile *base,
GValue *value)
{
- gboolean inset;
+ gboolean have_inset, have_color, have_lengths;
gdouble hoffset, voffset, blur, spread;
GtkSymbolicColor *color;
GtkShadow *shadow;
+ guint i;
shadow = _gtk_shadow_new ();
do
{
- inset = _gtk_css_parser_try (parser, "inset", TRUE);
+ have_inset = have_lengths = have_color = FALSE;
- if (!_gtk_css_parser_try_double (parser, &hoffset) ||
- !_gtk_css_parser_try_double (parser, &voffset))
+ for (i = 0; i < 3; i++)
{
- _gtk_css_parser_error (parser, "Horizontal and vertical offsets are required");
- _gtk_shadow_unref (shadow);
- return FALSE;
- }
+ if (!have_inset &&
+ _gtk_css_parser_try (parser, "inset", TRUE))
+ {
+ have_inset = TRUE;
+ continue;
+ }
+
+ if (!have_lengths &&
+ _gtk_css_parser_try_double (parser, &hoffset))
+ {
+ have_lengths = TRUE;
- if (!_gtk_css_parser_try_double (parser, &blur))
- blur = 0;
+ if (!_gtk_css_parser_try_double (parser, &voffset))
+ {
+ _gtk_css_parser_error (parser, "Horizontal and vertical offsets are required");
+ _gtk_shadow_unref (shadow);
+ return FALSE;
+ }
- if (!_gtk_css_parser_try_double (parser, &spread))
- spread = 0;
+ if (!_gtk_css_parser_try_double (parser, &blur))
+ blur = 0;
- /* XXX: the color is optional and UA-defined if it's missing,
- * but it doesn't really make sense for us...
- */
- color = _gtk_css_parser_read_symbolic_color (parser);
+ if (!_gtk_css_parser_try_double (parser, &spread))
+ spread = 0;
- if (color == NULL)
+ continue;
+ }
+
+ if (!have_color)
+ {
+ have_color = TRUE;
+
+ /* XXX: the color is optional and UA-defined if it's missing,
+ * but it doesn't really make sense for us...
+ */
+ color = _gtk_css_parser_read_symbolic_color (parser);
+
+ if (color == NULL)
+ {
+ _gtk_shadow_unref (shadow);
+ return FALSE;
+ }
+ }
+ }
+
+ if (!have_color || !have_lengths)
{
+ _gtk_css_parser_error (parser, "Must specify at least color and offsets");
_gtk_shadow_unref (shadow);
return FALSE;
}
@@ -923,7 +953,7 @@ shadow_value_parse (GtkCssParser *parser,
_gtk_shadow_append (shadow,
hoffset, voffset,
blur, spread,
- inset, color);
+ have_inset, color);
gtk_symbolic_color_unref (color);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]