Clear ComputedStyle before detaching descendants. #24358
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
More importantly, make sure ComputedStyle is cleared before cancelling
animations. There is a problem with CSSAnimations::Cancel() marking for
style recalc during DetachLayoutTree() and updating the style recalc
root when DetachLayoutTree() was called due to an element being removed
from the flat tree during slot assignment.
At that time, the element is outside the flat tree for traversal, but
may have a ComputedStyle which is not IsEnsuredOutsideFlatTree().
The code to avoid having style recalc roots outside the flat tree in
MarkAncestorsWithChildNeedsStyleRecalc[1] relies on ComputedStyle being
null or IsEnsuredOutsideFlatTree().
An alternative approach to clearing the ComputedStyle early, would be to
pass an argument to Cancel() saying that the element is being removed
from the flat tree and make sure we don't try to mark for style recalc
in that case. Or, introduce a DetachLayoutTreeNotForReattachScope which
sets a flag to make sure we don't mark for style recalc or update the
recalc root.
[1] https://source.chromium.org/chromium/chromium/src/+/065224b3301f8e531a7fb750e5245891cd1a0e53:third_party/blink/renderer/core/dom/node.cc;l=1367-1381
Bug: 1093747
Change-Id: I7c133e6372a11bd0b87002f4eb54316588d05564
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2268938
Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#783451}