[gtk+] computedvalues: Pass dependencies to set_value()



commit 6fbd8b00031c4627085cf4bf300dc408a39833c1
Author: Benjamin Otte <otte redhat com>
Date:   Fri Aug 24 17:00:02 2012 +0200

    computedvalues: Pass dependencies to set_value()
    
    This simplifies the code.

 gtk/gtkcssanimatedvalues.c        |    1 +
 gtk/gtkcsscomputedvalues.c        |   35 ++++++++++++++---------------------
 gtk/gtkcsscomputedvaluesprivate.h |    1 +
 gtk/gtkcsslookup.c                |    1 +
 gtk/gtkcsstransition.c            |    3 ++-
 5 files changed, 19 insertions(+), 22 deletions(-)
---
diff --git a/gtk/gtkcssanimatedvalues.c b/gtk/gtkcssanimatedvalues.c
index 7617faa..c337849 100644
--- a/gtk/gtkcssanimatedvalues.c
+++ b/gtk/gtkcssanimatedvalues.c
@@ -251,6 +251,7 @@ _gtk_css_animated_values_new (GtkCssComputedValues *computed,
       _gtk_css_computed_values_set_value (GTK_CSS_COMPUTED_VALUES (values), 
                                           i,
                                           value,
+                                          0,
                                           _gtk_css_computed_values_get_section (computed, i));
     }
 
diff --git a/gtk/gtkcsscomputedvalues.c b/gtk/gtkcsscomputedvalues.c
index 63b0ee7..efca159 100644
--- a/gtk/gtkcsscomputedvalues.c
+++ b/gtk/gtkcsscomputedvalues.c
@@ -108,12 +108,11 @@ _gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
                                         GtkCssSection        *section)
 {
   GtkCssDependencies dependencies;
+  GtkCssValue *value;
 
   g_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
   g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
 
-  gtk_css_computed_values_ensure_array (values, id + 1);
-
   /* http://www.w3.org/TR/css3-cascade/#cascade
    * Then, for every element, the value for each property can be found
    * by following this pseudo-algorithm:
@@ -131,27 +130,11 @@ _gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
   else
     _gtk_css_value_ref (specified);
 
-  g_ptr_array_index (values->values, id) = _gtk_css_value_compute (specified, id, context, &dependencies);
+  value = _gtk_css_value_compute (specified, id, context, &dependencies);
 
-  if (dependencies & (GTK_CSS_DEPENDS_ON_PARENT | GTK_CSS_EQUALS_PARENT))
-    values->depends_on_parent = _gtk_bitmask_set (values->depends_on_parent, id, TRUE);
-  if (dependencies & (GTK_CSS_EQUALS_PARENT))
-    values->equals_parent = _gtk_bitmask_set (values->equals_parent, id, TRUE);
-  if (dependencies & (GTK_CSS_DEPENDS_ON_COLOR))
-    values->depends_on_color = _gtk_bitmask_set (values->depends_on_color, id, TRUE);
-  if (dependencies & (GTK_CSS_DEPENDS_ON_FONT_SIZE))
-    values->depends_on_font_size = _gtk_bitmask_set (values->depends_on_font_size, id, TRUE);
+  _gtk_css_computed_values_set_value (values, id, value, dependencies, section);
 
-  if (section)
-    {
-      if (values->sections == NULL)
-        values->sections = g_ptr_array_new_with_free_func (maybe_unref_section);
-      if (values->sections->len <= id)
-        g_ptr_array_set_size (values->sections, id + 1);
-
-      g_ptr_array_index (values->sections, id) = gtk_css_section_ref (section);
-    }
-  
+  _gtk_css_value_unref (value);
   _gtk_css_value_unref (specified);
 }
                                     
@@ -159,6 +142,7 @@ void
 _gtk_css_computed_values_set_value (GtkCssComputedValues *values,
                                     guint                 id,
                                     GtkCssValue          *value,
+                                    GtkCssDependencies    dependencies,
                                     GtkCssSection        *section)
 {
   g_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
@@ -169,6 +153,15 @@ _gtk_css_computed_values_set_value (GtkCssComputedValues *values,
     _gtk_css_value_unref (g_ptr_array_index (values->values, id));
   g_ptr_array_index (values->values, id) = _gtk_css_value_ref (value);
 
+  if (dependencies & (GTK_CSS_DEPENDS_ON_PARENT | GTK_CSS_EQUALS_PARENT))
+    values->depends_on_parent = _gtk_bitmask_set (values->depends_on_parent, id, TRUE);
+  if (dependencies & (GTK_CSS_EQUALS_PARENT))
+    values->equals_parent = _gtk_bitmask_set (values->equals_parent, id, TRUE);
+  if (dependencies & (GTK_CSS_DEPENDS_ON_COLOR))
+    values->depends_on_color = _gtk_bitmask_set (values->depends_on_color, id, TRUE);
+  if (dependencies & (GTK_CSS_DEPENDS_ON_FONT_SIZE))
+    values->depends_on_font_size = _gtk_bitmask_set (values->depends_on_font_size, id, TRUE);
+
   if (section)
     {
       if (values->sections == NULL)
diff --git a/gtk/gtkcsscomputedvaluesprivate.h b/gtk/gtkcsscomputedvaluesprivate.h
index 239afca..799121b 100644
--- a/gtk/gtkcsscomputedvaluesprivate.h
+++ b/gtk/gtkcsscomputedvaluesprivate.h
@@ -68,6 +68,7 @@ void                    _gtk_css_computed_values_compute_value        (GtkCssCom
 void                    _gtk_css_computed_values_set_value            (GtkCssComputedValues     *values,
                                                                        guint                     id,
                                                                        GtkCssValue              *value,
+                                                                       GtkCssDependencies        dependencies,
                                                                        GtkCssSection            *section);
                                                                         
 GtkCssValue *           _gtk_css_computed_values_get_value            (GtkCssComputedValues     *values,
diff --git a/gtk/gtkcsslookup.c b/gtk/gtkcsslookup.c
index 940f68c..e0f0af7 100644
--- a/gtk/gtkcsslookup.c
+++ b/gtk/gtkcsslookup.c
@@ -167,6 +167,7 @@ _gtk_css_lookup_resolve (GtkCssLookup         *lookup,
         _gtk_css_computed_values_set_value (values,
                                             i,
                                             lookup->values[i].computed,
+                                            0,
                                             lookup->values[i].section);
       else
         _gtk_css_computed_values_compute_value (values,
diff --git a/gtk/gtkcsstransition.c b/gtk/gtkcsstransition.c
index 79b803d..cbedc8b 100644
--- a/gtk/gtkcsstransition.c
+++ b/gtk/gtkcsstransition.c
@@ -51,7 +51,8 @@ gtk_css_transition_set_values (GtkStyleAnimation    *animation,
         value = _gtk_css_value_ref (transition->end);
     }
 
-  _gtk_css_computed_values_set_value (values, transition->property, value, NULL);
+  /* XXX: Is using 0 correct here? */
+  _gtk_css_computed_values_set_value (values, transition->property, value, 0, NULL);
   _gtk_css_value_unref (value);
 
   return _gtk_bitmask_set (changed, transition->property, TRUE);



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