[gtk+/wip/css: 24/97] css: Add generic support for 'inherit' and 'initial'



commit 5b50cf8d8f8d7966f1757c422508a1f0b66cb8fd
Author: Benjamin Otte <otte redhat com>
Date:   Thu Dec 29 16:18:12 2011 +0100

    css: Add generic support for 'inherit' and 'initial'
    
    CSS3 says they work for every property, so here we go.

 gtk/gtkcssprovider.c     |    4 ++++
 gtk/gtkcsstypesprivate.h |    2 +-
 gtk/gtkstyleproperty.c   |   29 +++++++++++++++++++++++++++--
 3 files changed, 32 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index f5c74ba..9b1831e 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -1533,6 +1533,10 @@ gtk_css_style_provider_lookup (GtkStyleProviderPrivate *provider,
       if (ruleset->style == NULL)
         continue;
 
+      if (!_gtk_bitmask_intersects (_gtk_css_lookup_get_missing (lookup),
+                                    ruleset->set_styles))
+        continue;
+
       if (!gtk_css_ruleset_matches (ruleset, path, state))
         continue;
 
diff --git a/gtk/gtkcsstypesprivate.h b/gtk/gtkcsstypesprivate.h
index c0c8848..ff1a844 100644
--- a/gtk/gtkcsstypesprivate.h
+++ b/gtk/gtkcsstypesprivate.h
@@ -27,7 +27,7 @@ G_BEGIN_DECLS
 typedef enum {
   GTK_CSS_INHERIT,
   GTK_CSS_INITIAL,
-  GTK_CSS_CURRENT_COLOR
+  GTK_CSS_CURRENT_COLOR /*< nick=currentColor >*/
 } GtkCssSpecialValue;
 
 typedef enum {
diff --git a/gtk/gtkstyleproperty.c b/gtk/gtkstyleproperty.c
index 5eade84..81f1cfd 100644
--- a/gtk/gtkstyleproperty.c
+++ b/gtk/gtkstyleproperty.c
@@ -2326,7 +2326,30 @@ _gtk_style_property_parse_value (const GtkStyleProperty *property,
 
   if (property)
     {
-      if (_gtk_css_parser_try (parser, "none", 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 (_gtk_css_parser_try (parser, "none", TRUE))
         {
           /* Insert the default value, so it has an opportunity
            * to override other style providers when merged
@@ -2383,7 +2406,9 @@ _gtk_style_property_print_value (const GtkStyleProperty *property,
 
   css_string_funcs_init ();
 
-  if (property)
+  if (G_VALUE_HOLDS (value, GTK_TYPE_CSS_SPECIAL_VALUE))
+    func = enum_value_print;
+  else if (property)
     func = property->print_func;
   else
     func = NULL;



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