[gtk/wip/otte/css: 51/79] css: Use gtk_css_parser_consume_any() for transition shorthand
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/css: 51/79] css: Use gtk_css_parser_consume_any() for transition shorthand
- Date: Fri, 12 Apr 2019 16:08:09 +0000 (UTC)
commit ff879fff12a0c10a1af41e9778754a2aa70076f7
Author: Benjamin Otte <otte redhat com>
Date: Wed Apr 10 00:08:57 2019 +0200
css: Use gtk_css_parser_consume_any() for transition shorthand
gtk/gtkcssshorthandpropertyimpl.c | 95 +++++++++++++++++++++------------------
1 file 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]