Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
REGRESSION (r260360): easing curves are broken on JS-originated anima…
…tions https://bugs.webkit.org/show_bug.cgi?id=213495 <rdar://problem/64649747> Reviewed by Darin Adler. Source/WebCore: Prior to Web Animations, there was no way for an animation to set an animation-wide timing function while also setting a per-keyframe timing function. As such GraphicsLayerCA would sometimes decide to set the timing function on keyframes or on the entire CAAnimation. However, we can no longer do this with Web Animations where an animation can set an animation-wide timing function and also keyframe-specific timing functions. In this patch we create CAKeyframeAnimation objects for any animation that has at least two keyframes if Web Animations are enabled, whereas the legacy code path requires at least three keyframes. We allow PlatformCAAnimation::setTimingFunction() to be called in the Web Animations code path only under GraphicsLayerCA::setupAnimation() while leaving the only call sites in place only for the legacy code path. Finally, we modify GraphicsLayerCA::timingFunctionForAnimationValue() to only ever return a keyframe- specific timing function or fall back to a default linear timing function in the Web Animations code path, leaving the function to behave the same way as it used to in the legacy code path. Test: webanimations/accelerated-animation-with-easing.html * platform/animation/TimingFunction.h: * platform/graphics/ca/GraphicsLayerCA.cpp: (WebCore::isKeyframe): (WebCore::GraphicsLayerCA::createAnimationFromKeyframes): (WebCore::GraphicsLayerCA::appendToUncommittedAnimations): (WebCore::GraphicsLayerCA::createTransformAnimationsFromKeyframes): LayoutTests: Add a new test that checks that various ways of setting the easing timing function on a JS-originated animation always yield the same visible animation behavior. * webanimations/accelerated-animation-with-easing-expected.html: Added. * webanimations/accelerated-animation-with-easing.html: Added. Canonical link: https://commits.webkit.org/226392@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@263506 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
6 changed files
with
165 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
LayoutTests/webanimations/accelerated-animation-with-easing-expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<body style="background-color: green"> | ||
</body> |
84 changes: 84 additions & 0 deletions
84
LayoutTests/webanimations/accelerated-animation-with-easing.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<body> | ||
<style> | ||
|
||
body { | ||
background-color: green; | ||
} | ||
|
||
div { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100px; | ||
height: 100px; | ||
background-color: red; | ||
} | ||
|
||
/* Allow for a 1px error on either side */ | ||
#easing-on-keyframe { | ||
left: -1px; | ||
width: 102px; | ||
background-color: green; | ||
} | ||
|
||
</style> | ||
<div id="easing-on-animation-one-keyframe"></div> | ||
<div id="easing-on-animation-two-keyframes"></div> | ||
<div id="easing-on-animation-three-keyframes"></div> | ||
<div id="easing-on-keyframe"></div> | ||
<script> | ||
|
||
(async function() { | ||
if (window.testRunner) | ||
testRunner.waitUntilDone(); | ||
|
||
const animations = []; | ||
|
||
animations.push(document.getElementById("easing-on-animation-one-keyframe").animate({ transform: "translateX(100px)" }, { | ||
duration: 500, | ||
easing: "ease", | ||
direction: "alternate", | ||
iterations: Infinity | ||
})); | ||
|
||
animations.push(document.getElementById("easing-on-animation-two-keyframes").animate([ | ||
{ transform: "translateX(0)" }, | ||
{ transform: "translateX(100px)" } | ||
], { | ||
duration: 500, | ||
easing: "ease", | ||
direction: "alternate", | ||
iterations: Infinity | ||
})); | ||
|
||
animations.push(document.getElementById("easing-on-animation-three-keyframes").animate([ | ||
{ transform: "translateX(0)" }, | ||
{ transform: "translateX(50px)" }, | ||
{ transform: "translateX(100px)" } | ||
], { | ||
duration: 500, | ||
easing: "ease", | ||
direction: "alternate", | ||
iterations: Infinity | ||
})); | ||
|
||
animations.push(document.getElementById("easing-on-keyframe").animate([ | ||
{ transform: "translateX(0)", easing: "ease" }, | ||
{ transform: "translateX(100px)" } | ||
], { | ||
duration: 500, | ||
direction: "alternate", | ||
iterations: Infinity | ||
})); | ||
|
||
await Promise.all(animations.map(animation => animation.ready)); | ||
await new Promise(requestAnimationFrame); | ||
await new Promise(requestAnimationFrame); | ||
await new Promise(requestAnimationFrame); | ||
|
||
if (window.testRunner) | ||
testRunner.notifyDone(); | ||
})(); | ||
|
||
</script> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters