[Web Animations] setKeyframes does not preserve animation's current offset
https://bugs.webkit.org/show_bug.cgi?id=222939
<rdar://problem/75207793>
Reviewed by Dean Jackson.
Source/WebCore:
Test: webanimations/set-keyframes-after-animation-completion.html
When setKeyframes() is called on a KeyframeEffect, it clears the existing blending keyframes
created for the style system which will be re-populated on the next style update.
When an animation completes, it becomes eligible for being removed unless its effect is the
top-most effect in the target element's effect stack affecting one of the CSS properties
animated by effects in the stack. To determine what properties an effect animates, the method
KeyframeEffect::animatedProperties() is used.
Until now, KeyframeEffect::animatedProperties() simply returned the properties from the
blending keyframes. As such, if blending keyframes are empty, that method returns an empty
set of properties.
Since blending keyframes are cleared by a call to setKeyframes(), calling this method on
the effect of an animation that just finished will remove that animation and the effect
will no longer be applied when updating styles.
To fix this, we add a new instance variable on KeyframeEffect to store the list of properties
affected by the effect from the keyframes parsed by setKeyframes() until we generate the
blending keyframes during the next style update.
As soon as we generate the blending keyframes and setBlendingKeyframes() is called, we clear
that new property. This guarantees that no matter how keyframes are specified – CSS Transitions,
CSS Animations or Web Animations JS API – the animatedProperties() method returns the set
of affected properties.
* animation/KeyframeEffect.cpp:
(WebCore::KeyframeEffect::animatedProperties):
(WebCore::KeyframeEffect::setBlendingKeyframes):
* animation/KeyframeEffect.h:
(WebCore::KeyframeEffect::animatedProperties const): Deleted.
LayoutTests:
Add a new test that checks that updating keyframes after an animation has completed
correctly updates styles accounting for the new keyframes.
* webanimations/set-keyframes-after-animation-completion-expected.html: Added.
* webanimations/set-keyframes-after-animation-completion.html: Added.
Canonical link: https://commits.webkit.org/235086@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274165 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-09 20:09:49 +00:00
|
|
|
<style>
|
|
|
|
|
|
|
|
#target {
|
|
|
|
width: 100px;
|
|
|
|
height: 100px;
|
|
|
|
background-color: black;
|
|
|
|
margin-left: 150px;
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|
|
|
|
<div id="target"></div>
|