Make traverse_preorder follow children of shadow hosts (#35276)

* Make traverse_preorder follow children of shadow hosts

Children of shadow hosts are not displayed, but they
still exist in the DOM and must be traversed.

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Fix traverse_preorder over shadow roots

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Update WPT expectations

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:
Simon Wülker 2025-02-04 21:47:33 +01:00 committed by GitHub
parent 3a75e1205b
commit aa09e2b88f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 25 additions and 185 deletions

View file

@ -1778,6 +1778,14 @@ impl TreeIterator {
self.current = Some(next_sibling);
return Some(current);
}
if let Some(shadow_root) = ancestor.downcast::<ShadowRoot>() {
// Shadow roots don't have sibling, so after we're done traversing
// one we jump to the first child of the host
if let Some(child) = shadow_root.Host().upcast::<Node>().GetFirstChild() {
self.current = Some(child);
return Some(current);
}
}
self.depth -= 1;
}
debug_assert_eq!(self.depth, 0);
@ -1801,8 +1809,6 @@ impl Iterator for TreeIterator {
self.current = Some(DomRoot::from_ref(shadow_root.upcast::<Node>()));
self.depth += 1;
return Some(current);
} else {
return self.next_skipping_children_impl(current);
}
}
}

View file

@ -1,6 +1,3 @@
[CustomElementRegistry.html]
[customElements.define must upgrade elements in the shadow-including tree order]
expected: FAIL
[customElements.define must get "observedAttributes" property on the constructor prototype when "attributeChangedCallback" is present]
expected: FAIL

View file

@ -1,2 +0,0 @@
[legend-in-slot.html]
expected: FAIL

View file

@ -1,2 +1,15 @@
[canvas-descendants-focusability-004.tentative.html]
expected: TIMEOUT
[<button data-focusable="false">]
expected: FAIL
[<section tabindex="-1" data-focusable="false">]
expected: FAIL
[<div tabindex="-1" data-focusable="false">]
expected: FAIL
[<span tabindex="-1" data-focusable="false">]
expected: FAIL
[<a href="#" data-focusable="false">]
expected: FAIL

View file

@ -100,3 +100,6 @@
[elementsFromPoint should return all elements under a point, even when context object is not connected]
expected: FAIL
[document.elementFromPoint and shadowRoot.elementFromPoint must return the element assigned to a slot when hit-tested text node under an element is assigned to a slot in the shadow tree and the shadow host of the slot has display: inline]
expected: FAIL

View file

@ -1,3 +0,0 @@
[declarative-after-attachshadow.html]
[Declarative Shadow DOM: declarative shadow should fail if attachShadow() already called]
expected: FAIL

View file

@ -1,3 +0,0 @@
[innerhtml-on-ordinary-template.html]
[Declarative Shadow DOM: innerHTML should work on <template shadowroot> that is left over]
expected: FAIL

View file

@ -1,60 +0,0 @@
[event-inside-slotted-node.html]
[Firing an event inside a grand child of a detached open mode shadow host]
expected: FAIL
[Firing an event inside a grand child of a detached closed mode shadow host]
expected: FAIL
[Firing an event inside a grand child of an in-document open mode shadow host]
expected: FAIL
[Firing an event inside a grand child of an in-document closed mode shadow host]
expected: FAIL
[Firing an event on a node with two ancestors with a detached open and open shadow trees with an inner open shadow tree]
expected: FAIL
[Firing an event on a node with two ancestors with a detached open and open shadow trees with an inner closed shadow tree]
expected: FAIL
[Firing an event on a node with two ancestors with a detached open and closed shadow trees with an inner open shadow tree]
expected: FAIL
[Firing an event on a node with two ancestors with a detached open and closed shadow trees with an inner closed shadow tree]
expected: FAIL
[Firing an event on a node with two ancestors with a detached closed and open shadow trees with an inner open shadow tree]
expected: FAIL
[Firing an event on a node with two ancestors with a detached closed and open shadow trees with an inner closed shadow tree]
expected: FAIL
[Firing an event on a node with two ancestors with a detached closed and closed shadow trees with an inner open shadow tree]
expected: FAIL
[Firing an event on a node with two ancestors with a detached closed and closed shadow trees with an inner closed shadow tree]
expected: FAIL
[Firing an event on a node within a open shadow tree that is itself a open shadow tree (the latter being the descendent of a host for a separate open shadow tree)]
expected: FAIL
[Firing an event on a node within a closed shadow tree that is itself a open shadow tree (the latter being the descendent of a host for a separate open shadow tree)]
expected: FAIL
[Firing an event on a node within a open shadow tree that is itself a closed shadow tree (the latter being the descendent of a host for a separate open shadow tree)]
expected: FAIL
[Firing an event on a node within a closed shadow tree that is itself a closed shadow tree (the latter being the descendent of a host for a separate open shadow tree)]
expected: FAIL
[Firing an event on a node within a open shadow tree that is itself a open shadow tree (the latter being the descendent of a host for a separate closed shadow tree)]
expected: FAIL
[Firing an event on a node within a closed shadow tree that is itself a open shadow tree (the latter being the descendent of a host for a separate closed shadow tree)]
expected: FAIL
[Firing an event on a node within a open shadow tree that is itself a closed shadow tree (the latter being the descendent of a host for a separate closed shadow tree)]
expected: FAIL
[Firing an event on a node within a closed shadow tree that is itself a closed shadow tree (the latter being the descendent of a host for a separate closed shadow tree)]
expected: FAIL

View file

@ -22,15 +22,3 @@
[offsetParent must find the first offset parent which is a shadow-including ancestor of the context object even some shadow tree of closed mode did not have any offset parent]
expected: FAIL
[offsetParent must return null on a child element of a shadow host for the shadow tree in open mode which is not assigned to any slot]
expected: FAIL
[offsetParent must return null on a child element of a shadow host for the shadow tree in closed mode which is not assigned to any slot]
expected: FAIL
[offsetParent must return null on a child element of a shadow host for the shadow tree in open mode which is not in the flat tree]
expected: FAIL
[offsetParent must return null on a child element of a shadow host for the shadow tree in closed mode which is not in the flat tree]
expected: FAIL

View file

@ -1,2 +0,0 @@
[slot-fallback-content-008.html]
expected: FAIL

View file

@ -1,4 +0,0 @@
[slotchange.html]
expected: TIMEOUT
[slotchange event: Child content is added to nested slots.]
expected: TIMEOUT

View file

@ -1,18 +1,3 @@
[slots-fallback.html]
[Slots fallback: Complex case.]
expected: FAIL
[Slots fallback: Complex case, elements only.]
expected: FAIL
[Slots fallback: Mutation. Append fallback contents.]
expected: FAIL
[Slots fallback: Mutation. Remove fallback contents.]
expected: FAIL
[Slots fallback: Mutation. Assign a node to a slot so that fallback contens are no longer used.]
expected: FAIL
[Slots fallback: Mutation. Remove a slot which is a fallback content of another slot.]
expected: FAIL

View file

@ -1,36 +1,3 @@
[slots.html]
[Slots: Slot is assigned to another slot]
expected: FAIL
[Slots: Open > Closed.]
expected: FAIL
[Slots: Closed > Closed.]
expected: FAIL
[Slots: Closed > Open.]
expected: FAIL
[Slots: Complex case: Basi line.]
expected: FAIL
[Slots: Mutation: appendChild.]
expected: FAIL
[Slots: Mutation: Change slot= attribute 2.]
expected: FAIL
[Slots: Mutation: Change slot= attribute 3.]
expected: FAIL
[Slots: Mutation: Add a slot: before.]
expected: FAIL
[Slots: Mutation: Change slot name= attribute.]
expected: FAIL
[Slots: Mutation: Change slot slot= attribute.]
expected: FAIL
[Slots: Mutation: Remove a slot.]
expected: FAIL

View file

@ -1,6 +1,3 @@
[dom-tree-accessors-001.html]
[Elements in a shadow tree should not be accessible from owner document's getElementsByName() method.]
expected: FAIL
[Elements in a shadow tree should not be accessible from owner document's "all" attribute.]
expected: FAIL

View file

@ -1,6 +0,0 @@
[selectors-api-001.html]
[Elements in a shadow tree should not be accessible from owner document's querySelector() method.]
expected: FAIL
[Elements in a shadow tree should not be accessible from owner document's querySelectorAll() method.]
expected: FAIL

View file

@ -1,33 +0,0 @@
[test-009.html]
[A_04_01_09_T01]
expected: FAIL
[A_04_01_09_T03]
expected: FAIL
[A_04_01_09_T05]
expected: FAIL
[A_04_01_09_T08]
expected: FAIL
[A_04_01_09_T09]
expected: FAIL
[A_04_01_09_T10]
expected: FAIL
[A_04_01_09_T11]
expected: FAIL
[A_04_01_09_T12]
expected: FAIL
[A_04_01_09_T14]
expected: FAIL
[A_04_01_09_T15]
expected: FAIL
[A_04_01_09_T16]
expected: FAIL

View file

@ -1,3 +0,0 @@
[test-008.html]
[A_06_00_09_T01]
expected: FAIL