[gtk+] css: Disallow bypassing value computation



commit a1f7c459b75fe47e2abb7e856e6d4a4ad5208cb9
Author: Benjamin Otte <otte redhat com>
Date:   Fri Oct 24 20:17:11 2014 +0200

    css: Disallow bypassing value computation
    
    This special code was added back in the days when computation wasn't
    idemptotent. These days it is.
    
    Also, the bypass code path is only used in fallback code that is pretty
    much unused.

 gtk/gtkcsscomputedvalues.c        |   56 ++++++++++++++----------------------
 gtk/gtkcsscomputedvaluesprivate.h |    5 ---
 gtk/gtkcsslookup.c                |   44 +---------------------------
 gtk/gtkcsslookupprivate.h         |    5 ---
 gtk/gtkstyleproperties.c          |    2 +-
 5 files changed, 25 insertions(+), 87 deletions(-)
---
diff --git a/gtk/gtkcsscomputedvalues.c b/gtk/gtkcsscomputedvalues.c
index 52d6e5e..18d5a8d 100644
--- a/gtk/gtkcsscomputedvalues.c
+++ b/gtk/gtkcsscomputedvalues.c
@@ -146,40 +146,6 @@ _gtk_css_computed_values_compute_value (GtkCssComputedValues    *values,
 
   value = _gtk_css_value_compute (specified, id, provider, scale, values, parent_values, &dependencies);
 
-  _gtk_css_computed_values_set_value (values, id, value, dependencies, section);
-
-  _gtk_css_value_unref (value);
-  _gtk_css_value_unref (specified);
-}
-
-void
-_gtk_css_computed_values_set_animated_value (GtkCssComputedValues *values,
-                                             guint                 id,
-                                             GtkCssValue          *value)
-{
-  gtk_internal_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
-  gtk_internal_return_if_fail (value != NULL);
-
-  if (values->animated_values == NULL)
-    values->animated_values = g_ptr_array_new_with_free_func ((GDestroyNotify)_gtk_css_value_unref);
-  if (id >= values->animated_values->len)
-   g_ptr_array_set_size (values->animated_values, id + 1);
-
-  if (g_ptr_array_index (values->animated_values, id))
-    _gtk_css_value_unref (g_ptr_array_index (values->animated_values, id));
-  g_ptr_array_index (values->animated_values, id) = _gtk_css_value_ref (value);
-
-}
-
-void
-_gtk_css_computed_values_set_value (GtkCssComputedValues *values,
-                                    guint                 id,
-                                    GtkCssValue          *value,
-                                    GtkCssDependencies    dependencies,
-                                    GtkCssSection        *section)
-{
-  gtk_internal_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
-
   if (values->values == NULL)
     values->values = g_ptr_array_new_full (_gtk_css_style_property_get_n_properties (),
                                           (GDestroyNotify)_gtk_css_value_unref);
@@ -214,6 +180,28 @@ _gtk_css_computed_values_set_value (GtkCssComputedValues *values,
 
       g_ptr_array_index (values->sections, id) = gtk_css_section_ref (section);
     }
+
+  _gtk_css_value_unref (value);
+  _gtk_css_value_unref (specified);
+}
+
+void
+_gtk_css_computed_values_set_animated_value (GtkCssComputedValues *values,
+                                             guint                 id,
+                                             GtkCssValue          *value)
+{
+  gtk_internal_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
+  gtk_internal_return_if_fail (value != NULL);
+
+  if (values->animated_values == NULL)
+    values->animated_values = g_ptr_array_new_with_free_func ((GDestroyNotify)_gtk_css_value_unref);
+  if (id >= values->animated_values->len)
+   g_ptr_array_set_size (values->animated_values, id + 1);
+
+  if (g_ptr_array_index (values->animated_values, id))
+    _gtk_css_value_unref (g_ptr_array_index (values->animated_values, id));
+  g_ptr_array_index (values->animated_values, id) = _gtk_css_value_ref (value);
+
 }
 
 GtkCssValue *
diff --git a/gtk/gtkcsscomputedvaluesprivate.h b/gtk/gtkcsscomputedvaluesprivate.h
index 059caee..6927446 100644
--- a/gtk/gtkcsscomputedvaluesprivate.h
+++ b/gtk/gtkcsscomputedvaluesprivate.h
@@ -71,11 +71,6 @@ void                    _gtk_css_computed_values_compute_value        (GtkCssCom
                                                                        guint                     id,
                                                                        GtkCssValue              *specified,
                                                                        GtkCssSection            *section);
-void                    _gtk_css_computed_values_set_value            (GtkCssComputedValues     *values,
-                                                                       guint                     id,
-                                                                       GtkCssValue              *value,
-                                                                       GtkCssDependencies        
dependencies,
-                                                                       GtkCssSection            *section);
 void                    _gtk_css_computed_values_set_animated_value   (GtkCssComputedValues     *values,
                                                                        guint                     id,
                                                                        GtkCssValue              *value);
diff --git a/gtk/gtkcsslookup.c b/gtk/gtkcsslookup.c
index 8166ee9..2c8b6b8 100644
--- a/gtk/gtkcsslookup.c
+++ b/gtk/gtkcsslookup.c
@@ -92,40 +92,6 @@ _gtk_css_lookup_set (GtkCssLookup  *lookup,
 }
 
 /**
- * _gtk_css_lookup_set_computed:
- * @lookup: the lookup
- * @id: id of the property to set, see _gtk_style_property_get_id()
- * @section: (allow-none): The @section the value was defined in or %NULL
- * @value: the “computed value” to use
- *
- * Sets the @value for a given @id. No value may have been set for @id
- * before. See _gtk_css_lookup_is_missing(). This function is used to
- * set the “winning declaration” of a lookup. Note that for performance
- * reasons @value and @section are not copied. It is your responsibility
- * to ensure they are kept alive until _gtk_css_lookup_free() is called.
- *
- * As opposed to _gtk_css_lookup_set(), this function forces a computed
- * value and will not cause computation to happen. In particular, with this
- * method relative lengths or symbolic colors can not be used. This is
- * usually only useful for doing overrides. It should not be used for proper
- * CSS.
- **/
-void
-_gtk_css_lookup_set_computed (GtkCssLookup  *lookup,
-                              guint          id,
-                              GtkCssSection *section,
-                              GtkCssValue  *value)
-{
-  g_return_if_fail (lookup != NULL);
-  g_return_if_fail (_gtk_bitmask_get (lookup->missing, id));
-  g_return_if_fail (value != NULL);
-
-  lookup->missing = _gtk_bitmask_set (lookup->missing, id, FALSE);
-  lookup->values[id].computed = value;
-  lookup->values[id].section = section;
-}
-
-/**
  * _gtk_css_lookup_resolve:
  * @lookup: the lookup
  * @context: the context the values are resolved for
@@ -155,14 +121,8 @@ _gtk_css_lookup_resolve (GtkCssLookup            *lookup,
 
   for (i = 0; i < n; i++)
     {
-      if (lookup->values[i].computed)
-        _gtk_css_computed_values_set_value (values,
-                                            i,
-                                            lookup->values[i].computed,
-                                            0,
-                                            lookup->values[i].section);
-      else if (lookup->values[i].value ||
-               _gtk_bitmask_get (lookup->missing, i))
+      if (lookup->values[i].value ||
+          _gtk_bitmask_get (lookup->missing, i))
         _gtk_css_computed_values_compute_value (values,
                                                 provider,
                                                scale,
diff --git a/gtk/gtkcsslookupprivate.h b/gtk/gtkcsslookupprivate.h
index 9287ccb..5b257c5 100644
--- a/gtk/gtkcsslookupprivate.h
+++ b/gtk/gtkcsslookupprivate.h
@@ -31,7 +31,6 @@ typedef struct _GtkCssLookup GtkCssLookup;
 typedef struct {
   GtkCssSection     *section;
   GtkCssValue       *value;
-  GtkCssValue       *computed;
 } GtkCssLookupValue;
 
 struct _GtkCssLookup {
@@ -49,10 +48,6 @@ void                    _gtk_css_lookup_set                     (GtkCssLookup
                                                                  guint                       id,
                                                                  GtkCssSection              *section,
                                                                  GtkCssValue                *value);
-void                    _gtk_css_lookup_set_computed            (GtkCssLookup               *lookup,
-                                                                 guint                       id,
-                                                                 GtkCssSection              *section,
-                                                                 GtkCssValue                *value);
 void                    _gtk_css_lookup_resolve                 (GtkCssLookup               *lookup,
                                                                  GtkStyleProviderPrivate    *provider,
                                                                 int                         scale,
diff --git a/gtk/gtkstyleproperties.c b/gtk/gtkstyleproperties.c
index e617020..d751227 100644
--- a/gtk/gtkstyleproperties.c
+++ b/gtk/gtkstyleproperties.c
@@ -327,7 +327,7 @@ gtk_style_properties_provider_lookup (GtkStyleProviderPrivate *provider,
       if (value == NULL)
         continue;
 
-      _gtk_css_lookup_set_computed (lookup, id, NULL, value);
+      _gtk_css_lookup_set (lookup, id, NULL, value);
     }
 }
 


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