return result;
}
-GtkCssValue *
-_gtk_css_position_value_parse (GtkCssParser *parser)
+static GtkCssValue *
+position_value_parse (GtkCssParser *parser, gboolean try)
{
static const struct {
const char *name;
return NULL;
}
else
- return NULL;
+ {
+ if (!try)
+ _gtk_css_parser_error (parser, "Unrecognized position value");
+ return NULL;
+ }
}
for (second = 0; names[second].name != NULL; second++)
{
if (missing != &y)
{
- _gtk_css_parser_error (parser, "Invalid combination of values");
+ if (!try)
+ _gtk_css_parser_error (parser, "Invalid combination of values");
_gtk_css_value_unref (y);
return NULL;
}
if ((names[first].horizontal && !names[second].vertical) ||
(!names[first].horizontal && !names[second].horizontal))
{
- _gtk_css_parser_error (parser, "Invalid combination of values");
+ if (!try)
+ _gtk_css_parser_error (parser, "Invalid combination of values");
_gtk_css_value_unref (x);
_gtk_css_value_unref (y);
return NULL;
return _gtk_css_position_value_new (x, y);
}
+GtkCssValue *
+_gtk_css_position_value_parse (GtkCssParser *parser)
+{
+ return position_value_parse (parser, FALSE);
+}
+
+GtkCssValue *
+_gtk_css_position_value_try_parse (GtkCssParser *parser)
+{
+ return position_value_parse (parser, TRUE);
+}
+
double
_gtk_css_position_value_get_x (const GtkCssValue *position,
double one_hundred_percent)