cssparser: Add gtk_css_parser_try_token()
This commit is contained in:
@@ -421,7 +421,7 @@ _gtk_css_array_value_parse (GtkCssParser *parser,
|
||||
}
|
||||
|
||||
g_ptr_array_add (values, value);
|
||||
} while (_gtk_css_parser_try (parser, ",", TRUE));
|
||||
} while (gtk_css_parser_try_token (parser, GTK_CSS_TOKEN_COMMA));
|
||||
|
||||
result = _gtk_css_array_value_new_from_array ((GtkCssValue **) values->pdata, values->len);
|
||||
g_ptr_array_free (values, TRUE);
|
||||
|
||||
@@ -263,7 +263,7 @@ gtk_css_font_features_value_parse (GtkCssParser *parser)
|
||||
|
||||
gtk_css_font_features_value_add_feature (result, name, val);
|
||||
g_free (name);
|
||||
} while (_gtk_css_parser_try (parser, ",", TRUE));
|
||||
} while (gtk_css_parser_try_token (parser, GTK_CSS_TOKEN_COMMA));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ gtk_css_font_variations_value_parse (GtkCssParser *parser)
|
||||
|
||||
gtk_css_font_variations_value_add_axis (result, name, coord);
|
||||
g_free (name);
|
||||
} while (_gtk_css_parser_try (parser, ",", TRUE));
|
||||
} while (gtk_css_parser_try_token (parser, GTK_CSS_TOKEN_COMMA));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ gtk_css_image_linear_parse (GtkCssImage *image,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!_gtk_css_parser_try (parser, ",", TRUE))
|
||||
if (!gtk_css_parser_try_token (parser, GTK_CSS_TOKEN_COMMA))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Expected a comma");
|
||||
return FALSE;
|
||||
@@ -334,7 +334,7 @@ gtk_css_image_linear_parse (GtkCssImage *image,
|
||||
if (linear->angle == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (!_gtk_css_parser_try (parser, ",", TRUE))
|
||||
if (!gtk_css_parser_try_token (parser, GTK_CSS_TOKEN_COMMA))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Expected a comma");
|
||||
return FALSE;
|
||||
@@ -368,7 +368,7 @@ gtk_css_image_linear_parse (GtkCssImage *image,
|
||||
|
||||
g_array_append_val (linear->stops, stop);
|
||||
|
||||
} while (_gtk_css_parser_try (parser, ",", TRUE));
|
||||
} while (gtk_css_parser_try_token (parser, GTK_CSS_TOKEN_COMMA));
|
||||
|
||||
if (linear->stops->len < 2)
|
||||
{
|
||||
|
||||
@@ -315,6 +315,88 @@ gtk_css_parser_try_ident (GtkCssParser *parser,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_css_parser_try_token (GtkCssParser *parser,
|
||||
GtkCssTokenType type)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_CSS_PARSER (parser), FALSE);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case GTK_CSS_TOKEN_OPEN_CURLY:
|
||||
if (*parser->data != '{')
|
||||
return FALSE;
|
||||
parser->data += 1;
|
||||
_gtk_css_parser_skip_whitespace (parser);
|
||||
return TRUE;
|
||||
|
||||
case GTK_CSS_TOKEN_CLOSE_CURLY:
|
||||
if (*parser->data != '}')
|
||||
return FALSE;
|
||||
parser->data += 1;
|
||||
_gtk_css_parser_skip_whitespace (parser);
|
||||
return TRUE;
|
||||
|
||||
case GTK_CSS_TOKEN_COMMA:
|
||||
if (*parser->data != ',')
|
||||
return FALSE;
|
||||
parser->data += 1;
|
||||
_gtk_css_parser_skip_whitespace (parser);
|
||||
return TRUE;
|
||||
|
||||
case GTK_CSS_TOKEN_COLON:
|
||||
if (*parser->data != ':')
|
||||
return FALSE;
|
||||
parser->data += 1;
|
||||
_gtk_css_parser_skip_whitespace (parser);
|
||||
return TRUE;
|
||||
|
||||
case GTK_CSS_TOKEN_SEMICOLON:
|
||||
if (*parser->data != ';')
|
||||
return FALSE;
|
||||
parser->data += 1;
|
||||
_gtk_css_parser_skip_whitespace (parser);
|
||||
return TRUE;
|
||||
|
||||
default:
|
||||
case GTK_CSS_TOKEN_STRING:
|
||||
case GTK_CSS_TOKEN_AT_KEYWORD:
|
||||
case GTK_CSS_TOKEN_IDENT:
|
||||
case GTK_CSS_TOKEN_FUNCTION:
|
||||
case GTK_CSS_TOKEN_HASH_UNRESTRICTED:
|
||||
case GTK_CSS_TOKEN_HASH_ID:
|
||||
case GTK_CSS_TOKEN_URL:
|
||||
case GTK_CSS_TOKEN_SIGNED_INTEGER_DIMENSION:
|
||||
case GTK_CSS_TOKEN_SIGNLESS_INTEGER_DIMENSION:
|
||||
case GTK_CSS_TOKEN_DIMENSION:
|
||||
case GTK_CSS_TOKEN_EOF:
|
||||
case GTK_CSS_TOKEN_WHITESPACE:
|
||||
case GTK_CSS_TOKEN_OPEN_PARENS:
|
||||
case GTK_CSS_TOKEN_CLOSE_PARENS:
|
||||
case GTK_CSS_TOKEN_OPEN_SQUARE:
|
||||
case GTK_CSS_TOKEN_CLOSE_SQUARE:
|
||||
case GTK_CSS_TOKEN_CDC:
|
||||
case GTK_CSS_TOKEN_CDO:
|
||||
case GTK_CSS_TOKEN_DELIM:
|
||||
case GTK_CSS_TOKEN_SIGNED_INTEGER:
|
||||
case GTK_CSS_TOKEN_SIGNLESS_INTEGER:
|
||||
case GTK_CSS_TOKEN_SIGNED_NUMBER:
|
||||
case GTK_CSS_TOKEN_SIGNLESS_NUMBER:
|
||||
case GTK_CSS_TOKEN_PERCENTAGE:
|
||||
case GTK_CSS_TOKEN_INCLUDE_MATCH:
|
||||
case GTK_CSS_TOKEN_DASH_MATCH:
|
||||
case GTK_CSS_TOKEN_PREFIX_MATCH:
|
||||
case GTK_CSS_TOKEN_SUFFIX_MATCH:
|
||||
case GTK_CSS_TOKEN_SUBSTRING_MATCH:
|
||||
case GTK_CSS_TOKEN_COLUMN:
|
||||
case GTK_CSS_TOKEN_BAD_STRING:
|
||||
case GTK_CSS_TOKEN_BAD_URL:
|
||||
case GTK_CSS_TOKEN_COMMENT:
|
||||
g_assert_not_reached ();
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static guint
|
||||
get_xdigit (char c)
|
||||
{
|
||||
|
||||
@@ -67,6 +67,8 @@ gboolean gtk_css_parser_has_function (GtkCssParser *parser
|
||||
*/
|
||||
gboolean gtk_css_parser_try_ident (GtkCssParser *parser,
|
||||
const char *ident);
|
||||
gboolean gtk_css_parser_try_token (GtkCssParser *parser,
|
||||
GtkCssTokenType token_type);
|
||||
gboolean _gtk_css_parser_try (GtkCssParser *parser,
|
||||
const char *string,
|
||||
gboolean skip_whitespace);
|
||||
|
||||
@@ -1021,7 +1021,7 @@ parse_declaration (GtkCssScanner *scanner,
|
||||
|
||||
property = _gtk_style_property_lookup (name);
|
||||
|
||||
if (!_gtk_css_parser_try (scanner->parser, ":", TRUE))
|
||||
if (!gtk_css_parser_try_token (scanner->parser, GTK_CSS_TOKEN_COLON))
|
||||
{
|
||||
gtk_css_provider_invalid_token (scanner->provider, scanner, "':'");
|
||||
_gtk_css_parser_resync (scanner->parser, TRUE, '}');
|
||||
|
||||
@@ -256,7 +256,7 @@ _gtk_css_shadows_value_parse (GtkCssParser *parser,
|
||||
}
|
||||
|
||||
g_ptr_array_add (values, value);
|
||||
} while (_gtk_css_parser_try (parser, ",", TRUE));
|
||||
} while (gtk_css_parser_try_token (parser, GTK_CSS_TOKEN_COMMA));
|
||||
|
||||
result = gtk_css_shadows_value_new ((GtkCssValue **) values->pdata, values->len);
|
||||
g_ptr_array_free (values, TRUE);
|
||||
|
||||
@@ -595,7 +595,7 @@ parse_background (GtkCssShorthandProperty *shorthand,
|
||||
g_ptr_array_add (arrays[i], step_values[i]);
|
||||
step_values[i] = NULL;
|
||||
}
|
||||
} while (_gtk_css_parser_try (parser, ",", TRUE));
|
||||
} while (gtk_css_parser_try_token (parser, GTK_CSS_TOKEN_COMMA));
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
@@ -699,7 +699,7 @@ parse_transition (GtkCssShorthandProperty *shorthand,
|
||||
g_ptr_array_add (arrays[i], step_values[i]);
|
||||
step_values[i] = NULL;
|
||||
}
|
||||
} while (_gtk_css_parser_try (parser, ",", TRUE));
|
||||
} while (gtk_css_parser_try_token (parser, GTK_CSS_TOKEN_COMMA));
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
@@ -816,7 +816,7 @@ parse_animation (GtkCssShorthandProperty *shorthand,
|
||||
g_ptr_array_add (arrays[i], step_values[i]);
|
||||
step_values[i] = NULL;
|
||||
}
|
||||
} while (_gtk_css_parser_try (parser, ",", TRUE));
|
||||
} while (gtk_css_parser_try_token (parser, GTK_CSS_TOKEN_COMMA));
|
||||
|
||||
for (i = 0; i < 7; i++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user