[gtk+/wip/otte/tokenizer: 23/42] css: Add token parser for corner radius value



commit fec3ff3c0b5c358490f0ba1830330ebcffbcb7a8
Author: Benjamin Otte <otte redhat com>
Date:   Thu Mar 17 03:28:14 2016 +0100

    css: Add token parser for corner radius value

 gtk/gtkcsscornervalue.c        |   33 +++++++++++++++++++++++++++++++++
 gtk/gtkcsscornervalueprivate.h |    2 ++
 gtk/gtkcssstylepropertyimpl.c  |   16 ++++++++--------
 3 files changed, 43 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkcsscornervalue.c b/gtk/gtkcsscornervalue.c
index c4ef38d..52ba36e 100644
--- a/gtk/gtkcsscornervalue.c
+++ b/gtk/gtkcsscornervalue.c
@@ -151,6 +151,39 @@ _gtk_css_corner_value_parse (GtkCssParser *parser)
   return _gtk_css_corner_value_new (x, y);
 }
 
+GtkCssValue *
+gtk_css_corner_value_token_parse (GtkCssTokenSource *source)
+{
+  GtkCssValue *x, *y;
+
+  x = gtk_css_number_value_token_parse (source,
+                                        GTK_CSS_POSITIVE_ONLY
+                                        | GTK_CSS_PARSE_PERCENT
+                                        | GTK_CSS_NUMBER_AS_PIXELS
+                                        | GTK_CSS_PARSE_LENGTH);
+  if (x == NULL)
+    return NULL;
+
+  gtk_css_token_source_consume_whitespace (source);
+  if (gtk_css_token_is (gtk_css_token_source_get_token (source), GTK_CSS_TOKEN_EOF))
+    y = _gtk_css_value_ref (x);
+  else
+    {
+      y = gtk_css_number_value_token_parse (source,
+                                            GTK_CSS_POSITIVE_ONLY
+                                            | GTK_CSS_PARSE_PERCENT
+                                            | GTK_CSS_NUMBER_AS_PIXELS
+                                            | GTK_CSS_PARSE_LENGTH);
+      if (y == NULL)
+        {
+          _gtk_css_value_unref (x);
+          return NULL;
+        }
+    }
+
+  return _gtk_css_corner_value_new (x, y);
+}
+
 double
 _gtk_css_corner_value_get_x (const GtkCssValue *corner,
                              double             one_hundred_percent)
diff --git a/gtk/gtkcsscornervalueprivate.h b/gtk/gtkcsscornervalueprivate.h
index c7d1483..c1a7479 100644
--- a/gtk/gtkcsscornervalueprivate.h
+++ b/gtk/gtkcsscornervalueprivate.h
@@ -21,6 +21,7 @@
 #define __GTK_CSS_CORNER_VALUE_PRIVATE_H__
 
 #include "gtkcssparserprivate.h"
+#include "gtkcsstokensourceprivate.h"
 #include "gtkcssvalueprivate.h"
 
 G_BEGIN_DECLS
@@ -28,6 +29,7 @@ G_BEGIN_DECLS
 GtkCssValue *   _gtk_css_corner_value_new           (GtkCssValue            *x,
                                                      GtkCssValue            *y);
 GtkCssValue *   _gtk_css_corner_value_parse         (GtkCssParser           *parser);
+GtkCssValue *   gtk_css_corner_value_token_parse    (GtkCssTokenSource      *source);
 
 double          _gtk_css_corner_value_get_x         (const GtkCssValue      *corner,
                                                      double                  one_hundred_percent);
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index 1ca306b..2d1ff54 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -1759,7 +1759,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_STYLE_PROPERTY_ANIMATED,
                                           GTK_CSS_AFFECTS_BACKGROUND | GTK_CSS_AFFECTS_BORDER,
                                           border_corner_radius_value_parse,
-                                          gtk_css_style_property_token_parse_default,
+                                          (GtkCssStylePropertyTokenParseFunc) 
gtk_css_corner_value_token_parse,
                                           NULL,
                                           NULL,
                                           _gtk_css_corner_value_new (_gtk_css_number_value_new (0, 
GTK_CSS_PX),
@@ -1770,7 +1770,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_STYLE_PROPERTY_ANIMATED,
                                           GTK_CSS_AFFECTS_BACKGROUND | GTK_CSS_AFFECTS_BORDER,
                                           border_corner_radius_value_parse,
-                                          gtk_css_style_property_token_parse_default,
+                                          (GtkCssStylePropertyTokenParseFunc) 
gtk_css_corner_value_token_parse,
                                           NULL,
                                           NULL,
                                           _gtk_css_corner_value_new (_gtk_css_number_value_new (0, 
GTK_CSS_PX),
@@ -1781,7 +1781,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_STYLE_PROPERTY_ANIMATED,
                                           GTK_CSS_AFFECTS_BACKGROUND | GTK_CSS_AFFECTS_BORDER,
                                           border_corner_radius_value_parse,
-                                          gtk_css_style_property_token_parse_default,
+                                          (GtkCssStylePropertyTokenParseFunc) 
gtk_css_corner_value_token_parse,
                                           NULL,
                                           NULL,
                                           _gtk_css_corner_value_new (_gtk_css_number_value_new (0, 
GTK_CSS_PX),
@@ -1792,7 +1792,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_STYLE_PROPERTY_ANIMATED,
                                           GTK_CSS_AFFECTS_BACKGROUND | GTK_CSS_AFFECTS_BORDER,
                                           border_corner_radius_value_parse,
-                                          gtk_css_style_property_token_parse_default,
+                                          (GtkCssStylePropertyTokenParseFunc) 
gtk_css_corner_value_token_parse,
                                           NULL,
                                           NULL,
                                           _gtk_css_corner_value_new (_gtk_css_number_value_new (0, 
GTK_CSS_PX),
@@ -1835,7 +1835,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_STYLE_PROPERTY_ANIMATED,
                                           GTK_CSS_AFFECTS_OUTLINE,
                                           border_corner_radius_value_parse,
-                                          gtk_css_style_property_token_parse_default,
+                                          (GtkCssStylePropertyTokenParseFunc) 
gtk_css_corner_value_token_parse,
                                           NULL,
                                           NULL,
                                           _gtk_css_corner_value_new (_gtk_css_number_value_new (0, 
GTK_CSS_PX),
@@ -1847,7 +1847,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_STYLE_PROPERTY_ANIMATED,
                                           GTK_CSS_AFFECTS_OUTLINE,
                                           border_corner_radius_value_parse,
-                                          gtk_css_style_property_token_parse_default,
+                                          (GtkCssStylePropertyTokenParseFunc) 
gtk_css_corner_value_token_parse,
                                           NULL,
                                           NULL,
                                           _gtk_css_corner_value_new (_gtk_css_number_value_new (0, 
GTK_CSS_PX),
@@ -1859,7 +1859,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_STYLE_PROPERTY_ANIMATED,
                                           GTK_CSS_AFFECTS_OUTLINE,
                                           border_corner_radius_value_parse,
-                                          gtk_css_style_property_token_parse_default,
+                                          (GtkCssStylePropertyTokenParseFunc) 
gtk_css_corner_value_token_parse,
                                           NULL,
                                           NULL,
                                           _gtk_css_corner_value_new (_gtk_css_number_value_new (0, 
GTK_CSS_PX),
@@ -1871,7 +1871,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_STYLE_PROPERTY_ANIMATED,
                                           GTK_CSS_AFFECTS_OUTLINE,
                                           border_corner_radius_value_parse,
-                                          gtk_css_style_property_token_parse_default,
+                                          (GtkCssStylePropertyTokenParseFunc) 
gtk_css_corner_value_token_parse,
                                           NULL,
                                           NULL,
                                           _gtk_css_corner_value_new (_gtk_css_number_value_new (0, 
GTK_CSS_PX),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]