haikuwebkit/LayoutTests/webanimations/css-transition-retargeting-...

59 lines
1.9 KiB
HTML
Raw Permalink Normal View History

REGRESSION: Delayed updating of the parallax images on pacificvoyages.net/posts https://bugs.webkit.org/show_bug.cgi?id=212213 <rdar://problem/63497946> Reviewed by Simon Fraser. Source/WebCore: Test: webanimations/css-transition-retargeting-during-ready-promise.html When a transition's ready promise is resolved, its start time is the same as the timeline's current time. This means that retargeting a transition at that moment will yield a progress of zero even though the transition was started before the current animation frame. This means that retargeting a property on each page rendering may start a new transition with the same from value, which can have an undesirable effect such as on the website reported in this bug. We now keep track of the timeline time when a transition is created and use this time as a start time override when applying the animation to compute the before-change style in AnimationTimeline::updateCSSTransitionsForElementAndProperty(). To do so, we pass an optional start time all the way from WebAnimation::resolve() through to WebAnimation::currentTime() and via the animation effect timing computation. * animation/AnimationEffect.cpp: (WebCore::AnimationEffect::getBasicTiming const): (WebCore::AnimationEffect::getComputedTiming const): * animation/AnimationEffect.h: * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::updateCSSTransitionsForElementAndProperty): * animation/CSSTransition.cpp: (WebCore::CSSTransition::CSSTransition): (WebCore::CSSTransition::resolve): * animation/CSSTransition.h: * animation/KeyframeEffect.cpp: (WebCore::KeyframeEffect::apply): * animation/KeyframeEffect.h: * animation/WebAnimation.cpp: (WebCore::WebAnimation::currentTime const): (WebCore::WebAnimation::resolve): * animation/WebAnimation.h: LayoutTests: Add a new test that checks that retargeting a transition while its "ready" promise is resolved uses a before-change style that will differ from the from style. * webanimations/css-transition-retargeting-during-ready-promise-expected.txt: Added. * webanimations/css-transition-retargeting-during-ready-promise.html: Added. Canonical link: https://commits.webkit.org/226359@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@263464 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-06-24 17:58:46 +00:00
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.target {
margin-left: 0;
transition: margin-left 1s linear;
}
.target.in-flight {
margin-left: 100px;
}
.target.in-flight.retargeted {
margin-left: 200px;
}
</style>
<body>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script>
'use strict';
promise_test(async test => {
const target = document.body.appendChild(document.createElement("div"));
target.classList.add("target");
const getAnimation = () => {
const animations = target.getAnimations();
assert_equals(animations.length, 1, "There is one animation applied to the target.");
const transition = animations[0];
assert_true(transition instanceof CSSTransition, "There is one transition applied to the target.");
return transition;
}
let initialTransition;
let retargetedTransition;
// Start the initial transition.
await new Promise(requestAnimationFrame);
target.classList.add("in-flight");
initialTransition = getAnimation();
// Wait until the animation is ready and retarget the transition.
await initialTransition.ready;
target.classList.add("retargeted");
retargetedTransition = getAnimation();
assert_not_equals(initialTransition, retargetedTransition, "Retargeting yielded a new transition.");
assert_not_equals(initialTransition.effect.getKeyframes()[0].marginLeft, retargetedTransition.effect.getKeyframes()[0].marginLeft, "The new transition used a different from value.");
assert_not_equals(initialTransition.effect.getKeyframes()[1].marginLeft, retargetedTransition.effect.getKeyframes()[1].marginLeft, "The new transition used a different to value.");
}, `A CSS transition that is retargeted during its ready promise should not use its from style as its before-change style.`);
</script>
</body>