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

@ -10,6 +10,7 @@ use script_layout_interface::wrapper_traits::{ThreadSafeLayoutElement, ThreadSaf
use script_layout_interface::{LayoutElementType, LayoutNodeType};
use selectors::Element as SelectorsElement;
use servo_arc::Arc as ServoArc;
use style::dom::{TElement, TShadowRoot};
use style::properties::ComputedValues;
use style::selector_parser::PseudoElement;
use style::values::generics::counters::{Content, ContentItem};
@ -467,6 +468,10 @@ pub(crate) fn iter_child_nodes<'dom, Node>(parent: Node) -> impl Iterator<Item =
where
Node: NodeExt<'dom>,
{
if let Some(shadow) = parent.as_element().and_then(|e| e.shadow_root()) {
return iter_child_nodes(shadow.as_node());
};
let mut next = parent.first_child();
std::iter::from_fn(move || {
next.inspect(|child| {