mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Don't recurse in Node::GetRootNode (#35725)
* Don't recurse in Node::GetRootNode This causes servo to crash when computing the root of deeply nested shadow roots. Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Add test case Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
parent
ce977636f6
commit
25cc675101
7 changed files with 59 additions and 13 deletions
|
@ -2887,19 +2887,16 @@ impl NodeMethods<crate::DomTypeHolder> for Node {
|
|||
|
||||
/// <https://dom.spec.whatwg.org/#dom-node-getrootnode>
|
||||
fn GetRootNode(&self, options: &GetRootNodeOptions) -> DomRoot<Node> {
|
||||
if let Some(shadow_root) = self.containing_shadow_root() {
|
||||
return if options.composed {
|
||||
// shadow-including root.
|
||||
shadow_root.Host().upcast::<Node>().GetRootNode(options)
|
||||
} else {
|
||||
DomRoot::from_ref(shadow_root.upcast::<Node>())
|
||||
};
|
||||
if !options.composed {
|
||||
if let Some(shadow_root) = self.containing_shadow_root() {
|
||||
return DomRoot::upcast(shadow_root);
|
||||
}
|
||||
}
|
||||
|
||||
if self.is_in_a_document_tree() {
|
||||
if self.is_connected() {
|
||||
DomRoot::from_ref(self.owner_doc().upcast::<Node>())
|
||||
} else {
|
||||
self.inclusive_ancestors(ShadowIncluding::No)
|
||||
self.inclusive_ancestors(ShadowIncluding::Yes)
|
||||
.last()
|
||||
.unwrap()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue