mirror of
https://github.com/servo/servo
synced 2026-04-25 17:15:48 +02:00
dom: avoid short lived rooting in Node::is_ancestor_of (#40776)
When using the iterator nodes are rooted but they are dropped immediately. Testing: Green wpt run: https://github.com/webbeef/servo/actions/runs/19560383039/job/56012660243 Signed-off-by: webbeef <me@webbeef.org>
This commit is contained in:
@@ -915,7 +915,19 @@ impl Node {
|
||||
}
|
||||
|
||||
pub(crate) fn is_ancestor_of(&self, child: &Node) -> bool {
|
||||
child.ancestors().any(|ancestor| &*ancestor == self)
|
||||
let mut current = &MutNullableDom::new(Some(child));
|
||||
let mut done = false;
|
||||
|
||||
while let Some(node) = current.if_is_some(|node| {
|
||||
done = node == self;
|
||||
&node.parent_node
|
||||
}) {
|
||||
if done {
|
||||
break;
|
||||
}
|
||||
current = node
|
||||
}
|
||||
done
|
||||
}
|
||||
|
||||
pub(crate) fn is_shadow_including_inclusive_ancestor_of(&self, node: &Node) -> bool {
|
||||
|
||||
Reference in New Issue
Block a user