mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 14:31:10 +00:00
Introduce _gtk_css_parser_try_length
This starts to introduce the proper API abstraction for when we will support different units
This commit is contained in:
parent
fce45757cb
commit
fee09e726f
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user