[gtk/gtk-4-6] Don't invalidate parent if it didn't change



commit fc5966a34755f40181f6b9f1f137238773b73950
Author: Benjamin Otte <otte benjamin googlemail com>
Date:   Fri May 6 11:50:55 2022 +0000

    Don't invalidate parent if it didn't change
    
    This looks like a leftover excess invalidation from when the surrounding
    code was refactored to not just be called on parent changes but also
    when repositioning inside the same parent in commit
    507016cafc407b2c47aea3fd1483df75e9757f29
    
    Ivan Molodetskikh found this problem in
    https://gitlab.gnome.org/GNOME/gtk/-/issues/3334#note_1445873 which
    contains a longer analysis of this problem and the performance
    reductions it causes.
    
    Related: #3334

 gtk/gtkcssnode.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkcssnode.c b/gtk/gtkcssnode.c
index 6ed25f9461..5dc5f49068 100644
--- a/gtk/gtkcssnode.c
+++ b/gtk/gtkcssnode.c
@@ -239,7 +239,7 @@ gtk_css_node_dispose (GObject *object)
     }
 
   gtk_css_node_set_invalid (cssnode, FALSE);
-  
+
   g_clear_pointer (&cssnode->cache, gtk_css_node_style_cache_unref);
 
   G_OBJECT_CLASS (gtk_css_node_parent_class)->dispose (object);
@@ -292,7 +292,7 @@ may_use_global_parent_cache (GtkCssNode *node)
 {
   GtkStyleProvider *provider;
   GtkCssNode *parent;
-  
+
   parent = gtk_css_node_get_parent (node);
   if (parent == NULL)
     return FALSE;
@@ -700,10 +700,10 @@ gtk_css_node_invalidate_style (GtkCssNode *cssnode)
 
   cssnode->style_is_invalid = TRUE;
   gtk_css_node_set_invalid (cssnode, TRUE);
-  
+
   if (cssnode->first_child)
     gtk_css_node_invalidate_style (cssnode->first_child);
-  
+
   if (cssnode->next_sibling)
     gtk_css_node_invalidate_style (cssnode->next_sibling);
 }
@@ -796,7 +796,7 @@ gtk_css_node_reposition (GtkCssNode *node,
         gtk_css_node_invalidate_style (node->next_sibling);
     }
 
-  gtk_css_node_invalidate (node, GTK_CSS_CHANGE_ANY_PARENT
+  gtk_css_node_invalidate (node, (old_parent != new_parent ? GTK_CSS_CHANGE_ANY_PARENT : 0)
                                  | GTK_CSS_CHANGE_ANY_SIBLING
                                  | GTK_CSS_CHANGE_NTH_CHILD
                                  | (node->previous_sibling ? 0 : GTK_CSS_CHANGE_FIRST_CHILD)
@@ -842,7 +842,7 @@ gtk_css_node_insert_before (GtkCssNode *parent,
   g_return_if_fail (next_sibling == NULL || next_sibling->parent == parent);
   g_return_if_fail (cssnode != next_sibling);
 
-  if (cssnode->next_sibling == next_sibling && 
+  if (cssnode->next_sibling == next_sibling &&
       cssnode->parent == parent)
     return;
 
@@ -1067,7 +1067,7 @@ gtk_css_node_set_visible (GtkCssNode *cssnode,
             }
         }
     }
-               
+
   if (cssnode->previous_sibling)
     {
       if (gtk_css_node_is_last_child (cssnode))
@@ -1424,7 +1424,7 @@ gtk_css_node_print (GtkCssNode                *cssnode,
 
       change = gtk_css_static_style_get_change (gtk_css_style_get_static_style (style));
       g_string_append (string, "    ");
-      gtk_css_change_print (change, string); 
+      gtk_css_change_print (change, string);
     }
 
   g_string_append_c (string, '\n');


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