layout: Lay out Shadow DOM elements (#34701)

When an element is a shadow root, lay out the shadow root elements
instead of the non-shadow children.

This fixes some tests and introduces some failures, due to bugs in the
Shadow DOM implementation. In general, this is very low impact as the
Shadow DOM is still disabled by default. At least this gets elements
rendering when the preference is turned on though.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2024-12-19 20:24:42 +01:00 committed by GitHub
parent b7460bcb84
commit 50c9c72778
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 32 additions and 67 deletions

View file

@ -558,19 +558,24 @@ impl Element {
};
shadow_root.bind_to_tree(&bind_context);
self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
let node = self.upcast::<Node>();
node.dirty(NodeDamage::OtherNodeDamage);
node.rev_version();
Ok(shadow_root)
}
pub fn detach_shadow(&self) {
if let Some(ref shadow_root) = self.shadow_root() {
self.upcast::<Node>().note_dirty_descendants();
shadow_root.detach();
self.ensure_rare_data().shadow_root = None;
} else {
debug_assert!(false, "Trying to detach a non-attached shadow root");
}
let Some(ref shadow_root) = self.shadow_root() else {
unreachable!("Trying to detach a non-attached shadow root");
};
let node = self.upcast::<Node>();
node.note_dirty_descendants();
node.rev_version();
shadow_root.detach();
self.ensure_rare_data().shadow_root = None;
}
// https://html.spec.whatwg.org/multipage/#translation-mode