[gtk+/composite-templates] css: Handle some more simple cases of dependencies



commit 6b99aa8d90ddd5ea03eb9582fab252a2ba5e1f29
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Aug 25 11:22:14 2012 -0400

    css: Handle some more simple cases of dependencies

 gtk/gtkcssarrayvalue.c   |    8 +++++---
 gtk/gtkcssbgsizevalue.c  |   18 +++++++++++++++---
 gtk/gtkcssshadowsvalue.c |    6 +++---
 gtk/gtkcssshadowvalue.c  |   32 ++++++++++++++++++++++++--------
 4 files changed, 47 insertions(+), 17 deletions(-)
---
diff --git a/gtk/gtkcssarrayvalue.c b/gtk/gtkcssarrayvalue.c
index 418ac65..69f81bf 100644
--- a/gtk/gtkcssarrayvalue.c
+++ b/gtk/gtkcssarrayvalue.c
@@ -49,16 +49,18 @@ gtk_css_value_array_compute (GtkCssValue        *value,
   GtkCssValue *result;
   gboolean changed = FALSE;
   guint i;
+  GtkCssDependencies child_deps;
 
   if (value->n_values == 0)
     return _gtk_css_value_ref (value);
 
-  *dependencies = GTK_CSS_DEPENDS_ON_EVERYTHING;
-
   result = _gtk_css_array_value_new_from_array (value->values, value->n_values);
   for (i = 0; i < value->n_values; i++)
     {
-      result->values[i] = _gtk_css_value_compute (value->values[i], property_id, context, NULL);
+      result->values[i] = _gtk_css_value_compute (value->values[i], property_id, context, &child_deps);
+
+      *dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
+
       changed |= (result->values[i] != value->values[i]);
     }
 
diff --git a/gtk/gtkcssbgsizevalue.c b/gtk/gtkcssbgsizevalue.c
index 2bff385..349a986 100644
--- a/gtk/gtkcssbgsizevalue.c
+++ b/gtk/gtkcssbgsizevalue.c
@@ -46,13 +46,25 @@ gtk_css_value_bg_size_compute (GtkCssValue        *value,
                                GtkStyleContext    *context,
                                GtkCssDependencies *dependencies)
 {
+  GtkCssValue *x, *y;
+  GtkCssDependencies x_deps, y_deps;
+
   if (value->x == NULL && value->y == NULL)
     return _gtk_css_value_ref (value);
 
-  *dependencies = GTK_CSS_DEPENDS_ON_EVERYTHING;
+  x_deps = y_deps = 0;
+  x = y = NULL;
+
+  if (value->x)
+    x = _gtk_css_value_compute (value->x, property_id, context, &x_deps);
+
+  if (value->y)
+    y = _gtk_css_value_compute (value->y, property_id, context, &y_deps);
+
+  *dependencies = _gtk_css_dependencies_union (x_deps, y_deps);
 
-  return _gtk_css_bg_size_value_new (value->x ? _gtk_css_value_compute (value->x, property_id, context, NULL) : NULL,
-                                     value->y ? _gtk_css_value_compute (value->y, property_id, context, NULL) : NULL);
+  return _gtk_css_bg_size_value_new (value->x ? x : NULL,
+                                     value->y ? y : NULL);
 }
 
 static gboolean
diff --git a/gtk/gtkcssshadowsvalue.c b/gtk/gtkcssshadowsvalue.c
index ce37d86..78e092a 100644
--- a/gtk/gtkcssshadowsvalue.c
+++ b/gtk/gtkcssshadowsvalue.c
@@ -54,17 +54,17 @@ gtk_css_value_shadows_compute (GtkCssValue        *value,
                                GtkCssDependencies *dependencies)
 {
   GtkCssValue *result;
+  GtkCssDependencies child_deps;
   guint i;
 
   if (value->len == 0)
     return _gtk_css_value_ref (value);
 
-  *dependencies = GTK_CSS_DEPENDS_ON_EVERYTHING;
-
   result = gtk_css_shadows_value_new (value->values, value->len);
   for (i = 0; i < value->len; i++)
     {
-      result->values[i] = _gtk_css_value_compute (value->values[i], property_id, context, NULL);
+      result->values[i] = _gtk_css_value_compute (value->values[i], property_id, context, &child_deps);
+      *dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
     }
 
   return result;
diff --git a/gtk/gtkcssshadowvalue.c b/gtk/gtkcssshadowvalue.c
index 9b2d897..bdfa8d2 100644
--- a/gtk/gtkcssshadowvalue.c
+++ b/gtk/gtkcssshadowvalue.c
@@ -65,14 +65,30 @@ gtk_css_value_shadow_compute (GtkCssValue        *shadow,
                               GtkStyleContext    *context,
                               GtkCssDependencies *dependencies)
 {
-  *dependencies = GTK_CSS_DEPENDS_ON_EVERYTHING;
-
-  return gtk_css_shadow_value_new (_gtk_css_value_compute (shadow->hoffset, property_id, context, NULL),
-                                   _gtk_css_value_compute (shadow->voffset, property_id, context, NULL),
-                                   _gtk_css_value_compute (shadow->radius, property_id, context, NULL),
-                                   _gtk_css_value_compute (shadow->spread, property_id, context, NULL),
-                                   shadow->inset,
-                                   _gtk_css_value_compute (shadow->color, property_id, context, NULL));
+  GtkCssValue *hoffset, *voffset, *radius, *spread, *color;
+  GtkCssDependencies child_deps;
+
+  child_deps = 0;
+  hoffset = _gtk_css_value_compute (shadow->hoffset, property_id, context, &child_deps);
+  *dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
+
+  child_deps = 0;
+  voffset = _gtk_css_value_compute (shadow->voffset, property_id, context, &child_deps);
+  *dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
+
+  child_deps = 0;
+  radius = _gtk_css_value_compute (shadow->radius, property_id, context, &child_deps);
+  *dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
+
+  child_deps = 0;
+  spread = _gtk_css_value_compute (shadow->spread, property_id, context, &child_deps),
+  *dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
+
+  child_deps = 0;
+  color = _gtk_css_value_compute (shadow->color, property_id, context, &child_deps);
+  *dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
+
+  return gtk_css_shadow_value_new (hoffset, voffset, radius, spread, shadow->inset, color);
 }
 
 static gboolean



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