Bug 1356141 - Check the child is unstyled without creating element data in preprocess_children. r?heycam
If we check it and skip the child after ensure_element_data() call,
the child will have an empty element data, so we will succeed
element_data.is_some() check unexpectedly.
MozReview-Commit-ID: 1kcyHfDzxCB
--- a/servo/components/style/traversal.rs
+++ b/servo/components/style/traversal.rs
@@ -859,24 +859,24 @@ where
// Loop over all the traversal children.
for child in element.as_node().traversal_children() {
// FIXME(bholley): Add TElement::element_children instead of this.
let child = match child.as_element() {
Some(el) => el,
None => continue,
};
+ // If the child is unstyled, we don't need to set up any restyling.
+ if child.borrow_data().map_or(true, |d| !d.has_styles()) {
+ continue;
+ }
+
let mut child_data =
unsafe { D::ensure_element_data(&child).borrow_mut() };
- // If the child is unstyled, we don't need to set up any restyling.
- if !child_data.has_styles() {
- continue;
- }
-
trace!(" > {:?} -> {:?} + {:?}, pseudo: {:?}",
child,
child_data.restyle.hint,
propagated_hint,
child.implemented_pseudo_element());
// Propagate the parent restyle hint, that may make us restyle the whole
// subtree.