summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2019-04-10 00:08:57 +0200
committerBenjamin Otte <otte@redhat.com>2019-04-12 19:34:28 +0200
commitde73ac980f2c4a7ce981910d4ebd68591bde7329 (patch)
tree1a443e55ace54100483b7672ecb38198521c940e
parentacaec5f1865a6cb761225f679f1cbb9456210d8c (diff)
downloadgtk+-de73ac980f2c4a7ce981910d4ebd68591bde7329.tar.gz
css: Use gtk_css_parser_consume_any() for transition shorthand
-rw-r--r--gtk/gtkcssshorthandpropertyimpl.c95
1 files changed, 51 insertions, 44 deletions
diff --git a/gtk/gtkcssshorthandpropertyimpl.c b/gtk/gtkcssshorthandpropertyimpl.c
index 95bc8b6dc1..4f051e800e 100644
--- a/gtk/gtkcssshorthandpropertyimpl.c
+++ b/gtk/gtkcssshorthandpropertyimpl.c
@@ -636,56 +636,63 @@ parse_background (GtkCssShorthandProperty *shorthand,
}
static gboolean
-parse_one_transition (GtkCssShorthandProperty *shorthand,
- GtkCssValue **values,
- GtkCssParser *parser)
+has_transition_property (GtkCssParser *parser,
+ gpointer option_data,
+ gpointer user_data)
{
- do
- {
- /* the image part */
- if (values[2] == NULL &&
- gtk_css_number_value_can_parse (parser))
- {
- GtkCssValue *number = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_TIME);
+ return gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_IDENT);
+}
- if (number == NULL)
- return FALSE;
+static gboolean
+parse_transition_property (GtkCssParser *parser,
+ gpointer option_data,
+ gpointer user_data)
+{
+ GtkCssValue **value = option_data;
- if (values[1] == NULL)
- values[1] = number;
- else
- values[2] = number;
- }
- else if (values[3] == NULL &&
- _gtk_css_ease_value_can_parse (parser))
- {
- values[3] = _gtk_css_ease_value_parse (parser);
+ *value = _gtk_css_ident_value_try_parse (parser);
+ g_assert (*value);
- if (values[3] == NULL)
- return FALSE;
- }
- else if (values[0] == NULL)
- {
- values[0] = _gtk_css_ident_value_try_parse (parser);
- if (values[0] == NULL)
- {
- _gtk_css_parser_error (parser, "Unknown value for property");
- return FALSE;
- }
+ return TRUE;
+}
- }
- else
- {
- /* We parsed everything and there's still stuff left?
- * Pretend we didn't notice and let the normal code produce
- * a 'junk at end of value' error
- */
- break;
- }
- }
- while (!value_is_done_parsing (parser));
+static gboolean
+parse_transition_time (GtkCssParser *parser,
+ gpointer option_data,
+ gpointer user_data)
+{
+ GtkCssValue **value = option_data;
- return TRUE;
+ *value = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_TIME);
+
+ return *value != NULL;
+}
+
+static gboolean
+parse_transition_timing_function (GtkCssParser *parser,
+ gpointer option_data,
+ gpointer user_data)
+{
+ GtkCssValue **value = option_data;
+
+ *value = _gtk_css_ease_value_parse (parser);
+
+ return *value != NULL;
+}
+
+static gboolean
+parse_one_transition (GtkCssShorthandProperty *shorthand,
+ GtkCssValue **values,
+ GtkCssParser *parser)
+{
+ const GtkCssParseOption options[] = {
+ { (void *) _gtk_css_ease_value_can_parse, parse_transition_timing_function, &values[3] },
+ { (void *) gtk_css_number_value_can_parse, parse_transition_time, &values[1] },
+ { (void *) gtk_css_number_value_can_parse, parse_transition_time, &values[2] },
+ { (void *) has_transition_property, parse_transition_property, &values[0] },
+ };
+
+ return gtk_css_parser_consume_any (parser, options, G_N_ELEMENTS (options), NULL);
}
static gboolean