summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2019-04-01 11:47:53 +0200
committerBenjamin Otte <otte@redhat.com>2019-04-12 19:34:28 +0200
commitdce8c11b07ba9a51102af4dbbc84450e60822fb0 (patch)
treee25e361413564e9dd1f1bae2eb66968b5ca8a2e8 /gtk
parent7ccec19501fef664aa7b9bc333230a9f3bc9aeb5 (diff)
downloadgtk+-dce8c11b07ba9a51102af4dbbc84450e60822fb0.tar.gz
cssparser: Drop _gtk_css_parser_has_prefix()
Replace it with has_ident/has_function. The old function is a typical string matching API, not a tokenizing one.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkcsscalcvalue.c2
-rw-r--r--gtk/gtkcsseasevalue.c12
-rw-r--r--gtk/gtkcssimage.c2
-rw-r--r--gtk/gtkcssnumbervalue.c4
-rw-r--r--gtk/gtkcssparser.c24
-rw-r--r--gtk/gtkcssparserprivate.h4
-rw-r--r--gtk/gtkcssselector.c2
-rw-r--r--gtk/gtkcssshorthandpropertyimpl.c4
8 files changed, 34 insertions, 20 deletions
diff --git a/gtk/gtkcsscalcvalue.c b/gtk/gtkcsscalcvalue.c
index 3b3b133273..f9279e7649 100644
--- a/gtk/gtkcsscalcvalue.c
+++ b/gtk/gtkcsscalcvalue.c
@@ -316,7 +316,7 @@ static GtkCssValue *
gtk_css_calc_value_parse_value (GtkCssParser *parser,
GtkCssNumberParseFlags flags)
{
- if (_gtk_css_parser_has_prefix (parser, "calc"))
+ if (gtk_css_parser_has_function (parser, "calc"))
{
_gtk_css_parser_error (parser, "Nested calc() expressions are not allowed.");
return NULL;
diff --git a/gtk/gtkcsseasevalue.c b/gtk/gtkcsseasevalue.c
index 1a1e66c92a..7dc851cd5b 100644
--- a/gtk/gtkcsseasevalue.c
+++ b/gtk/gtkcsseasevalue.c
@@ -209,8 +209,16 @@ _gtk_css_ease_value_can_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (parser_values); i++)
{
- if (_gtk_css_parser_has_prefix (parser, parser_values[i].name))
- return TRUE;
+ if (parser_values[i].is_function)
+ {
+ if (gtk_css_parser_has_function (parser, parser_values[i].name))
+ return TRUE;
+ }
+ else
+ {
+ if (gtk_css_parser_has_ident (parser, parser_values[i].name))
+ return TRUE;
+ }
}
return FALSE;
diff --git a/gtk/gtkcssimage.c b/gtk/gtkcssimage.c
index dd7a949b9f..ac0eab182a 100644
--- a/gtk/gtkcssimage.c
+++ b/gtk/gtkcssimage.c
@@ -509,7 +509,7 @@ gtk_css_image_get_parser_type (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (image_types); i++)
{
- if (_gtk_css_parser_has_prefix (parser, image_types[i].prefix))
+ if (gtk_css_parser_has_function (parser, image_types[i].prefix))
return image_types[i].type_func ();
}
diff --git a/gtk/gtkcssnumbervalue.c b/gtk/gtkcssnumbervalue.c
index 24396fa29d..6b742c42e1 100644
--- a/gtk/gtkcssnumbervalue.c
+++ b/gtk/gtkcssnumbervalue.c
@@ -130,14 +130,14 @@ gboolean
gtk_css_number_value_can_parse (GtkCssParser *parser)
{
return _gtk_css_parser_has_number (parser)
- || _gtk_css_parser_has_prefix (parser, "calc");
+ || gtk_css_parser_has_function (parser, "calc");
}
GtkCssValue *
_gtk_css_number_value_parse (GtkCssParser *parser,
GtkCssNumberParseFlags flags)
{
- if (_gtk_css_parser_has_prefix (parser, "calc"))
+ if (gtk_css_parser_has_function (parser, "calc"))
return gtk_css_calc_value_parse (parser, flags);
return gtk_css_dimension_value_parse (parser, flags);
diff --git a/gtk/gtkcssparser.c b/gtk/gtkcssparser.c
index 66f0ad8ef2..c9412e26bf 100644
--- a/gtk/gtkcssparser.c
+++ b/gtk/gtkcssparser.c
@@ -90,15 +90,6 @@ _gtk_css_parser_free (GtkCssParser *parser)
g_slice_free (GtkCssParser, parser);
}
-gboolean
-_gtk_css_parser_has_prefix (GtkCssParser *parser,
- const char *prefix)
-{
- g_return_val_if_fail (GTK_IS_CSS_PARSER (parser), FALSE);
-
- return g_ascii_strncasecmp (parser->data, prefix, strlen (prefix)) == 0;
-}
-
guint
_gtk_css_parser_get_line (GtkCssParser *parser)
{
@@ -635,6 +626,21 @@ gtk_css_parser_has_token (GtkCssParser *parser,
}
gboolean
+gtk_css_parser_has_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);
+
+ return g_ascii_strncasecmp (parser->data, ident, len) == 0 &&
+ parser->data[len] != '(';
+}
+
+gboolean
gtk_css_parser_has_function (GtkCssParser *parser,
const char *name)
{
diff --git a/gtk/gtkcssparserprivate.h b/gtk/gtkcssparserprivate.h
index 001d2060e5..1611dea07c 100644
--- a/gtk/gtkcssparserprivate.h
+++ b/gtk/gtkcssparserprivate.h
@@ -62,10 +62,10 @@ GFile * _gtk_css_parser_get_file (GtkCssParser *parser
GFile * _gtk_css_parser_get_file_for_path (GtkCssParser *parser,
const char *path);
-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_ident (GtkCssParser *parser,
+ const char *name);
gboolean gtk_css_parser_has_function (GtkCssParser *parser,
const char *name);
diff --git a/gtk/gtkcssselector.c b/gtk/gtkcssselector.c
index e653e69b98..6658f5eb33 100644
--- a/gtk/gtkcssselector.c
+++ b/gtk/gtkcssselector.c
@@ -1036,7 +1036,7 @@ parse_selector_pseudo_class_nth_child (GtkCssParser *parser,
}
a *= multiplier;
}
- else if (_gtk_css_parser_has_prefix (parser, "n"))
+ else if (gtk_css_parser_has_ident (parser, "n"))
{
a = multiplier;
}
diff --git a/gtk/gtkcssshorthandpropertyimpl.c b/gtk/gtkcssshorthandpropertyimpl.c
index 3b32c7f282..0f14bf9524 100644
--- a/gtk/gtkcssshorthandpropertyimpl.c
+++ b/gtk/gtkcssshorthandpropertyimpl.c
@@ -261,7 +261,7 @@ parse_border_image (GtkCssShorthandProperty *shorthand,
do
{
if (values[0] == NULL &&
- (_gtk_css_parser_has_prefix (parser, "none") ||
+ (gtk_css_parser_has_ident (parser, "none") ||
_gtk_css_image_can_parse (parser)))
{
GtkCssImage *image;
@@ -507,7 +507,7 @@ parse_one_background (GtkCssShorthandProperty *shorthand,
{
/* the image part */
if (values[0] == NULL &&
- (_gtk_css_parser_has_prefix (parser, "none") ||
+ (gtk_css_parser_has_ident (parser, "none") ||
_gtk_css_image_can_parse (parser)))
{
GtkCssImage *image;