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
--- 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.