cssnode: Refactor invalidation propagation
authorBenjamin Otte <otte@redhat.com>
Sun, 8 Feb 2015 11:15:27 +0000 (12:15 +0100)
committerBenjamin Otte <otte@redhat.com>
Wed, 18 Mar 2015 14:23:30 +0000 (15:23 +0100)
We want to be sure to gtk_css_node_invalidate() all potential changes.

gtk/gtkcontainer.c
gtk/gtkcssnode.c
gtk/gtkcssnodeprivate.h
gtk/gtkwindow.c

index 186f89db08715c83646848198716e8425f52301c..6dc69b8c499e8d137fe29003fd821dbeabfd13f9 100644 (file)
@@ -1855,7 +1855,6 @@ gtk_container_idle_sizer (GdkFrameClock *clock,
       container->priv->restyle_pending = FALSE;
       gtk_css_node_validate (gtk_style_context_get_root (gtk_widget_get_style_context (GTK_WIDGET (container))),
                              current_time,
-                             0,
                              empty);
 
       _gtk_bitmask_free (empty);
index 9d7c0cbc7666898a56aca1a59c8f49e165ed53bc..36a108f16a56e97003a90c7259342ca3b9a11a2d 100644 (file)
@@ -628,12 +628,31 @@ gtk_css_node_invalidate (GtkCssNode   *cssnode,
   gtk_css_node_set_invalid (cssnode, TRUE);
 }
 
+static void
+gtk_css_node_propagate_pending_changes (GtkCssNode *cssnode)
+{
+  GtkCssChange change;
+  GtkCssNode *child;
+
+  if (!cssnode->invalid)
+    return;
+
+  change = _gtk_css_change_for_child (cssnode->pending_changes);
+
+  for (child = gtk_css_node_get_first_child (cssnode);
+       child;
+       child = gtk_css_node_get_next_sibling (child))
+    {
+      gtk_css_node_invalidate (child, change);
+    }
+}
+
 void
 gtk_css_node_validate (GtkCssNode            *cssnode,
                        gint64                 timestamp,
-                       GtkCssChange           change,
                        const GtkBitmask      *parent_changes)
 {
+  GtkCssChange change;
   GtkCssNode *child;
   GtkBitmask *changes;
 
@@ -655,20 +674,20 @@ gtk_css_node_validate (GtkCssNode            *cssnode,
   if (!cssnode->invalid && change == 0 && _gtk_bitmask_is_empty (parent_changes))
     return;
 
+  gtk_css_node_propagate_pending_changes (cssnode);
+
   gtk_css_node_set_invalid (cssnode, FALSE);
 
-  change |= cssnode->pending_changes;
+  change = cssnode->pending_changes;
   cssnode->pending_changes = 0;
 
   changes = GTK_CSS_NODE_GET_CLASS (cssnode)->validate (cssnode, timestamp, change, parent_changes);
 
-  change = _gtk_css_change_for_child (change);
-
   for (child = gtk_css_node_get_first_child (cssnode);
        child;
        child = gtk_css_node_get_next_sibling (child))
     {
-      gtk_css_node_validate (child, timestamp, change, changes);
+      gtk_css_node_validate (child, timestamp, changes);
     }
 
   _gtk_bitmask_free (changes);
index e0f60e5b6651fb3f6ef9e75e89c7e4ff85394f53..25e4cfa5bab8a1271b960638e4dd7d0b71cbeb04 100644 (file)
@@ -126,7 +126,6 @@ void                    gtk_css_node_invalidate         (GtkCssNode            *
                                                          GtkCssChange           change);
 void                    gtk_css_node_validate           (GtkCssNode            *cssnode,
                                                          gint64                 timestamp,
-                                                         GtkCssChange           change,
                                                          const GtkBitmask      *parent_changes);
 void                    gtk_css_node_set_invalid        (GtkCssNode            *node,
                                                          gboolean               invalid);
index 32a3b2c1f72e0917d6774f0d138b1174fbc8ad70..14d47232180ba8902140df5960bcd223ab80a8a3 100644 (file)
@@ -5851,7 +5851,6 @@ gtk_window_show (GtkWidget *widget)
   empty = _gtk_bitmask_new ();
   gtk_css_node_validate (gtk_style_context_get_root (gtk_widget_get_style_context (widget)),
                          g_get_monotonic_time (),
-                         0,
                          empty);
   _gtk_bitmask_free (empty);