[gtk+/wip/cssdep: 19/21] stylecontext: Update computed values when dependencies change



commit 03b675797dd21d17dcbf654d3d565466a04d0bc2
Author: Benjamin Otte <otte redhat com>
Date:   Fri Aug 24 18:17:52 2012 +0200

    stylecontext: Update computed values when dependencies change
    
    This fixes the longstanding bug where GTK would not update styles when
    parent styles would change.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=672046

 gtk/gtkstylecontext.c |   43 +++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 41 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index e37edd5..264e946 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -2925,6 +2925,36 @@ gtk_style_context_clear_cache (GtkStyleContext *context)
 }
 
 static void
+gtk_style_context_update_cache (GtkStyleContext  *context,
+                                const GtkBitmask *parent_changes)
+{
+  GtkStyleContextPrivate *priv;
+  GHashTableIter iter;
+  gpointer key, value;
+
+  priv = context->priv;
+
+  g_hash_table_remove_all (priv->style_data);
+
+  g_hash_table_iter_init (&iter, priv->style_data);
+  while (g_hash_table_iter_next (&iter, &key, &value))
+    {
+      GtkStyleInfo *info = key;
+      StyleData *data = value;
+      GtkBitmask *changes;
+
+      changes = _gtk_bitmask_copy (parent_changes);
+      changes = _gtk_bitmask_intersect (changes, data->store->depends_on_parent);
+      if (_gtk_bitmask_get (changes, GTK_CSS_PROPERTY_COLOR))
+        changes = _gtk_bitmask_union (changes, data->store->depends_on_color);
+      if (_gtk_bitmask_get (changes, GTK_CSS_PROPERTY_FONT_SIZE))
+        changes = _gtk_bitmask_union (changes, data->store->depends_on_font_size);
+
+      build_properties (context, data->store, info->state_flags, changes);
+    }
+}
+
+static void
 gtk_style_context_do_invalidate (GtkStyleContext *context)
 {
   GtkStyleContextPrivate *priv;
@@ -2983,6 +3013,8 @@ gtk_style_context_should_animate (GtkStyleContext *context)
 
   priv = context->priv;
 
+  return FALSE;
+
   if (priv->widget == NULL)
     return FALSE;
 
@@ -3113,9 +3145,14 @@ _gtk_style_context_validate (GtkStyleContext  *context,
       gtk_style_context_needs_full_revalidate (context, change))
     {
       if ((priv->relevant_changes & change) & ~GTK_STYLE_CONTEXT_CACHED_CHANGE)
-        gtk_style_context_clear_cache (context);
+        {
+          gtk_style_context_clear_cache (context);
+        }
       else
-        style_info_set_data (info, NULL);
+        {
+          gtk_style_context_update_cache (context, parent_changes);
+          style_info_set_data (info, NULL);
+        }
 
       if (current)
         {
@@ -3144,6 +3181,8 @@ _gtk_style_context_validate (GtkStyleContext  *context,
         changes = _gtk_bitmask_union (changes, current->store->depends_on_color);
       if (_gtk_bitmask_get (changes, GTK_CSS_PROPERTY_FONT_SIZE))
         changes = _gtk_bitmask_union (changes, current->store->depends_on_font_size);
+
+      gtk_style_context_update_cache (context, parent_changes);
     }
 
   if (change & GTK_CSS_CHANGE_ANIMATE &&



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