Commit a69b9c61 authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

Use InDetach() to avoid marking style dirty animation cancelling.

This CL is a revert of [1] and an alternative fix for 1093747.

The original change caused increased memory use for some reason. It's
confirmed with a pinpoint job that this CL fixes that regression.

[1] https://crrev.com/c4a447a85cdb4de7740476a74c9d258feb0a976d

Bug: 1100637, 1093747
Change-Id: If13212db30f818e68649f56a5c68ca5221a73dc5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2278052Reviewed-by: default avatarAnders Hartvoll Ruud <andruud@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#786202}
parent f6daca9f
......@@ -527,7 +527,8 @@ void KeyframeEffect::ClearEffects() {
sampled_effect_ = nullptr;
if (GetAnimation())
GetAnimation()->RestartAnimationOnCompositor();
effect_target_->SetNeedsAnimationStyleRecalc();
if (!effect_target_->GetDocument().Lifecycle().InDetach())
effect_target_->SetNeedsAnimationStyleRecalc();
auto* svg_element = DynamicTo<SVGElement>(effect_target_.Get());
if (RuntimeEnabledFeatures::WebAnimationsSVGEnabled() && svg_element)
svg_element->ClearWebAnimatedAttributes();
......
......@@ -2874,6 +2874,24 @@ void Element::AttachLayoutTree(AttachContext& context) {
void Element::DetachLayoutTree(bool performing_reattach) {
HTMLFrameOwnerElement::PluginDisposeSuspendScope suspend_plugin_dispose;
if (HasRareData()) {
ElementRareData* data = GetElementRareData();
if (!performing_reattach)
data->ClearPseudoElements();
if (ElementAnimations* element_animations = data->GetElementAnimations()) {
if (performing_reattach) {
// FIXME: restart compositor animations rather than pull back to the
// main thread
element_animations->RestartAnimationOnCompositor();
} else {
DocumentLifecycle::DetachScope will_detach(GetDocument().Lifecycle());
element_animations->CssAnimations().Cancel();
element_animations->SetAnimationStyleChange(false);
}
element_animations->ClearBaseComputedStyle();
}
}
DetachPseudoElement(kPseudoIdMarker, performing_reattach);
DetachPseudoElement(kPseudoIdBefore, performing_reattach);
......@@ -2888,10 +2906,6 @@ void Element::DetachLayoutTree(bool performing_reattach) {
// https://crbug.com/939769
if (ChildNeedsReattachLayoutTree() || GetComputedStyle() ||
(!performing_reattach && IsUserActionElement())) {
if (!performing_reattach) {
UpdateCallbackSelectors(GetComputedStyle(), nullptr);
SetComputedStyle(nullptr);
}
if (ShadowRoot* shadow_root = GetShadowRoot()) {
shadow_root->DetachLayoutTree(performing_reattach);
Node::DetachLayoutTree(performing_reattach);
......@@ -2906,22 +2920,9 @@ void Element::DetachLayoutTree(bool performing_reattach) {
DetachPseudoElement(kPseudoIdBackdrop, performing_reattach);
DetachPseudoElement(kPseudoIdFirstLetter, performing_reattach);
if (HasRareData()) {
ElementRareData* data = GetElementRareData();
if (!performing_reattach)
data->ClearPseudoElements();
if (ElementAnimations* element_animations = data->GetElementAnimations()) {
if (performing_reattach) {
// FIXME: restart compositor animations rather than pull back to the
// main thread
element_animations->RestartAnimationOnCompositor();
} else {
element_animations->CssAnimations().Cancel();
element_animations->SetAnimationStyleChange(false);
}
element_animations->ClearBaseComputedStyle();
}
if (!performing_reattach) {
UpdateCallbackSelectors(GetComputedStyle(), nullptr);
SetComputedStyle(nullptr);
}
if (!performing_reattach && IsUserActionElement()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment