cssparser: Introduce gtk_css_parser_try_ident()

... and gtk_css_parser_has_function().
This commit is contained in:
Benjamin Otte 2019-03-24 14:03:52 +01:00
parent 684b6459f1
commit 76fb80f46c
20 changed files with 126 additions and 85 deletions

View File

@ -187,12 +187,12 @@ _gtk_css_bg_size_value_parse (GtkCssParser *parser)
{
GtkCssValue *x, *y;
if (_gtk_css_parser_try (parser, "cover", TRUE))
if (gtk_css_parser_try_ident (parser, "cover"))
return _gtk_css_value_ref (&cover_singleton);
else if (_gtk_css_parser_try (parser, "contain", TRUE))
else if (gtk_css_parser_try_ident (parser, "contain"))
return _gtk_css_value_ref (&contain_singleton);
if (_gtk_css_parser_try (parser, "auto", TRUE))
if (gtk_css_parser_try_ident (parser, "auto"))
x = NULL;
else
{
@ -204,7 +204,7 @@ _gtk_css_bg_size_value_parse (GtkCssParser *parser)
return NULL;
}
if (_gtk_css_parser_try (parser, "auto", TRUE))
if (gtk_css_parser_try_ident (parser, "auto"))
y = NULL;
else if (!gtk_css_number_value_can_parse (parser))
y = NULL;

View File

@ -178,11 +178,11 @@ _gtk_css_border_value_parse (GtkCssParser *parser,
result = _gtk_css_border_value_new (NULL, NULL, NULL, NULL);
if (allow_fill)
result->fill = _gtk_css_parser_try (parser, "fill", TRUE);
result->fill = gtk_css_parser_try_ident (parser, "fill");
for (i = 0; i < 4; i++)
{
if (allow_auto && _gtk_css_parser_try (parser, "auto", TRUE))
if (allow_auto && gtk_css_parser_try_ident (parser, "auto"))
continue;
if (!gtk_css_number_value_can_parse (parser))
@ -204,7 +204,7 @@ _gtk_css_border_value_parse (GtkCssParser *parser,
}
if (allow_fill && !result->fill)
result->fill = _gtk_css_parser_try (parser, "fill", TRUE);
result->fill = gtk_css_parser_try_ident (parser, "fill");
for (; i < 4; i++)
{

View File

@ -680,10 +680,10 @@ _gtk_css_color_value_parse (GtkCssParser *parser)
const char *names[] = {"rgba", "rgb", "lighter", "darker", "shade", "alpha", "mix"};
char *name;
if (_gtk_css_parser_try (parser, "currentColor", TRUE))
if (gtk_css_parser_try_ident (parser, "currentColor"))
return _gtk_css_color_value_new_current_color ();
if (_gtk_css_parser_try (parser, "transparent", TRUE))
if (gtk_css_parser_try_ident (parser, "transparent"))
{
GdkRGBA transparent = { 0, 0, 0, 0 };

View File

@ -188,7 +188,7 @@ _gtk_css_ease_value_new_steps (guint n_steps,
static const struct {
const char *name;
guint is_bezier :1;
guint needs_custom :1;
guint is_function :1;
double values[4];
} parser_values[] = {
{ "linear", TRUE, FALSE, { 0.0, 0.0, 1.0, 1.0 } },
@ -224,7 +224,7 @@ gtk_css_ease_value_parse_cubic_bezier (GtkCssParser *parser)
for (i = 0; i < 4; i++)
{
if (!_gtk_css_parser_try (parser, i ? "," : "(", TRUE))
if (!_gtk_css_parser_try (parser, i ? "," : "cubic-bezier(", TRUE))
{
_gtk_css_parser_error (parser, "Expected '%s'", i ? "," : "(");
return NULL;
@ -257,7 +257,7 @@ gtk_css_ease_value_parse_steps (GtkCssParser *parser)
int n_steps;
gboolean start;
if (!_gtk_css_parser_try (parser, "(", TRUE))
if (!_gtk_css_parser_try (parser, "steps(", TRUE))
{
_gtk_css_parser_error (parser, "Expected '('");
return NULL;
@ -276,9 +276,9 @@ gtk_css_ease_value_parse_steps (GtkCssParser *parser)
if (_gtk_css_parser_try (parser, ",", TRUE))
{
if (_gtk_css_parser_try (parser, "start", TRUE))
if (gtk_css_parser_try_ident (parser, "start"))
start = TRUE;
else if (_gtk_css_parser_try (parser, "end", TRUE))
else if (gtk_css_parser_try_ident (parser, "end"))
start = FALSE;
else
{
@ -307,26 +307,29 @@ _gtk_css_ease_value_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (parser_values); i++)
{
if (_gtk_css_parser_try (parser, parser_values[i].name, FALSE))
if (parser_values[i].is_function)
{
if (parser_values[i].needs_custom)
if (gtk_css_parser_has_function (parser, parser_values[i].name))
{
if (parser_values[i].is_bezier)
return gtk_css_ease_value_parse_cubic_bezier (parser);
else
return gtk_css_ease_value_parse_steps (parser);
}
_gtk_css_parser_skip_whitespace (parser);
if (parser_values[i].is_bezier)
return _gtk_css_ease_value_new_cubic_bezier (parser_values[i].values[0],
parser_values[i].values[1],
parser_values[i].values[2],
parser_values[i].values[3]);
else
return _gtk_css_ease_value_new_steps (parser_values[i].values[0],
parser_values[i].values[1] != 0.0);
}
else
{
if (gtk_css_parser_try_ident (parser, parser_values[i].name))
{
if (parser_values[i].is_bezier)
return _gtk_css_ease_value_new_cubic_bezier (parser_values[i].values[0],
parser_values[i].values[1],
parser_values[i].values[2],
parser_values[i].values[3]);
else
return _gtk_css_ease_value_new_steps (parser_values[i].values[0],
parser_values[i].values[1] != 0.0);
}
}
}

View File

@ -117,7 +117,7 @@ _gtk_css_border_style_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (border_style_values); i++)
{
if (_gtk_css_parser_try (parser, border_style_values[i].name, TRUE))
if (gtk_css_parser_try_ident (parser, border_style_values[i].name))
return _gtk_css_value_ref (&border_style_values[i]);
}
@ -180,7 +180,7 @@ _gtk_css_blend_mode_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (blend_mode_values); i++)
{
if (_gtk_css_parser_try (parser, blend_mode_values[i].name, TRUE))
if (gtk_css_parser_try_ident (parser, blend_mode_values[i].name))
return _gtk_css_value_ref (&blend_mode_values[i]);
}
@ -323,7 +323,7 @@ _gtk_css_font_size_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (font_size_values); i++)
{
if (_gtk_css_parser_try (parser, font_size_values[i].name, TRUE))
if (gtk_css_parser_try_ident (parser, font_size_values[i].name))
return _gtk_css_value_ref (&font_size_values[i]);
}
@ -373,7 +373,7 @@ _gtk_css_font_style_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (font_style_values); i++)
{
if (_gtk_css_parser_try (parser, font_style_values[i].name, TRUE))
if (gtk_css_parser_try_ident (parser, font_style_values[i].name))
return _gtk_css_value_ref (&font_style_values[i]);
}
@ -568,7 +568,7 @@ _gtk_css_font_stretch_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (font_stretch_values); i++)
{
if (_gtk_css_parser_try (parser, font_stretch_values[i].name, TRUE))
if (gtk_css_parser_try_ident (parser, font_stretch_values[i].name))
return _gtk_css_value_ref (&font_stretch_values[i]);
}
@ -618,7 +618,7 @@ _gtk_css_text_decoration_line_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (text_decoration_line_values); i++)
{
if (_gtk_css_parser_try (parser, text_decoration_line_values[i].name, TRUE))
if (gtk_css_parser_try_ident (parser, text_decoration_line_values[i].name))
return _gtk_css_value_ref (&text_decoration_line_values[i]);
}
@ -668,7 +668,7 @@ _gtk_css_text_decoration_style_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (text_decoration_style_values); i++)
{
if (_gtk_css_parser_try (parser, text_decoration_style_values[i].name, TRUE))
if (gtk_css_parser_try_ident (parser, text_decoration_style_values[i].name))
return _gtk_css_value_ref (&text_decoration_style_values[i]);
}
@ -724,7 +724,7 @@ _gtk_css_area_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (area_values); i++)
{
if (_gtk_css_parser_try (parser, area_values[i].name, TRUE))
if (gtk_css_parser_try_ident (parser, area_values[i].name))
return _gtk_css_value_ref (&area_values[i]);
}
@ -784,7 +784,7 @@ _gtk_css_direction_value_try_parse (GtkCssParser *parser)
*/
for (i = G_N_ELEMENTS (direction_values) - 1; i >= 0; i--)
{
if (_gtk_css_parser_try (parser, direction_values[i].name, TRUE))
if (gtk_css_parser_try_ident (parser, direction_values[i].name))
return _gtk_css_value_ref (&direction_values[i]);
}
@ -839,7 +839,7 @@ _gtk_css_play_state_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (play_state_values); i++)
{
if (_gtk_css_parser_try (parser, play_state_values[i].name, TRUE))
if (gtk_css_parser_try_ident (parser, play_state_values[i].name))
return _gtk_css_value_ref (&play_state_values[i]);
}
@ -896,7 +896,7 @@ _gtk_css_fill_mode_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (fill_mode_values); i++)
{
if (_gtk_css_parser_try (parser, fill_mode_values[i].name, TRUE))
if (gtk_css_parser_try_ident (parser, fill_mode_values[i].name))
return _gtk_css_value_ref (&fill_mode_values[i]);
}
@ -952,7 +952,7 @@ _gtk_css_icon_style_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (icon_style_values); i++)
{
if (_gtk_css_parser_try (parser, icon_style_values[i].name, TRUE))
if (gtk_css_parser_try_ident (parser, icon_style_values[i].name))
return _gtk_css_value_ref (&icon_style_values[i]);
}
@ -1008,7 +1008,7 @@ _gtk_css_font_kerning_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (font_kerning_values); i++)
{
if (_gtk_css_parser_try (parser, font_kerning_values[i].name, TRUE))
if (gtk_css_parser_try_ident (parser, font_kerning_values[i].name))
return _gtk_css_value_ref (&font_kerning_values[i]);
}
@ -1064,7 +1064,7 @@ _gtk_css_font_variant_position_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (font_variant_position_values); i++)
{
if (_gtk_css_parser_try (parser, font_variant_position_values[i].name, TRUE))
if (gtk_css_parser_try_ident (parser, font_variant_position_values[i].name))
return _gtk_css_value_ref (&font_variant_position_values[i]);
}
@ -1124,7 +1124,7 @@ _gtk_css_font_variant_caps_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (font_variant_caps_values); i++)
{
if (_gtk_css_parser_try (parser, font_variant_caps_values[i].name, TRUE))
if (gtk_css_parser_try_ident (parser, font_variant_caps_values[i].name))
return _gtk_css_value_ref (&font_variant_caps_values[i]);
}
@ -1179,7 +1179,7 @@ _gtk_css_font_variant_alternate_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (font_variant_alternate_values); i++)
{
if (_gtk_css_parser_try (parser, font_variant_alternate_values[i].name, TRUE))
if (gtk_css_parser_try_ident (parser, font_variant_alternate_values[i].name))
return _gtk_css_value_ref (&font_variant_alternate_values[i]);
}
@ -1310,7 +1310,7 @@ _gtk_css_font_variant_ligature_try_parse_one (GtkCssParser *parser,
for (i = 0; i < G_N_ELEMENTS (font_variant_ligature_values); i++)
{
if (_gtk_css_parser_try (parser, font_variant_ligature_values[i].name, TRUE))
if (gtk_css_parser_try_ident (parser, font_variant_ligature_values[i].name))
{
value = font_variant_ligature_values[i].value;
break;
@ -1412,7 +1412,7 @@ _gtk_css_font_variant_numeric_try_parse_one (GtkCssParser *parser,
for (i = 0; i < G_N_ELEMENTS (font_variant_numeric_values); i++)
{
if (_gtk_css_parser_try (parser, font_variant_numeric_values[i].name, TRUE))
if (gtk_css_parser_try_ident (parser, font_variant_numeric_values[i].name))
{
value = font_variant_numeric_values[i].value;
break;
@ -1554,7 +1554,7 @@ _gtk_css_font_variant_east_asian_try_parse_one (GtkCssParser *pars
for (i = 0; i < G_N_ELEMENTS (font_variant_east_asian_values); i++)
{
if (_gtk_css_parser_try (parser, font_variant_east_asian_values[i].name, TRUE))
if (gtk_css_parser_try_ident (parser, font_variant_east_asian_values[i].name))
{
value = font_variant_east_asian_values[i].value;
break;

View File

@ -230,7 +230,7 @@ gtk_css_font_features_value_parse (GtkCssParser *parser)
char *name;
int num;
if (_gtk_css_parser_try (parser, "normal", TRUE))
if (gtk_css_parser_try_ident (parser, "normal"))
return gtk_css_font_features_value_new_default ();
result = gtk_css_font_features_value_new_empty ();
@ -252,9 +252,9 @@ gtk_css_font_features_value_parse (GtkCssParser *parser)
return NULL;
}
if (_gtk_css_parser_try (parser, "on", TRUE))
if (gtk_css_parser_try_ident (parser, "on"))
val = _gtk_css_number_value_new (1.0, GTK_CSS_NUMBER);
else if (_gtk_css_parser_try (parser, "off", TRUE))
else if (gtk_css_parser_try_ident (parser, "off"))
val = _gtk_css_number_value_new (0.0, GTK_CSS_NUMBER);
else if (_gtk_css_parser_try_int (parser, &num))
val = _gtk_css_number_value_new ((double)num, GTK_CSS_NUMBER);

View File

@ -228,7 +228,7 @@ gtk_css_font_variations_value_parse (GtkCssParser *parser)
GtkCssValue *result, *coord;
char *name;
if (_gtk_css_parser_try (parser, "normal", TRUE))
if (gtk_css_parser_try_ident (parser, "normal"))
return gtk_css_font_variations_value_new_default ();
result = gtk_css_font_variations_value_new_empty ();

View File

@ -457,7 +457,7 @@ static gboolean
gtk_css_image_builtin_parse (GtkCssImage *image,
GtkCssParser *parser)
{
if (!_gtk_css_parser_try (parser, "builtin", TRUE))
if (!gtk_css_parser_try_ident (parser, "builtin"))
{
_gtk_css_parser_error (parser, "Expected 'builtin'");
return FALSE;

View File

@ -272,11 +272,11 @@ gtk_css_image_linear_parse (GtkCssImage *image,
return FALSE;
}
if (_gtk_css_parser_try (parser, "to", TRUE))
if (gtk_css_parser_try_ident (parser, "to"))
{
for (i = 0; i < 2; i++)
{
if (_gtk_css_parser_try (parser, "left", TRUE))
if (gtk_css_parser_try_ident (parser, "left"))
{
if (linear->side & ((1 << GTK_CSS_LEFT) | (1 << GTK_CSS_RIGHT)))
{
@ -285,7 +285,7 @@ gtk_css_image_linear_parse (GtkCssImage *image,
}
linear->side |= (1 << GTK_CSS_LEFT);
}
else if (_gtk_css_parser_try (parser, "right", TRUE))
else if (gtk_css_parser_try_ident (parser, "right"))
{
if (linear->side & ((1 << GTK_CSS_LEFT) | (1 << GTK_CSS_RIGHT)))
{
@ -294,7 +294,7 @@ gtk_css_image_linear_parse (GtkCssImage *image,
}
linear->side |= (1 << GTK_CSS_RIGHT);
}
else if (_gtk_css_parser_try (parser, "top", TRUE))
else if (gtk_css_parser_try_ident (parser, "top"))
{
if (linear->side & ((1 << GTK_CSS_TOP) | (1 << GTK_CSS_BOTTOM)))
{
@ -303,7 +303,7 @@ gtk_css_image_linear_parse (GtkCssImage *image,
}
linear->side |= (1 << GTK_CSS_TOP);
}
else if (_gtk_css_parser_try (parser, "bottom", TRUE))
else if (gtk_css_parser_try_ident (parser, "bottom"))
{
if (linear->side & ((1 << GTK_CSS_TOP) | (1 << GTK_CSS_BOTTOM)))
{

View File

@ -264,12 +264,12 @@ gtk_css_image_radial_parse (GtkCssImage *image,
do {
found_one = FALSE;
if (!has_shape && _gtk_css_parser_try (parser, "circle", TRUE))
if (!has_shape && gtk_css_parser_try_ident (parser, "circle"))
{
radial->circle = TRUE;
found_one = has_shape = TRUE;
}
else if (!has_shape && _gtk_css_parser_try (parser, "ellipse", TRUE))
else if (!has_shape && gtk_css_parser_try_ident (parser, "ellipse"))
{
radial->circle = FALSE;
found_one = has_shape = TRUE;

View File

@ -335,9 +335,9 @@ _gtk_css_keyframes_parse (GtkCssParser *parser)
while (!gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_CLOSE_CURLY))
{
if (_gtk_css_parser_try (parser, "from", TRUE))
if (gtk_css_parser_try_ident (parser, "from"))
progress = 0;
else if (_gtk_css_parser_try (parser, "to", TRUE))
else if (gtk_css_parser_try_ident (parser, "to"))
progress = 1;
else if (_gtk_css_parser_try_double (parser, &progress) &&
_gtk_css_parser_try (parser, "%", TRUE))

View File

@ -293,6 +293,28 @@ _gtk_css_parser_try (GtkCssParser *parser,
return TRUE;
}
gboolean
gtk_css_parser_try_ident (GtkCssParser *parser,
const char *ident)
{
gsize len;
g_return_val_if_fail (GTK_IS_CSS_PARSER (parser), FALSE);
g_return_val_if_fail (ident != NULL, FALSE);
len = strlen (ident);
if (g_ascii_strncasecmp (parser->data, ident, len) != 0 ||
parser->data[len] == '(')
return FALSE;
parser->data += len;
_gtk_css_parser_skip_whitespace (parser);
return TRUE;
}
static guint
get_xdigit (char c)
{
@ -526,6 +548,21 @@ gtk_css_parser_has_token (GtkCssParser *parser,
}
}
gboolean
gtk_css_parser_has_function (GtkCssParser *parser,
const char *name)
{
gsize len;
g_return_val_if_fail (GTK_IS_CSS_PARSER (parser), FALSE);
g_return_val_if_fail (name != NULL, FALSE);
len = strlen (name);
return g_ascii_strncasecmp (parser->data, name, len) == 0 &&
parser->data[len] == '(';
}
char *
_gtk_css_parser_read_string (GtkCssParser *parser)
{

View File

@ -54,6 +54,8 @@ gboolean _gtk_css_parser_has_prefix (GtkCssParser *parser
const char *prefix);
gboolean gtk_css_parser_has_token (GtkCssParser *parser,
GtkCssTokenType token_type);
gboolean gtk_css_parser_has_function (GtkCssParser *parser,
const char *name);
/* IMPORTANT:
* _try_foo() functions do not modify the data pointer if they fail, nor do they
@ -63,6 +65,8 @@ gboolean gtk_css_parser_has_token (GtkCssParser *parser
* however is fine to call if you dont know yet if the token is a foo or a bar,
* you can _try_bar() if try_foo() failed.
*/
gboolean gtk_css_parser_try_ident (GtkCssParser *parser,
const char *ident);
gboolean _gtk_css_parser_try (GtkCssParser *parser,
const char *string,
gboolean skip_whitespace);

View File

@ -195,7 +195,7 @@ position_value_parse (GtkCssParser *parser, gboolean try)
for (first = 0; names[first].name != NULL; first++)
{
if (_gtk_css_parser_try (parser, names[first].name, TRUE))
if (gtk_css_parser_try_ident (parser, names[first].name))
{
if (names[first].horizontal)
{
@ -232,7 +232,7 @@ position_value_parse (GtkCssParser *parser, gboolean try)
for (second = 0; names[second].name != NULL; second++)
{
if (_gtk_css_parser_try (parser, names[second].name, TRUE))
if (gtk_css_parser_try_ident (parser, names[second].name))
{
*missing = _gtk_css_number_value_new (names[second].percentage, GTK_CSS_PERCENT);
break;

View File

@ -178,7 +178,7 @@ _gtk_css_background_repeat_style_try (GtkCssParser *parser,
for (i = 0; i < G_N_ELEMENTS (background_repeat_values); i++)
{
if (_gtk_css_parser_try (parser, background_repeat_values[i].name, TRUE))
if (gtk_css_parser_try_ident (parser, background_repeat_values[i].name))
{
*result = i;
return TRUE;
@ -195,9 +195,9 @@ _gtk_css_background_repeat_value_try_parse (GtkCssParser *parser)
g_return_val_if_fail (parser != NULL, NULL);
if (_gtk_css_parser_try (parser, "repeat-x", TRUE))
if (gtk_css_parser_try_ident (parser, "repeat-x"))
return _gtk_css_background_repeat_value_new (GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_NO_REPEAT);
if (_gtk_css_parser_try (parser, "repeat-y", TRUE))
if (gtk_css_parser_try_ident (parser, "repeat-y"))
return _gtk_css_background_repeat_value_new (GTK_CSS_REPEAT_STYLE_NO_REPEAT, GTK_CSS_REPEAT_STYLE_REPEAT);
if (!_gtk_css_background_repeat_style_try (parser, &x))
@ -272,7 +272,7 @@ _gtk_css_border_repeat_style_try (GtkCssParser *parser,
for (i = 0; i < G_N_ELEMENTS (border_repeat_values); i++)
{
if (_gtk_css_parser_try (parser, border_repeat_values[i].name, TRUE))
if (gtk_css_parser_try_ident (parser, border_repeat_values[i].name))
{
*result = i;
return TRUE;

View File

@ -240,7 +240,7 @@ _gtk_css_shadows_value_parse (GtkCssParser *parser,
GtkCssValue *value, *result;
GPtrArray *values;
if (_gtk_css_parser_try (parser, "none", TRUE))
if (gtk_css_parser_try_ident (parser, "none"))
return _gtk_css_shadows_value_new_none ();
values = g_ptr_array_new ();

View File

@ -226,10 +226,7 @@ _gtk_css_shadow_value_parse (GtkCssParser *parser,
gboolean inset;
guint i;
if (box_shadow_mode)
inset = _gtk_css_parser_try (parser, "inset", TRUE);
else
inset = FALSE;
inset = FALSE;
do
{
@ -267,7 +264,7 @@ _gtk_css_shadow_value_parse (GtkCssParser *parser,
else
values[SPREAD] = _gtk_css_number_value_new (0.0, GTK_CSS_PX);
}
else if (!inset && box_shadow_mode && _gtk_css_parser_try (parser, "inset", TRUE))
else if (!inset && box_shadow_mode && gtk_css_parser_try_ident (parser, "inset"))
{
if (values[HOFFSET] == NULL)
goto fail;

View File

@ -266,7 +266,7 @@ parse_border_image (GtkCssShorthandProperty *shorthand,
{
GtkCssImage *image;
if (_gtk_css_parser_try (parser, "none", TRUE))
if (gtk_css_parser_try_ident (parser, "none"))
image = NULL;
else
{
@ -418,9 +418,9 @@ parse_border (GtkCssShorthandProperty *shorthand,
static GtkCssValue *
_gtk_css_font_variant_value_try_parse (GtkCssParser *parser)
{
if (_gtk_css_parser_try (parser, "normal", TRUE))
if (gtk_css_parser_try_ident (parser, "normal"))
return _gtk_css_ident_value_new ("normal");
else if (_gtk_css_parser_try (parser, "small-caps", TRUE))
else if (gtk_css_parser_try_ident (parser, "small-caps"))
return _gtk_css_ident_value_new ("small-caps");
return NULL;
}
@ -485,7 +485,7 @@ parse_one_background (GtkCssShorthandProperty *shorthand,
{
GtkCssImage *image;
if (_gtk_css_parser_try (parser, "none", TRUE))
if (gtk_css_parser_try_ident (parser, "none"))
image = NULL;
else
{
@ -717,7 +717,7 @@ parse_one_animation (GtkCssShorthandProperty *shorthand,
{
do
{
if (values[1] == NULL && _gtk_css_parser_try (parser, "infinite", TRUE))
if (values[1] == NULL && gtk_css_parser_try_ident (parser, "infinite"))
{
values[1] = _gtk_css_number_value_new (HUGE_VAL, GTK_CSS_NUMBER);
}
@ -870,11 +870,11 @@ parse_font_variant (GtkCssShorthandProperty *shorthand,
GtkCssValue **values,
GtkCssParser *parser)
{
if (_gtk_css_parser_try (parser, "normal", TRUE))
if (gtk_css_parser_try_ident (parser, "normal"))
{
/* all initial values */
}
else if (_gtk_css_parser_try (parser, "none", TRUE))
else if (gtk_css_parser_try_ident (parser, "none"))
{
/* all initial values, except for font-variant-ligatures */
values[0] = _gtk_css_font_variant_ligature_value_new (GTK_CSS_FONT_VARIANT_LIGATURE_NONE);

View File

@ -142,14 +142,14 @@ gtk_css_style_property_parse_value (GtkStyleProperty *property,
{
GtkCssStyleProperty *style_property = GTK_CSS_STYLE_PROPERTY (property);
if (_gtk_css_parser_try (parser, "initial", TRUE))
if (gtk_css_parser_try_ident (parser, "initial"))
{
/* the initial value can be explicitly specified with the
* initial keyword which all properties accept.
*/
return _gtk_css_initial_value_new ();
}
else if (_gtk_css_parser_try (parser, "inherit", TRUE))
else if (gtk_css_parser_try_ident (parser, "inherit"))
{
/* All properties accept the inherit value which
* explicitly specifies that the value will be determined
@ -159,7 +159,7 @@ gtk_css_style_property_parse_value (GtkStyleProperty *property,
*/
return _gtk_css_inherit_value_new ();
}
else if (_gtk_css_parser_try (parser, "unset", TRUE))
else if (gtk_css_parser_try_ident (parser, "unset"))
{
/* If the cascaded value of a property is the unset keyword,
* then if it is an inherited property, this is treated as

View File

@ -650,7 +650,7 @@ css_image_value_parse (GtkCssStyleProperty *property,
{
GtkCssImage *image;
if (_gtk_css_parser_try (parser, "none", TRUE))
if (gtk_css_parser_try_ident (parser, "none"))
image = NULL;
else
{
@ -666,7 +666,7 @@ static GtkCssValue *
css_image_value_parse_with_builtin (GtkCssStyleProperty *property,
GtkCssParser *parser)
{
if (_gtk_css_parser_try (parser, "builtin", TRUE))
if (gtk_css_parser_try_ident (parser, "builtin"))
return _gtk_css_image_value_new (gtk_css_image_builtin_new ());
return css_image_value_parse (property, parser);
@ -817,7 +817,7 @@ transition_timing_function_parse (GtkCssStyleProperty *property,
static GtkCssValue *
iteration_count_parse_one (GtkCssParser *parser)
{
if (_gtk_css_parser_try (parser, "infinite", TRUE))
if (gtk_css_parser_try_ident (parser, "infinite"))
return _gtk_css_number_value_new (HUGE_VAL, GTK_CSS_NUMBER);
return _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_NUMBER | GTK_CSS_POSITIVE_ONLY);