[gtk+/wip/css: 64/154] styleproperty: require property in _gtk_style_property_parse_value()



commit 44af67f39d0e8b45a95d9f13e3fdd7fb2b83a464
Author: Benjamin Otte <otte redhat com>
Date:   Mon Jan 2 00:14:23 2012 +0100

    styleproperty: require property in _gtk_style_property_parse_value()
    
    Other code uses _gtk_css_style_parse_value() instead now.

 gtk/gtkcssprovider.c              |    8 ++--
 gtk/gtkcssshorthandpropertyimpl.c |    9 ++--
 gtk/gtkstyleproperty.c            |   87 ++++++++++++++++++-------------------
 3 files changed, 51 insertions(+), 53 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 1027086..e15861e 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -28,6 +28,7 @@
 #include "gtkcssproviderprivate.h"
 
 #include "gtkbitmaskprivate.h"
+#include "gtkcssstylefuncsprivate.h"
 #include "gtkcssparserprivate.h"
 #include "gtkcsssectionprivate.h"
 #include "gtkcssselectorprivate.h"
@@ -1485,10 +1486,9 @@ gtk_css_provider_get_style_property (GtkStyleProvider *provider,
                                          gtk_css_section_get_file (val->section),
                                          g_value_get_string (&val->value));
 
-          found = _gtk_style_property_parse_value (NULL,
-                                                   value,
-                                                   scanner->parser,
-                                                   NULL);
+          found = _gtk_css_style_parse_value (value,
+                                              scanner->parser,
+                                              NULL);
 
           gtk_css_scanner_destroy (scanner);
 
diff --git a/gtk/gtkcssshorthandpropertyimpl.c b/gtk/gtkcssshorthandpropertyimpl.c
index 023a38f..a658efd 100644
--- a/gtk/gtkcssshorthandpropertyimpl.c
+++ b/gtk/gtkcssshorthandpropertyimpl.c
@@ -26,6 +26,7 @@
 #include <math.h>
 
 #include "gtkborderimageprivate.h"
+#include "gtkcssstylefuncsprivate.h"
 #include "gtkcsstypesprivate.h"
 
 /* this is in case round() is not provided by the compiler, 
@@ -54,7 +55,7 @@ border_image_value_parse (GtkCssParser *parser,
 
   g_value_init (&temp, CAIRO_GOBJECT_TYPE_PATTERN);
 
-  if (!_gtk_style_property_parse_value (NULL, &temp, parser, base))
+  if (!_gtk_css_style_parse_value (&temp, parser, base))
     return FALSE;
 
   boxed_type = G_VALUE_TYPE (&temp);
@@ -66,7 +67,7 @@ border_image_value_parse (GtkCssParser *parser,
   g_value_unset (&temp);
   g_value_init (&temp, GTK_TYPE_BORDER);
 
-  if (!_gtk_style_property_parse_value (NULL, &temp, parser, base))
+  if (!_gtk_css_style_parse_value (&temp, parser, base))
     goto out;
 
   parsed_slice = g_value_get_boxed (&temp);
@@ -77,7 +78,7 @@ border_image_value_parse (GtkCssParser *parser,
       g_value_unset (&temp);
       g_value_init (&temp, GTK_TYPE_BORDER);
 
-      if (!_gtk_style_property_parse_value (NULL, &temp, parser, base))
+      if (!_gtk_css_style_parse_value (&temp, parser, base))
         goto out;
 
       width = g_value_dup_boxed (&temp);
@@ -86,7 +87,7 @@ border_image_value_parse (GtkCssParser *parser,
   g_value_unset (&temp);
   g_value_init (&temp, GTK_TYPE_CSS_BORDER_IMAGE_REPEAT);
 
-  if (!_gtk_style_property_parse_value (NULL, &temp, parser, base))
+  if (!_gtk_css_style_parse_value (&temp, parser, base))
     goto out;
 
   parsed_repeat = g_value_get_boxed (&temp);
diff --git a/gtk/gtkstyleproperty.c b/gtk/gtkstyleproperty.c
index 1c638b3..b444cf1 100644
--- a/gtk/gtkstyleproperty.c
+++ b/gtk/gtkstyleproperty.c
@@ -385,56 +385,53 @@ _gtk_style_property_parse_value (GtkStyleProperty *property,
                                  GtkCssParser     *parser,
                                  GFile            *base)
 {
+  g_return_val_if_fail (GTK_IS_STYLE_PROPERTY (property), FALSE);
   g_return_val_if_fail (value != NULL, FALSE);
   g_return_val_if_fail (parser != NULL, FALSE);
 
-  if (property)
+  if (_gtk_css_parser_try (parser, "initial", TRUE))
     {
-      if (_gtk_css_parser_try (parser, "initial", TRUE))
-        {
-          /* the initial value can be explicitly specified with the
-           * âinitialâ keyword which all properties accept.
-           */
-          g_value_unset (value);
-          g_value_init (value, GTK_TYPE_CSS_SPECIAL_VALUE);
-          g_value_set_enum (value, GTK_CSS_INITIAL);
-          return TRUE;
-        }
-      else if (_gtk_css_parser_try (parser, "inherit", TRUE))
-        {
-          /* All properties accept the âinheritâ value which
-           * explicitly specifies that the value will be determined
-           * by inheritance. The âinheritâ value can be used to
-           * strengthen inherited values in the cascade, and it can
-           * also be used on properties that are not normally inherited.
-           */
-          g_value_unset (value);
-          g_value_init (value, GTK_TYPE_CSS_SPECIAL_VALUE);
-          g_value_set_enum (value, GTK_CSS_INHERIT);
-          return TRUE;
-        }
-      else if (property->property_parse_func)
-        {
-          GError *error = NULL;
-          char *value_str;
-          gboolean success;
-          
-          value_str = _gtk_css_parser_read_value (parser);
-          if (value_str == NULL)
-            return FALSE;
-          
-          success = (*property->property_parse_func) (value_str, value, &error);
-
-          g_free (value_str);
-
-          return success;
-        }
-
-      if (property->parse_func)
-        return (* property->parse_func) (parser, base, value);
+      /* the initial value can be explicitly specified with the
+       * âinitialâ keyword which all properties accept.
+       */
+      g_value_unset (value);
+      g_value_init (value, GTK_TYPE_CSS_SPECIAL_VALUE);
+      g_value_set_enum (value, GTK_CSS_INITIAL);
+      return TRUE;
     }
-
-  return _gtk_css_style_parse_value (value, parser, base);
+  else if (_gtk_css_parser_try (parser, "inherit", TRUE))
+    {
+      /* All properties accept the âinheritâ value which
+       * explicitly specifies that the value will be determined
+       * by inheritance. The âinheritâ value can be used to
+       * strengthen inherited values in the cascade, and it can
+       * also be used on properties that are not normally inherited.
+       */
+      g_value_unset (value);
+      g_value_init (value, GTK_TYPE_CSS_SPECIAL_VALUE);
+      g_value_set_enum (value, GTK_CSS_INHERIT);
+      return TRUE;
+    }
+  else if (property->property_parse_func)
+    {
+      GError *error = NULL;
+      char *value_str;
+      gboolean success;
+      
+      value_str = _gtk_css_parser_read_value (parser);
+      if (value_str == NULL)
+        return FALSE;
+      
+      success = (*property->property_parse_func) (value_str, value, &error);
+
+      g_free (value_str);
+
+      return success;
+    }
+  else if (property->parse_func)
+    return (* property->parse_func) (parser, base, value);
+  else
+    return _gtk_css_style_parse_value (value, parser, base);
 }
 
 GParameter *



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