cssnode: Only invalidate sibling nodes if changed node is visible

This commit is contained in:
Benjamin Otte 2015-07-10 21:34:06 +02:00
parent c05cd611e6
commit adcb52e82b

View File

@ -657,7 +657,7 @@ gtk_css_node_reposition (GtkCssNode *node,
if (old_parent != NULL)
{
g_signal_emit (old_parent, cssnode_signals[NODE_REMOVED], 0, node, node->previous_sibling);
if (old_parent->first_child)
if (old_parent->first_child && node->visible)
gtk_css_node_invalidate (old_parent->first_child, GTK_CSS_CHANGE_NTH_LAST_CHILD);
}
@ -694,19 +694,28 @@ gtk_css_node_reposition (GtkCssNode *node,
if (new_parent)
{
g_signal_emit (new_parent, cssnode_signals[NODE_ADDED], 0, node, previous);
gtk_css_node_invalidate (new_parent->first_child, GTK_CSS_CHANGE_NTH_LAST_CHILD);
if (node->visible)
gtk_css_node_invalidate (new_parent->first_child, GTK_CSS_CHANGE_NTH_LAST_CHILD);
}
if (node->next_sibling)
if (node->visible)
{
if (node->previous_sibling == NULL)
gtk_css_node_invalidate (node->next_sibling, GTK_CSS_CHANGE_FIRST_CHILD);
else
gtk_css_node_invalidate_style (node->next_sibling);
if (node->next_sibling)
{
if (node->previous_sibling == NULL)
gtk_css_node_invalidate (node->next_sibling, GTK_CSS_CHANGE_FIRST_CHILD);
else
gtk_css_node_invalidate_style (node->next_sibling);
}
else if (node->previous_sibling)
{
gtk_css_node_invalidate (node->previous_sibling, GTK_CSS_CHANGE_LAST_CHILD);
}
}
else if (node->previous_sibling)
else
{
gtk_css_node_invalidate (node->previous_sibling, GTK_CSS_CHANGE_LAST_CHILD);
if (node->next_sibling)
gtk_css_node_invalidate_style (node->next_sibling);
}
gtk_css_node_invalidate (node, GTK_CSS_CHANGE_ANY_PARENT
@ -888,7 +897,13 @@ gtk_css_node_set_visible (GtkCssNode *cssnode,
g_object_notify_by_pspec (G_OBJECT (cssnode), cssnode_properties[PROP_VISIBLE]);
if (cssnode->next_sibling)
gtk_css_node_invalidate (cssnode->next_sibling, GTK_CSS_CHANGE_POSITION | GTK_CSS_CHANGE_ANY_SIBLING);
gtk_css_node_invalidate (cssnode->next_sibling, GTK_CSS_CHANGE_ANY_SIBLING
| GTK_CSS_CHANGE_NTH_CHILD
| (cssnode->previous_sibling ? 0 : GTK_CSS_CHANGE_FIRST_CHILD));
if (cssnode->previous_sibling)
gtk_css_node_invalidate (cssnode->previous_sibling, GTK_CSS_CHANGE_NTH_LAST_CHILD
| (cssnode->next_sibling ? 0 : GTK_CSS_CHANGE_LAST_CHILD));
}
gboolean