Bonus fix: Be more robust about clearing descendants bits under display:none subtrees.

MozReview-Commit-ID: 9KQVOpdEjwF
This commit is contained in:
Bobby Holley 2017-08-14 17:07:43 -07:00
parent 05a1b682bb
commit 8a3761972d
3 changed files with 30 additions and 17 deletions

View file

@ -597,18 +597,10 @@ where
data.clear_restyle_flags_and_damage();
}
// Optionally clear the descendants bit for the traversal type we're in.
if flags.for_animation_only() {
if flags.contains(ClearAnimationOnlyDirtyDescendants) {
unsafe { element.unset_animation_only_dirty_descendants(); }
}
} else {
// There are two cases when we want to clear the dity descendants bit here
// after styling this element. The first case is when we were explicitly
// asked to clear the bit by the caller.
//
// The second case is when this element is the root of a display:none
// subtree, even if the style didn't change (since, if the style did change,
// Optionally clear the descendants bits.
if data.styles.is_display_none() {
// When this element is the root of a display:none subtree, we want to clear
// the bits even if the style didn't change (since, if the style did change,
// we'd have already cleared it above).
//
// This keeps the tree in a valid state without requiring the DOM to check
@ -616,10 +608,18 @@ where
// moderately expensive). Instead, DOM implementations can unconditionally
// set the dirty descendants bit on any styled parent, and let the traversal
// sort it out.
if flags.contains(ClearDirtyDescendants) ||
data.styles.is_display_none() {
unsafe { element.unset_dirty_descendants(); }
//
// Note that the NODE_DESCENDANTS_NEED_FRAMES bit should generally only be set
// when appending content beneath an element with a frame (i.e. not
// display:none), so clearing it here isn't strictly necessary, but good
// belt-and-suspenders.
unsafe { element.clear_descendants_bits(); }
} else if flags.for_animation_only() {
if flags.contains(ClearAnimationOnlyDirtyDescendants) {
unsafe { element.unset_animation_only_dirty_descendants(); }
}
} else if flags.contains(ClearDirtyDescendants) {
unsafe { element.unset_dirty_descendants(); }
}
context.thread_local.end_element(element);
@ -849,7 +849,6 @@ where
}
unsafe {
el.unset_dirty_descendants();
el.unset_animation_only_dirty_descendants();
el.clear_descendants_bits();
}
}