css: Add gtk_css_parser_has_url()

This function wasn't needed so far so I didn't add it.
The next commits will use it.

I made has_url() return TRUE for the BAD_URL token, even though a
BAD_URL is not a valid URL. But parsing code will almost always want to
treat these tokesn the same way it would treat otherwise bad urls, so
returning TRUE here makes it go own the right error path in calling
code.
This commit is contained in:
Benjamin Otte 2024-01-22 05:19:15 +01:00
parent 4e00384830
commit 976c5077b9
2 changed files with 9 additions and 0 deletions

View File

@ -957,6 +957,14 @@ gtk_css_parser_parse_url_arg (GtkCssParser *parser,
return 1;
}
gboolean
gtk_css_parser_has_url (GtkCssParser *self)
{
return gtk_css_parser_has_token (self, GTK_CSS_TOKEN_URL)
|| gtk_css_parser_has_token (self, GTK_CSS_TOKEN_BAD_URL)
|| gtk_css_parser_has_function (self, "url");
}
/**
* gtk_css_parser_consume_url:
* @self: a `GtkCssParser`

View File

@ -116,6 +116,7 @@ gboolean gtk_css_parser_has_token (GtkCssParser
GtkCssTokenType token_type);
gboolean gtk_css_parser_has_ident (GtkCssParser *self,
const char *ident);
gboolean gtk_css_parser_has_url (GtkCssParser *self);
gboolean gtk_css_parser_has_number (GtkCssParser *self);
gboolean gtk_css_parser_has_integer (GtkCssParser *self);
gboolean gtk_css_parser_has_function (GtkCssParser *self,