Commit fee09e72 authored by Paolo Borelli's avatar Paolo Borelli Committed by Benjamin Otte

Introduce _gtk_css_parser_try_length

This starts to introduce the proper API abstraction for when we will
support different units
parent fce45757
......@@ -578,6 +578,23 @@ _gtk_css_parser_try_double (GtkCssParser *parser,
return TRUE;
}
/* XXX: we should introduce GtkCssLenght that deals with
* different kind of units */
gboolean
_gtk_css_parser_try_length (GtkCssParser *parser,
int *value)
{
if (!_gtk_css_parser_try_int (parser, value))
return FALSE;
/* FIXME: _try_uint skips spaces while the
* spec forbids them
*/
_gtk_css_parser_try (parser, "px", TRUE);
return TRUE;
}
gboolean
_gtk_css_parser_try_enum (GtkCssParser *parser,
GType enum_type,
......
......@@ -72,9 +72,11 @@ gboolean _gtk_css_parser_try_uint (GtkCssParser *parser
guint *value);
gboolean _gtk_css_parser_try_double (GtkCssParser *parser,
gdouble *value);
gboolean _gtk_css_parser_try_length (GtkCssParser *parser,
int *value);
gboolean _gtk_css_parser_try_enum (GtkCssParser *parser,
GType enum_type,
int *value);
GType enum_type,
int *value);
void _gtk_css_parser_skip_whitespace (GtkCssParser *parser);
char * _gtk_css_parser_read_string (GtkCssParser *parser);
......
......@@ -646,7 +646,8 @@ border_value_parse (GtkCssParser *parser,
GValue *value)
{
GtkBorder border = { 0, };
guint i, numbers[4];
guint i;
int numbers[4];
for (i = 0; i < G_N_ELEMENTS (numbers); i++)
{
......@@ -654,7 +655,7 @@ border_value_parse (GtkCssParser *parser,
{
/* These are strictly speaking signed, but we want to be able to use them
for unsigned types too, as the actual ranges of values make this safe */
int res = _gtk_win32_theme_int_parse (parser, base, (int *)&numbers[i]);
int res = _gtk_win32_theme_int_parse (parser, base, &numbers[i]);
if (res == 0) /* Parse error, report */
return FALSE;
......@@ -663,13 +664,10 @@ border_value_parse (GtkCssParser *parser,
break;
}
else
{
if (!_gtk_css_parser_try_uint (parser, &numbers[i]))
break;
/* XXX: shouldn't allow spaces here? */
_gtk_css_parser_try (parser, "px", TRUE);
}
{
if (!_gtk_css_parser_try_length (parser, &numbers[i]))
break;
}
}
if (i == 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment