Bug 1418059 - Stop eagerly CSS animations on the root of display:none subtree. r=birtles

Otherwise we do update keyframes data unnecessarily.

MozReview-Commit-ID: ys4BEF1kxX

--HG--
extra : rebase_source : 725aef9a4be9296bc992f6128be7c62b4c2b01e1
This commit is contained in:
Hiroyuki Ikezoe 2017-11-20 13:56:26 +09:00
Родитель 264402226f
Коммит 49f31bb414
3 изменённых файлов: 35 добавлений и 5 удалений

Просмотреть файл

@ -0,0 +1,24 @@
<!DOCTYPE html>
<html class="reftest-wait">
<style>
@keyframes anim {
to { transform: rotate(360deg); }
}
.document-ready .animation::after {
display: none;
}
.animation::after {
content: "";
animation: anim 1s infinite;
}
</style>
<div class="animation"></div>
<script>
window.addEventListener('load', () => {
document.documentElement.classList.add('document-ready');
requestAnimationFrame(() => {
document.documentElement.classList.remove('reftest-wait');
});
});
</script>
</html>

Просмотреть файл

@ -263,3 +263,4 @@ load 1413361.html
load 1415663.html
pref(dom.webcomponents.enabled,true) load 1415353.html
load 1415021.html # This should have dom.webcomponents.enabled=true, but it leaks the world, see bug 1416296.
load 1418059.html

Просмотреть файл

@ -1068,10 +1068,17 @@ nsAnimationManager::UpdateAnimations(
"Should not update animations that are not attached to the "
"document tree");
if (!aStyleContext) {
const nsStyleDisplay* disp = aStyleContext
? aStyleContext->ComputedData()->GetStyleDisplay()
: nullptr;
if (!disp || disp->mDisplay == StyleDisplay::None) {
// If we are in a display:none subtree we will have no computed values.
// Since CSS animations should not run in display:none subtrees we should
// stop (actually, destroy) any animations on this element here.
// However, if we are on the root of display:none subtree, the computed
// values might not have been cleared yet.
// In either case, since CSS animations should not run in display:none
// subtrees we should stop (actually, destroy) any animations on this
// element here.
StopAnimationsForElement(aElement, aPseudoType);
return;
}
@ -1079,8 +1086,6 @@ nsAnimationManager::UpdateAnimations(
NonOwningAnimationTarget target(aElement, aPseudoType);
ServoCSSAnimationBuilder builder(aStyleContext);
const nsStyleDisplay *disp =
aStyleContext->ComputedData()->GetStyleDisplay();
DoUpdateAnimations(target, *disp, builder);
}