mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Include non-shadowdom children of shadow hosts in style calculation (#34298)
* Include non-shadowdom children of shadow hosts in style calculation This was previously causing crashes because the layout nodes of those children would never be assigned style data by stylo. 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:
parent
2889e934f5
commit
f3ad078358
77 changed files with 284 additions and 96 deletions
|
@ -140,20 +140,41 @@ impl<'dom> ServoLayoutElement<'dom> {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct DomChildrenIncludingShadowDom<N> {
|
||||
children: DomChildren<N>,
|
||||
children_in_shadow_root: Option<DomChildren<N>>,
|
||||
}
|
||||
|
||||
impl<N> Iterator for DomChildrenIncludingShadowDom<N>
|
||||
where
|
||||
N: TNode,
|
||||
{
|
||||
type Item = N;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
self.children
|
||||
.next()
|
||||
.or_else(|| self.children_in_shadow_root.as_mut()?.next())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'dom> style::dom::TElement for ServoLayoutElement<'dom> {
|
||||
type ConcreteNode = ServoLayoutNode<'dom>;
|
||||
type TraversalChildrenIterator = DomChildren<Self::ConcreteNode>;
|
||||
type TraversalChildrenIterator = DomChildrenIncludingShadowDom<Self::ConcreteNode>;
|
||||
|
||||
fn as_node(&self) -> ServoLayoutNode<'dom> {
|
||||
ServoLayoutNode::from_layout_js(self.element.upcast())
|
||||
}
|
||||
|
||||
fn traversal_children(&self) -> LayoutIterator<Self::TraversalChildrenIterator> {
|
||||
LayoutIterator(if let Some(shadow) = self.shadow_root() {
|
||||
shadow.as_node().dom_children()
|
||||
} else {
|
||||
self.as_node().dom_children()
|
||||
})
|
||||
let children = DomChildrenIncludingShadowDom {
|
||||
children: self.as_node().dom_children(),
|
||||
children_in_shadow_root: self
|
||||
.shadow_root()
|
||||
.map(|shadow| shadow.as_node().dom_children()),
|
||||
};
|
||||
|
||||
LayoutIterator(children)
|
||||
}
|
||||
|
||||
fn is_html_element(&self) -> bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue