Bug 1356141 - Check the child is unstyled without creating element data in preprocess_children. r?heycam draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Mon, 19 Jun 2017 13:39:24 +0900
changeset 596333 2cb5cbf7f669b06f2f8db3cb40cc3128bccde01b
parent 596332 6ef2e46d5eeed0e3c2c1f98565ea2cc76d951345
child 596334 53c085fb58333284918b664efcd8db26123dec36
push id64580
push userhikezoe@mozilla.com
push dateMon, 19 Jun 2017 04:40:50 +0000
reviewersheycam
bugs1356141
milestone56.0a1
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
servo/components/style/traversal.rs
--- 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.