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 558863 2589b7fca69a87e74d0fd3a9bf3c19a50f65cb64
parent 558862 30d4c9f84cfdd9c3ae0b8c8d5eff90c573d4f27c
child 558864 f30c0b04593311679e3d98fbdb7a3503634fa310
push id52975
push userbmo:cam@mcc.id.au
push dateSat, 08 Apr 2017 09:24:07 +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.