html: Properly count <image>/<source> insertion/removal steps as the relevant mutations (#39452)

Follow the HTML specification and take into account that the HTML
`<image>/<source>` element inserting/removal steps should only be
counted as relevant mutations for `<image>` element if the parent of the
inclusive ancestor that was inserted/removed is the parent `<picture>`
element.

See <https://html.spec.whatwg.org/multipage/#relevant-mutations>.

Testing: Improvements in the following tests
-
html/semantics/embedded-content/the-img-element/relevant-mutations.html

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
This commit is contained in:
Andrei Volykhin 2025-09-23 15:40:03 +03:00 committed by GitHub
parent c63311af02
commit 99fbd36b5d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 75 additions and 71 deletions

View file

@ -586,20 +586,15 @@ impl VirtualMethods for ShadowRoot {
shadow_root.set_flag(NodeFlags::IS_CONNECTED, context.tree_connected);
let context = BindContext::new(shadow_root);
// avoid iterate over the shadow root itself
for node in shadow_root.traverse_preorder(ShadowIncluding::Yes).skip(1) {
node.set_flag(NodeFlags::IS_CONNECTED, context.tree_connected);
// Out-of-document elements never have the descendants flag set
debug_assert!(!node.get_flag(NodeFlags::HAS_DIRTY_DESCENDANTS));
vtable_for(&node).bind_to_tree(
&BindContext {
tree_connected: context.tree_connected,
tree_is_in_a_document_tree: false,
tree_is_in_a_shadow_tree: true,
},
can_gc,
);
vtable_for(&node).bind_to_tree(&context, can_gc);
}
}