mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Make traverse_preorder follow shadow roots (#34503)
* script: Ensure shadow-inclusve preorder traversals follow hosted shadow roots. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Handle unregistering element id/name values inside of a shadow root. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Merge shadow root tree iteration logic. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
ad48ab7ec3
commit
4242ff9626
15 changed files with 20733 additions and 123 deletions
|
@ -492,7 +492,7 @@ impl Element {
|
||||||
self.ScrollWidth(can_gc) > self.ClientWidth(can_gc)
|
self.ScrollWidth(can_gc) > self.ClientWidth(can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn shadow_root(&self) -> Option<DomRoot<ShadowRoot>> {
|
pub(crate) fn shadow_root(&self) -> Option<DomRoot<ShadowRoot>> {
|
||||||
self.rare_data()
|
self.rare_data()
|
||||||
.as_ref()?
|
.as_ref()?
|
||||||
.shadow_root
|
.shadow_root
|
||||||
|
@ -3632,19 +3632,21 @@ impl VirtualMethods for Element {
|
||||||
|
|
||||||
let doc = document_from_node(self);
|
let doc = document_from_node(self);
|
||||||
|
|
||||||
if let Some(ref shadow_root) = self.shadow_root() {
|
|
||||||
shadow_root.unbind_from_tree(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
let fullscreen = doc.GetFullscreenElement();
|
let fullscreen = doc.GetFullscreenElement();
|
||||||
if fullscreen.as_deref() == Some(self) {
|
if fullscreen.as_deref() == Some(self) {
|
||||||
doc.exit_fullscreen(CanGc::note());
|
doc.exit_fullscreen(CanGc::note());
|
||||||
}
|
}
|
||||||
if let Some(ref value) = *self.id_attribute.borrow() {
|
if let Some(ref value) = *self.id_attribute.borrow() {
|
||||||
doc.unregister_element_id(self, value.clone());
|
if let Some(ref shadow_root) = self.upcast::<Node>().containing_shadow_root() {
|
||||||
|
shadow_root.unregister_element_id(self, value.clone());
|
||||||
|
} else {
|
||||||
|
doc.unregister_element_id(self, value.clone());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if let Some(ref value) = self.name_attribute() {
|
if let Some(ref value) = self.name_attribute() {
|
||||||
doc.unregister_element_name(self, value.clone());
|
if self.upcast::<Node>().containing_shadow_root().is_none() {
|
||||||
|
doc.unregister_element_name(self, value.clone());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// This is used for layout optimization.
|
// This is used for layout optimization.
|
||||||
doc.decrement_dom_count();
|
doc.decrement_dom_count();
|
||||||
|
|
|
@ -1744,9 +1744,14 @@ impl Iterator for TreeIterator {
|
||||||
fn next(&mut self) -> Option<DomRoot<Node>> {
|
fn next(&mut self) -> Option<DomRoot<Node>> {
|
||||||
let current = self.current.take()?;
|
let current = self.current.take()?;
|
||||||
|
|
||||||
if !self.shadow_including {
|
// Handle a potential shadow root on the element
|
||||||
if let Some(element) = current.downcast::<Element>() {
|
if let Some(element) = current.downcast::<Element>() {
|
||||||
if element.is_shadow_host() {
|
if let Some(shadow_root) = element.shadow_root() {
|
||||||
|
if self.shadow_including {
|
||||||
|
self.current = Some(DomRoot::from_ref(shadow_root.upcast::<Node>()));
|
||||||
|
self.depth += 1;
|
||||||
|
return Some(current);
|
||||||
|
} else {
|
||||||
return self.next_skipping_children_impl(current);
|
return self.next_skipping_children_impl(current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -315,13 +315,6 @@ impl VirtualMethods for ShadowRoot {
|
||||||
let document = document_from_node(self);
|
let document = document_from_node(self);
|
||||||
document.unregister_shadow_root(self);
|
document.unregister_shadow_root(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
let shadow_root = self.upcast::<Node>();
|
|
||||||
shadow_root.set_flag(NodeFlags::IS_CONNECTED, false);
|
|
||||||
for node in shadow_root.children() {
|
|
||||||
node.set_flag(NodeFlags::IS_CONNECTED, false);
|
|
||||||
node.unbind_from_tree(context);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,82 +1,40 @@
|
||||||
[adopted-callback.html]
|
[adopted-callback.html]
|
||||||
[Inserting the shadow host of a custom element into the document of the template elements must enqueue and invoke adoptedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Moving the shadow host of a custom element from the owner document into the document of the template elements must enqueue and invoke adoptedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Moving the shadow host's shadow of a custom element from the owner document into the document of the template elements must enqueue and invoke adoptedCallback]
|
[Moving the shadow host's shadow of a custom element from the owner document into the document of the template elements must enqueue and invoke adoptedCallback]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Moving the <template>'s content of a custom element from the owner document into the document of the template elements must enqueue and invoke adoptedCallback]
|
[Moving the <template>'s content of a custom element from the owner document into the document of the template elements must enqueue and invoke adoptedCallback]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Inserting the shadow host of a custom element into a new document must enqueue and invoke adoptedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Moving the shadow host of a custom element from the owner document into a new document must enqueue and invoke adoptedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Moving the shadow host's shadow of a custom element from the owner document into a new document must enqueue and invoke adoptedCallback]
|
[Moving the shadow host's shadow of a custom element from the owner document into a new document must enqueue and invoke adoptedCallback]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Moving the <template>'s content of a custom element from the owner document into a new document must enqueue and invoke adoptedCallback]
|
[Moving the <template>'s content of a custom element from the owner document into a new document must enqueue and invoke adoptedCallback]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Inserting the shadow host of a custom element into a cloned document must enqueue and invoke adoptedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Moving the shadow host of a custom element from the owner document into a cloned document must enqueue and invoke adoptedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Moving the shadow host's shadow of a custom element from the owner document into a cloned document must enqueue and invoke adoptedCallback]
|
[Moving the shadow host's shadow of a custom element from the owner document into a cloned document must enqueue and invoke adoptedCallback]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Moving the <template>'s content of a custom element from the owner document into a cloned document must enqueue and invoke adoptedCallback]
|
[Moving the <template>'s content of a custom element from the owner document into a cloned document must enqueue and invoke adoptedCallback]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Inserting the shadow host of a custom element into a document created by createHTMLDocument must enqueue and invoke adoptedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Moving the shadow host of a custom element from the owner document into a document created by createHTMLDocument must enqueue and invoke adoptedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Moving the shadow host's shadow of a custom element from the owner document into a document created by createHTMLDocument must enqueue and invoke adoptedCallback]
|
[Moving the shadow host's shadow of a custom element from the owner document into a document created by createHTMLDocument must enqueue and invoke adoptedCallback]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Moving the <template>'s content of a custom element from the owner document into a document created by createHTMLDocument must enqueue and invoke adoptedCallback]
|
[Moving the <template>'s content of a custom element from the owner document into a document created by createHTMLDocument must enqueue and invoke adoptedCallback]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Inserting the shadow host of a custom element into an HTML document created by createDocument must enqueue and invoke adoptedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Moving the shadow host of a custom element from the owner document into an HTML document created by createDocument must enqueue and invoke adoptedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Moving the shadow host's shadow of a custom element from the owner document into an HTML document created by createDocument must enqueue and invoke adoptedCallback]
|
[Moving the shadow host's shadow of a custom element from the owner document into an HTML document created by createDocument must enqueue and invoke adoptedCallback]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Moving the <template>'s content of a custom element from the owner document into an HTML document created by createDocument must enqueue and invoke adoptedCallback]
|
[Moving the <template>'s content of a custom element from the owner document into an HTML document created by createDocument must enqueue and invoke adoptedCallback]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Inserting the shadow host of a custom element into the document of an iframe must enqueue and invoke adoptedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Moving the shadow host of a custom element from the owner document into the document of an iframe must enqueue and invoke adoptedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Moving the shadow host's shadow of a custom element from the owner document into the document of an iframe must enqueue and invoke adoptedCallback]
|
[Moving the shadow host's shadow of a custom element from the owner document into the document of an iframe must enqueue and invoke adoptedCallback]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Moving the <template>'s content of a custom element from the owner document into the document of an iframe must enqueue and invoke adoptedCallback]
|
[Moving the <template>'s content of a custom element from the owner document into the document of an iframe must enqueue and invoke adoptedCallback]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Inserting the shadow host of a custom element into an HTML document fetched by XHR must enqueue and invoke adoptedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Moving the shadow host of a custom element from the owner document into an HTML document fetched by XHR must enqueue and invoke adoptedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Moving the shadow host's shadow of a custom element from the owner document into an HTML document fetched by XHR must enqueue and invoke adoptedCallback]
|
[Moving the shadow host's shadow of a custom element from the owner document into an HTML document fetched by XHR must enqueue and invoke adoptedCallback]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
[connected-callbacks.html]
|
|
||||||
[Inserting the shadow host of a custom element into the document must enqueue and invoke connectedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Inserting the shadow host of a custom element into the document of the template elements must enqueue and invoke connectedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Inserting the shadow host of a custom element into a new document must enqueue and invoke connectedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Inserting the shadow host of a custom element into a cloned document must enqueue and invoke connectedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Inserting the shadow host of a custom element into a document created by createHTMLDocument must enqueue and invoke connectedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Inserting the shadow host of a custom element into an HTML document created by createDocument must enqueue and invoke connectedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Inserting the shadow host of a custom element into the document of an iframe must enqueue and invoke connectedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Inserting the shadow host of a custom element into an HTML document fetched by XHR must enqueue and invoke connectedCallback]
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[upgrade.html]
|
|
||||||
[Two elements as shadow-including descendants (and not descendants) of the upgraded node]
|
|
||||||
expected: FAIL
|
|
|
@ -1,48 +1,24 @@
|
||||||
[disconnected-callbacks.html]
|
[disconnected-callbacks.html]
|
||||||
[Removing the shadow host of a custom element from athe document must enqueue and invoke disconnectedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Removing a custom element from a detached shadow tree that belongs to the document must not enqueue and invoke disconnectedCallback]
|
[Removing a custom element from a detached shadow tree that belongs to the document must not enqueue and invoke disconnectedCallback]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Removing the shadow host of a custom element from athe document of the template elements must enqueue and invoke disconnectedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Removing a custom element from a detached shadow tree that belongs to the document of the template elements must not enqueue and invoke disconnectedCallback]
|
[Removing a custom element from a detached shadow tree that belongs to the document of the template elements must not enqueue and invoke disconnectedCallback]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Removing the shadow host of a custom element from aa new document must enqueue and invoke disconnectedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Removing a custom element from a detached shadow tree that belongs to a new document must not enqueue and invoke disconnectedCallback]
|
[Removing a custom element from a detached shadow tree that belongs to a new document must not enqueue and invoke disconnectedCallback]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Removing the shadow host of a custom element from aa cloned document must enqueue and invoke disconnectedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Removing a custom element from a detached shadow tree that belongs to a cloned document must not enqueue and invoke disconnectedCallback]
|
[Removing a custom element from a detached shadow tree that belongs to a cloned document must not enqueue and invoke disconnectedCallback]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Removing the shadow host of a custom element from aa document created by createHTMLDocument must enqueue and invoke disconnectedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Removing a custom element from a detached shadow tree that belongs to a document created by createHTMLDocument must not enqueue and invoke disconnectedCallback]
|
[Removing a custom element from a detached shadow tree that belongs to a document created by createHTMLDocument must not enqueue and invoke disconnectedCallback]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Removing the shadow host of a custom element from aan HTML document created by createDocument must enqueue and invoke disconnectedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Removing a custom element from a detached shadow tree that belongs to an HTML document created by createDocument must not enqueue and invoke disconnectedCallback]
|
[Removing a custom element from a detached shadow tree that belongs to an HTML document created by createDocument must not enqueue and invoke disconnectedCallback]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Removing the shadow host of a custom element from athe document of an iframe must enqueue and invoke disconnectedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Removing a custom element from a detached shadow tree that belongs to the document of an iframe must not enqueue and invoke disconnectedCallback]
|
[Removing a custom element from a detached shadow tree that belongs to the document of an iframe must not enqueue and invoke disconnectedCallback]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Removing the shadow host of a custom element from aan HTML document fetched by XHR must enqueue and invoke disconnectedCallback]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Removing a custom element from a detached shadow tree that belongs to an HTML document fetched by XHR must not enqueue and invoke disconnectedCallback]
|
[Removing a custom element from a detached shadow tree that belongs to an HTML document fetched by XHR must not enqueue and invoke disconnectedCallback]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
|
@ -2,9 +2,6 @@
|
||||||
[Adding definition to global registry should not affect shadow roots using scoped registry]
|
[Adding definition to global registry should not affect shadow roots using scoped registry]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Adding definition to global registry should affect shadow roots also using global registry]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Adding definition to scoped registry should affect all associated shadow roots]
|
[Adding definition to scoped registry should affect all associated shadow roots]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,3 @@
|
||||||
|
|
||||||
[Event listeners are to be removed with immediate effect]
|
[Event listeners are to be removed with immediate effect]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Event listeners are to be removed from shadow trees as well]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
20712
tests/wpt/meta/shadow-dom/declarative/gethtml.html.ini
vendored
20712
tests/wpt/meta/shadow-dom/declarative/gethtml.html.ini
vendored
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,4 @@
|
||||||
[getinnerhtml.tentative.html]
|
[getinnerhtml.tentative.html]
|
||||||
expected: TIMEOUT
|
|
||||||
[Element.getInnerHTML() on <a>]
|
[Element.getInnerHTML() on <a>]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
[input-element-list.html]
|
|
||||||
expected: CRASH
|
|
|
@ -1,2 +0,0 @@
|
||||||
[input-type-radio.html]
|
|
||||||
expected: CRASH
|
|
3
tests/wpt/meta/shadow-dom/leaktests/window-frames.html.ini
vendored
Normal file
3
tests/wpt/meta/shadow-dom/leaktests/window-frames.html.ini
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[window-frames.html]
|
||||||
|
[window.frames should not leak frames in Shadow DOM.]
|
||||||
|
expected: FAIL
|
|
@ -1,2 +1,3 @@
|
||||||
[window-named-properties-001.html]
|
[window-named-properties-001.html]
|
||||||
expected: TIMEOUT
|
[An iframe element in a shadow tree should not be accessible from window's named properties with its "name" attribute value.]
|
||||||
|
expected: FAIL
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue