css: Add gtk_css_number_value_can_parse()

Use it instead of _gtk_css_parser_has_number().

We need that once we introduce calc() support.
This commit is contained in:
Benjamin Otte 2016-02-12 06:45:06 +01:00
parent b246d55472
commit a52ecd2be6
11 changed files with 28 additions and 21 deletions

View File

@ -194,7 +194,7 @@ _gtk_css_bg_size_value_parse (GtkCssParser *parser)
if (_gtk_css_parser_try (parser, "auto", TRUE))
y = NULL;
else if (!_gtk_css_parser_has_number (parser))
else if (!gtk_css_number_value_can_parse (parser))
y = NULL;
else
{

View File

@ -174,7 +174,7 @@ _gtk_css_border_value_parse (GtkCssParser *parser,
if (allow_auto && _gtk_css_parser_try (parser, "auto", TRUE))
continue;
if (!_gtk_css_parser_has_number (parser))
if (!gtk_css_number_value_can_parse (parser))
break;
result->values[i] = _gtk_css_number_value_parse (parser, flags);

View File

@ -132,7 +132,7 @@ _gtk_css_corner_value_parse (GtkCssParser *parser)
if (x == NULL)
return NULL;
if (!_gtk_css_parser_has_number (parser))
if (!gtk_css_number_value_can_parse (parser))
y = _gtk_css_value_ref (x);
else
{

View File

@ -163,7 +163,7 @@ gtk_css_image_cross_fade_parse (GtkCssImage *image,
return FALSE;
}
if (_gtk_css_parser_has_number (parser))
if (gtk_css_number_value_can_parse (parser))
{
GtkCssValue *number;

View File

@ -310,7 +310,7 @@ gtk_css_image_linear_parse (GtkCssImage *image,
return FALSE;
}
}
else if (_gtk_css_parser_has_number (parser))
else if (gtk_css_number_value_can_parse (parser))
{
linear->angle = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_ANGLE);
if (linear->angle == NULL)
@ -332,7 +332,7 @@ gtk_css_image_linear_parse (GtkCssImage *image,
if (stop.color == NULL)
return FALSE;
if (_gtk_css_parser_has_number (parser))
if (gtk_css_number_value_can_parse (parser))
{
stop.offset = _gtk_css_number_value_parse (parser,
GTK_CSS_PARSE_PERCENT

View File

@ -282,9 +282,9 @@ gtk_css_image_radial_parse (GtkCssImage *image,
if (!has_size)
{
if (_gtk_css_parser_has_number (parser))
if (gtk_css_number_value_can_parse (parser))
radial->sizes[0] = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_LENGTH | GTK_CSS_PARSE_PERCENT);
if (_gtk_css_parser_has_number (parser))
if (gtk_css_number_value_can_parse (parser))
radial->sizes[1] = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_LENGTH | GTK_CSS_PARSE_PERCENT);
found_one = has_size = radial->sizes[0] != NULL;
}
@ -357,7 +357,7 @@ gtk_css_image_radial_parse (GtkCssImage *image,
if (stop.color == NULL)
return FALSE;
if (_gtk_css_parser_has_number (parser))
if (gtk_css_number_value_can_parse (parser))
{
stop.offset = _gtk_css_number_value_parse (parser,
GTK_CSS_PARSE_PERCENT

View File

@ -48,6 +48,12 @@ _gtk_css_number_value_new (double value,
return gtk_css_dimension_value_new (value, unit);
}
gboolean
gtk_css_number_value_can_parse (GtkCssParser *parser)
{
return _gtk_css_parser_has_number (parser);
}
GtkCssValue *
_gtk_css_number_value_parse (GtkCssParser *parser,
GtkCssNumberParseFlags flags)

View File

@ -49,6 +49,7 @@ struct _GtkCssNumberValueClass {
GtkCssValue * _gtk_css_number_value_new (double value,
GtkCssUnit unit);
gboolean gtk_css_number_value_can_parse (GtkCssParser *parser);
GtkCssValue * _gtk_css_number_value_parse (GtkCssParser *parser,
GtkCssNumberParseFlags flags);

View File

@ -210,7 +210,7 @@ position_value_parse (GtkCssParser *parser, gboolean try)
}
if (names[first].name == NULL)
{
if (_gtk_css_parser_has_number (parser))
if (gtk_css_number_value_can_parse (parser))
{
missing = &y;
x = _gtk_css_number_value_parse (parser,
@ -239,7 +239,7 @@ position_value_parse (GtkCssParser *parser, gboolean try)
if (names[second].name == NULL)
{
if (_gtk_css_parser_has_number (parser))
if (gtk_css_number_value_can_parse (parser))
{
if (missing != &y)
{

View File

@ -215,7 +215,7 @@ _gtk_css_shadow_value_parse (GtkCssParser *parser,
do
{
if (values[HOFFSET] == NULL &&
_gtk_css_parser_has_number (parser))
gtk_css_number_value_can_parse (parser))
{
values[HOFFSET] = _gtk_css_number_value_parse (parser,
GTK_CSS_PARSE_LENGTH
@ -229,7 +229,7 @@ _gtk_css_shadow_value_parse (GtkCssParser *parser,
if (values[VOFFSET] == NULL)
goto fail;
if (_gtk_css_parser_has_number (parser))
if (gtk_css_number_value_can_parse (parser))
{
values[RADIUS] = _gtk_css_number_value_parse (parser,
GTK_CSS_PARSE_LENGTH
@ -241,7 +241,7 @@ _gtk_css_shadow_value_parse (GtkCssParser *parser,
else
values[RADIUS] = _gtk_css_number_value_new (0.0, GTK_CSS_PX);
if (box_shadow_mode && _gtk_css_parser_has_number (parser))
if (box_shadow_mode && gtk_css_number_value_can_parse (parser))
{
values[SPREAD] = _gtk_css_number_value_parse (parser,
GTK_CSS_PARSE_LENGTH

View File

@ -68,7 +68,7 @@ parse_four_numbers (GtkCssShorthandProperty *shorthand,
for (i = 0; i < 4; i++)
{
if (!_gtk_css_parser_has_number (parser))
if (!gtk_css_number_value_can_parse (parser))
break;
values[i] = _gtk_css_number_value_parse (parser, flags);
@ -138,7 +138,7 @@ parse_border_radius (GtkCssShorthandProperty *shorthand,
for (i = 0; i < 4; i++)
{
if (!_gtk_css_parser_has_number (parser))
if (!gtk_css_number_value_can_parse (parser))
break;
x[i] = _gtk_css_number_value_parse (parser,
GTK_CSS_POSITIVE_ONLY
@ -165,7 +165,7 @@ parse_border_radius (GtkCssShorthandProperty *shorthand,
{
for (i = 0; i < 4; i++)
{
if (!_gtk_css_parser_has_number (parser))
if (!gtk_css_number_value_can_parse (parser))
break;
y[i] = _gtk_css_number_value_parse (parser,
GTK_CSS_POSITIVE_ONLY
@ -335,7 +335,7 @@ parse_border_side (GtkCssShorthandProperty *shorthand,
do
{
if (values[0] == NULL &&
_gtk_css_parser_has_number (parser))
gtk_css_number_value_can_parse (parser))
{
values[0] = _gtk_css_number_value_parse (parser,
GTK_CSS_POSITIVE_ONLY
@ -377,7 +377,7 @@ parse_border (GtkCssShorthandProperty *shorthand,
do
{
if (values[0] == NULL &&
_gtk_css_parser_has_number (parser))
gtk_css_number_value_can_parse (parser))
{
values[0] = _gtk_css_number_value_parse (parser,
GTK_CSS_POSITIVE_ONLY
@ -620,7 +620,7 @@ parse_one_transition (GtkCssShorthandProperty *shorthand,
{
/* the image part */
if (values[2] == NULL &&
_gtk_css_parser_has_number (parser) && !_gtk_css_parser_begins_with (parser, '-'))
gtk_css_number_value_can_parse (parser) && !_gtk_css_parser_begins_with (parser, '-'))
{
GtkCssValue *number = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_TIME);
@ -725,7 +725,7 @@ parse_one_animation (GtkCssShorthandProperty *shorthand,
values[1] = _gtk_css_number_value_new (HUGE_VAL, GTK_CSS_NUMBER);
}
else if ((values[1] == NULL || values[3] == NULL) &&
_gtk_css_parser_has_number (parser))
gtk_css_number_value_can_parse (parser))
{
GtkCssValue *value;