Bug 1351535 - Part 4: Don't traverse children if the root of the restyle is display:none. r?bholley draft
authorCameron McCormack <cam@mcc.id.au>
Tue, 04 Apr 2017 19:22:42 +0800
changeset 555568 1352b556f9a6486579a9417db06fb4ab36ecadfc
parent 555567 f98694b0829d0798b16d5a63c26b26705529e595
child 555569 4d050465fee8a64e4b3443ea512d8698c2450a46
push id52264
push userbmo:cam@mcc.id.au
push dateTue, 04 Apr 2017 13:50:52 +0000
reviewersbholley
bugs1351535
milestone55.0a1
Bug 1351535 - Part 4: Don't traverse children if the root of the restyle is display:none. r?bholley If we append a child to a display:none element, and we use StyleNewChildren on that parent, we should skip restyling the children. MozReview-Commit-ID: 7A6e7sPNHIA
servo/components/style/traversal.rs
--- a/servo/components/style/traversal.rs
+++ b/servo/components/style/traversal.rs
@@ -134,16 +134,22 @@ pub trait DomTraversal<E: TElement> : Sy
     /// If traversal_flag::UNSTYLED_CHILDREN_ONLY is specified, style newly-
     /// appended children without restyling the parent.
     /// If traversal_flag::ANIMATION_ONLY is specified, style only elements for
     /// animations.
     fn pre_traverse(root: E, stylist: &Stylist, traversal_flags: TraversalFlags)
                     -> PreTraverseToken
     {
         if traversal_flags.for_unstyled_children_only() {
+            if root.borrow_data().map_or(true, |d| d.has_styles() && d.styles().is_display_none()) {
+                return PreTraverseToken {
+                    traverse: false,
+                    unstyled_children_only: false,
+                };
+            }
             return PreTraverseToken {
                 traverse: true,
                 unstyled_children_only: true,
             };
         }
 
         // Expand the snapshot, if any. This is normally handled by the parent, so
         // we need a special case for the root.