diff options
-rw-r--r-- | gtk/gtkcssbgsizevalue.c | 8 | ||||
-rw-r--r-- | gtk/gtkcssbordervalue.c | 6 | ||||
-rw-r--r-- | gtk/gtkcsscolorvalue.c | 4 | ||||
-rw-r--r-- | gtk/gtkcsseasevalue.c | 39 | ||||
-rw-r--r-- | gtk/gtkcssenumvalue.c | 38 | ||||
-rw-r--r-- | gtk/gtkcssfontfeaturesvalue.c | 6 | ||||
-rw-r--r-- | gtk/gtkcssfontvariationsvalue.c | 2 | ||||
-rw-r--r-- | gtk/gtkcssimagebuiltin.c | 2 | ||||
-rw-r--r-- | gtk/gtkcssimagelinear.c | 10 | ||||
-rw-r--r-- | gtk/gtkcssimageradial.c | 4 | ||||
-rw-r--r-- | gtk/gtkcsskeyframes.c | 4 | ||||
-rw-r--r-- | gtk/gtkcssparser.c | 37 | ||||
-rw-r--r-- | gtk/gtkcssparserprivate.h | 4 | ||||
-rw-r--r-- | gtk/gtkcsspositionvalue.c | 4 | ||||
-rw-r--r-- | gtk/gtkcssrepeatvalue.c | 8 | ||||
-rw-r--r-- | gtk/gtkcssshadowsvalue.c | 2 | ||||
-rw-r--r-- | gtk/gtkcssshadowvalue.c | 7 | ||||
-rw-r--r-- | gtk/gtkcssshorthandpropertyimpl.c | 14 | ||||
-rw-r--r-- | gtk/gtkcssstyleproperty.c | 6 | ||||
-rw-r--r-- | gtk/gtkcssstylepropertyimpl.c | 6 |
20 files changed, 126 insertions, 85 deletions
diff --git a/gtk/gtkcssbgsizevalue.c b/gtk/gtkcssbgsizevalue.c index 5402f38fcb..9b31b60033 100644 --- a/gtk/gtkcssbgsizevalue.c +++ b/gtk/gtkcssbgsizevalue.c @@ -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; diff --git a/gtk/gtkcssbordervalue.c b/gtk/gtkcssbordervalue.c index 1efb5e9e16..1bc8aaeefc 100644 --- a/gtk/gtkcssbordervalue.c +++ b/gtk/gtkcssbordervalue.c @@ -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++) { diff --git a/gtk/gtkcsscolorvalue.c b/gtk/gtkcsscolorvalue.c index 3e1bade582..93aec028b0 100644 --- a/gtk/gtkcsscolorvalue.c +++ b/gtk/gtkcsscolorvalue.c @@ -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 }; diff --git a/gtk/gtkcsseasevalue.c b/gtk/gtkcsseasevalue.c index ab990af38e..319adee729 100644 --- a/gtk/gtkcsseasevalue.c +++ b/gtk/gtkcsseasevalue.c @@ -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); + } } } diff --git a/gtk/gtkcssenumvalue.c b/gtk/gtkcssenumvalue.c index 4a6bbfc978..467c9a568a 100644 --- a/gtk/gtkcssenumvalue.c +++ b/gtk/gtkcssenumvalue.c @@ -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; diff --git a/gtk/gtkcssfontfeaturesvalue.c b/gtk/gtkcssfontfeaturesvalue.c index 8fb5728268..262539e216 100644 --- a/gtk/gtkcssfontfeaturesvalue.c +++ b/gtk/gtkcssfontfeaturesvalue.c @@ -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); diff --git a/gtk/gtkcssfontvariationsvalue.c b/gtk/gtkcssfontvariationsvalue.c index b073dd40d3..56fb5162f1 100644 --- a/gtk/gtkcssfontvariationsvalue.c +++ b/gtk/gtkcssfontvariationsvalue.c @@ -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 (); diff --git a/gtk/gtkcssimagebuiltin.c b/gtk/gtkcssimagebuiltin.c index ee547f6c90..1c58da816a 100644 --- a/gtk/gtkcssimagebuiltin.c +++ b/gtk/gtkcssimagebuiltin.c @@ -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; diff --git a/gtk/gtkcssimagelinear.c b/gtk/gtkcssimagelinear.c index 5487767ae2..20ddb6e9cd 100644 --- a/gtk/gtkcssimagelinear.c +++ b/gtk/gtkcssimagelinear.c @@ -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))) { diff --git a/gtk/gtkcssimageradial.c b/gtk/gtkcssimageradial.c index 3b426978c4..2fad9f15f3 100644 --- a/gtk/gtkcssimageradial.c +++ b/gtk/gtkcssimageradial.c @@ -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; diff --git a/gtk/gtkcsskeyframes.c b/gtk/gtkcsskeyframes.c index a45a5fd584..de43bc6ab0 100644 --- a/gtk/gtkcsskeyframes.c +++ b/gtk/gtkcsskeyframes.c @@ -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)) diff --git a/gtk/gtkcssparser.c b/gtk/gtkcssparser.c index 650271e4a5..fb6ce4450f 100644 --- a/gtk/gtkcssparser.c +++ b/gtk/gtkcssparser.c @@ -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) { diff --git a/gtk/gtkcssparserprivate.h b/gtk/gtkcssparserprivate.h index 06be9e3a31..ff90e1c662 100644 --- a/gtk/gtkcssparserprivate.h +++ b/gtk/gtkcssparserprivate.h @@ -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 don’t 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); diff --git a/gtk/gtkcsspositionvalue.c b/gtk/gtkcsspositionvalue.c index 42735fe3ba..280ddc38f8 100644 --- a/gtk/gtkcsspositionvalue.c +++ b/gtk/gtkcsspositionvalue.c @@ -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; diff --git a/gtk/gtkcssrepeatvalue.c b/gtk/gtkcssrepeatvalue.c index 5cc6dab7be..9c8b8642ab 100644 --- a/gtk/gtkcssrepeatvalue.c +++ b/gtk/gtkcssrepeatvalue.c @@ -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; diff --git a/gtk/gtkcssshadowsvalue.c b/gtk/gtkcssshadowsvalue.c index d44e7a4a5b..b920c0737e 100644 --- a/gtk/gtkcssshadowsvalue.c +++ b/gtk/gtkcssshadowsvalue.c @@ -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 (); diff --git a/gtk/gtkcssshadowvalue.c b/gtk/gtkcssshadowvalue.c index 1a3dc68445..e87d753e1c 100644 --- a/gtk/gtkcssshadowvalue.c +++ b/gtk/gtkcssshadowvalue.c @@ -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; diff --git a/gtk/gtkcssshorthandpropertyimpl.c b/gtk/gtkcssshorthandpropertyimpl.c index b9b7cfdea5..6f8028cc48 100644 --- a/gtk/gtkcssshorthandpropertyimpl.c +++ b/gtk/gtkcssshorthandpropertyimpl.c @@ -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); diff --git a/gtk/gtkcssstyleproperty.c b/gtk/gtkcssstyleproperty.c index 70f014bb25..bdc7fb853e 100644 --- a/gtk/gtkcssstyleproperty.c +++ b/gtk/gtkcssstyleproperty.c @@ -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 diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c index f3a0e50e52..ed41c912db 100644 --- a/gtk/gtkcssstylepropertyimpl.c +++ b/gtk/gtkcssstylepropertyimpl.c @@ -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); |