[gtk+] css: Implement "unset"



commit 3a72e2fb2483d4dd26eb74319613ffb505d89128
Author: Benjamin Otte <otte redhat com>
Date:   Sun May 11 03:08:40 2014 +0200

    css: Implement "unset"
    
    Quoting the spec:
      If the cascaded value of a property is the unset keyword,
      then if it is an inherited property, this is treated as
      inherit, and if it is not, this is treated as initial.
    
    Spec in question:
      http://dev.w3.org/csswg/css-cascade/
    
    Also use unset in the reset-to-defaults.css we use to reset css in
    reftests.

 gtk/Makefile.am                          |    2 +
 gtk/gtkcssinheritvalue.c                 |    6 ++
 gtk/gtkcssinheritvalueprivate.h          |    1 +
 gtk/gtkcssshorthandproperty.c            |   12 +++
 gtk/gtkcssstyleproperty.c                |    9 +++
 testsuite/reftests/reset-to-defaults.css |  108 +++++++++++++++---------------
 6 files changed, 84 insertions(+), 54 deletions(-)
---
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index e3fa202..38a2492 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -483,6 +483,7 @@ gtk_private_h_sources =             \
        gtkcssstylepropertyprivate.h \
        gtkcsstransitionprivate.h       \
        gtkcsstypedvalueprivate.h       \
+       gtkcssunsetvalueprivate.h       \
        gtkcssvalueprivate.h    \
        gtkcustompaperunixdialog.h \
        gtkdialogprivate.h      \
@@ -731,6 +732,7 @@ gtk_base_c_sources =                \
        gtkcssstylepropertyimpl.c \
        gtkcsstransition.c      \
        gtkcsstypedvalue.c      \
+       gtkcssunsetvalue.c      \
        gtkcssvalue.c           \
        gtkcsstypes.c           \
        gtkdialog.c             \
diff --git a/gtk/gtkcssinheritvalue.c b/gtk/gtkcssinheritvalue.c
index 053245c..bfea779 100644
--- a/gtk/gtkcssinheritvalue.c
+++ b/gtk/gtkcssinheritvalue.c
@@ -97,3 +97,9 @@ _gtk_css_inherit_value_new (void)
 {
   return _gtk_css_value_ref (&inherit);
 }
+
+GtkCssValue *
+_gtk_css_inherit_value_get (void)
+{
+  return &inherit;
+}
diff --git a/gtk/gtkcssinheritvalueprivate.h b/gtk/gtkcssinheritvalueprivate.h
index ae69a6b..6c7fe8a 100644
--- a/gtk/gtkcssinheritvalueprivate.h
+++ b/gtk/gtkcssinheritvalueprivate.h
@@ -25,6 +25,7 @@
 G_BEGIN_DECLS
 
 GtkCssValue *   _gtk_css_inherit_value_new            (void);
+GtkCssValue *   _gtk_css_inherit_value_get            (void);
 
 G_END_DECLS
 
diff --git a/gtk/gtkcssshorthandproperty.c b/gtk/gtkcssshorthandproperty.c
index c6ca614..68bb064 100644
--- a/gtk/gtkcssshorthandproperty.c
+++ b/gtk/gtkcssshorthandproperty.c
@@ -25,6 +25,7 @@
 #include "gtkcssinheritvalueprivate.h"
 #include "gtkcssinitialvalueprivate.h"
 #include "gtkcssstylefuncsprivate.h"
+#include "gtkcssunsetvalueprivate.h"
 #include "gtkintl.h"
 
 enum {
@@ -118,6 +119,17 @@ gtk_css_shorthand_property_parse_value (GtkStyleProperty *property,
           data[i] = _gtk_css_inherit_value_new ();
         }
     }
+  else if (_gtk_css_parser_try (parser, "unset", TRUE))
+    {
+      /* If the cascaded value of a property is the unset keyword,
+       * then if it is an inherited property, this is treated as
+       * inherit, and if it is not, this is treated as initial.
+       */
+      for (i = 0; i < shorthand->subproperties->len; i++)
+        {
+          data[i] = _gtk_css_unset_value_new ();
+        }
+    }
   else if (!shorthand->parse (shorthand, data, parser))
     {
       for (i = 0; i < shorthand->subproperties->len; i++)
diff --git a/gtk/gtkcssstyleproperty.c b/gtk/gtkcssstyleproperty.c
index e2bfa77..5053892 100644
--- a/gtk/gtkcssstyleproperty.c
+++ b/gtk/gtkcssstyleproperty.c
@@ -26,6 +26,7 @@
 #include "gtkcssinitialvalueprivate.h"
 #include "gtkcssstylefuncsprivate.h"
 #include "gtkcsstypesprivate.h"
+#include "gtkcssunsetvalueprivate.h"
 #include "gtkintl.h"
 #include "gtkprivatetypebuiltins.h"
 #include "gtkstylepropertiesprivate.h"
@@ -255,6 +256,14 @@ gtk_css_style_property_parse_value (GtkStyleProperty *property,
        */
       return _gtk_css_inherit_value_new ();
     }
+  else if (_gtk_css_parser_try (parser, "unset", TRUE))
+    {
+      /* If the cascaded value of a property is the unset keyword,
+       * then if it is an inherited property, this is treated as
+       * inherit, and if it is not, this is treated as initial.
+       */
+      return _gtk_css_unset_value_new ();
+    }
 
   return (* style_property->parse_value) (style_property, parser);
 }
diff --git a/testsuite/reftests/reset-to-defaults.css b/testsuite/reftests/reset-to-defaults.css
index 1c27a8e..8654a5b 100644
--- a/testsuite/reftests/reset-to-defaults.css
+++ b/testsuite/reftests/reset-to-defaults.css
@@ -7,60 +7,60 @@
  */
 
 * {
-  color: inherit;
-  font-size: inherit;
-  background-color: initial;
-  font-family: inherit;
-  font-style: inherit;
-  font-variant: inherit;
-  font-weight: inherit;
-  text-shadow: inherit;
-  icon-shadow: inherit;
-  box-shadow: initial;
-  margin-top: initial;
-  margin-left: initial;
-  margin-bottom: initial;
-  margin-right: initial;
-  padding-top: initial;
-  padding-left: initial;
-  padding-bottom: initial;
-  padding-right: initial;
-  border-top-style: initial;
-  border-top-width: initial;
-  border-left-style: initial;
-  border-left-width: initial;
-  border-bottom-style: initial;
-  border-bottom-width: initial;
-  border-right-style: initial;
-  border-right-width: initial;
-  border-top-left-radius: initial;
-  border-top-right-radius: initial;
-  border-bottom-right-radius: initial;
-  border-bottom-left-radius: initial;
-  outline-style: initial;
-  outline-width: initial;
-  outline-offset: initial;
-  background-clip: initial;
-  background-origin: initial;
-  background-size: initial;
-  background-position: initial;
-  border-top-color: initial;
-  border-right-color: initial;
-  border-bottom-color: initial;
-  border-left-color: initial;
-  outline-color:  initial;
-  background-repeat: initial;
-  background-image: initial;
-  border-image-source: initial;
-  border-image-repeat: initial;
-  border-image-slice: initial;
-  border-image-width: initial;
-  transition-property: initial;
-  transition-duration: initial;
-  transition-timing-function: initial;
-  transition-delay: initial;
-  engine: initial;
-  gtk-key-bindings: initial;
+  color: unset;
+  font-size: unset;
+  background-color: unset;
+  font-family: unset;
+  font-style: unset;
+  font-variant: unset;
+  font-weight: unset;
+  text-shadow: unset;
+  icon-shadow: unset;
+  box-shadow: unset;
+  margin-top: unset;
+  margin-left: unset;
+  margin-bottom: unset;
+  margin-right: unset;
+  padding-top: unset;
+  padding-left: unset;
+  padding-bottom: unset;
+  padding-right: unset;
+  border-top-style: unset;
+  border-top-width: unset;
+  border-left-style: unset;
+  border-left-width: unset;
+  border-bottom-style: unset;
+  border-bottom-width: unset;
+  border-right-style: unset;
+  border-right-width: unset;
+  border-top-left-radius: unset;
+  border-top-right-radius: unset;
+  border-bottom-right-radius: unset;
+  border-bottom-left-radius: unset;
+  outline-style: unset;
+  outline-width: unset;
+  outline-offset: unset;
+  background-clip: unset;
+  background-origin: unset;
+  background-size: unset;
+  background-position: unset;
+  border-top-color: unset;
+  border-right-color: unset;
+  border-bottom-color: unset;
+  border-left-color: unset;
+  outline-color:  unset;
+  background-repeat: unset;
+  background-image: unset;
+  border-image-source: unset;
+  border-image-repeat: unset;
+  border-image-slice: unset;
+  border-image-width: unset;
+  transition-property: unset;
+  transition-duration: unset;
+  transition-timing-function: unset;
+  transition-delay: unset;
+  engine: unset;
+  gtk-key-bindings: unset;
 
   -GtkWidget-focus-line-width: 0;
   -GtkWidget-focus-padding: 0;


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