layout: Avoid extra tree walks when removing accessibility nodes. - #46348
Conversation
| if !update.tree_changes.contains_key(&child_id) { | ||
| ids_to_remove.push(child_id); | ||
| } |
There was a problem hiding this comment.
the contains_key() check can be removed, because tree_changes has been drained by this point
| self.opaque_node_to_id.remove(&opaque_node); | ||
| } | ||
| for child in node.borrow().children() { | ||
| let child_id = child.borrow().id; |
There was a problem hiding this comment.
this can be gotten with node.child_ids(), instead of borrowing the child
| debug_assert!( | ||
| update.unresolved_local_damage.is_empty(), | ||
| "Damage not empty: {:?}", | ||
| update.unresolved_local_damage | ||
| ); |
There was a problem hiding this comment.
does this need to be debug_assert!()? seems fast?
There was a problem hiding this comment.
also would be good to write a comment explaining why this is the case
There was a problem hiding this comment.
My reasoning was that I think it might not be worth crashing the tab over if there is pending damage, but it might actually be better to crash the tab in that case in case there are some subtle errors in the accessibility tree.
Comment added.
| tree_id: tree.tree_id, | ||
| }; | ||
|
|
||
| tree.remove_stale_nodes(self); |
There was a problem hiding this comment.
was this reordering across the TreeUpdate initialiser intentional?
There was a problem hiding this comment.
Ah - I figured it out: we need to drop removed nodes before we filter_map() on line 902 in case we have nodes which were both changed and removed in the same update.
| } | ||
|
|
||
| for id in update | ||
| let mut ids_to_remove: Vec<NodeId> = update |
There was a problem hiding this comment.
| let mut ids_to_remove: Vec<NodeId> = update | |
| let mut ids_to_remove: Vec<_> = update |
| } | ||
|
|
||
| // We should have resolved all damage in nodes still in the tree by this point, and any | ||
| // nodes not in the tree should have been removed from this map in the loop above. |
There was a problem hiding this comment.
| // nodes not in the tree should have been removed from this map in the loop above. | |
| // nodes not in the tree should have been removed from this map in the loop above. |
4aeb8f7 to
60cbe13
Compare
Instead of setting the TreeChange for each node in a removed subtree, just set the TreeChange for the subtree root. Also only root the subtree root in AccessibilityData. Signed-off-by: Alice Boxhall <alice@igalia.com>
- Avoid unnecessary borrow when recursively removing children of removed nodes - Avoid completely pointless check of empty map (!) - Comment why we can assert that `unresolved_local_damage` is empty at the end of `drop_removed_nodes()`, and make it an `assert!()`. Signed-off-by: Alice Boxhall <alice@igalia.com>
Signed-off-by: Alice Boxhall <alice@igalia.com>
60cbe13 to
3eb0c7a
Compare
|
Marked WPT test as flaky in #46497. |
Instead of setting the TreeChange for each node in a removed subtree, just set the TreeChange for the subtree root.
Also only root the subtree root in AccessibilityData.
Testing: Adds a new test with more involved sequences of moving and removing nodes.
Fixes: #46347