haikuwebkit/LayoutTests/webanimations/accelerated-animation-singl...

35 lines
991 B
HTML
Raw Permalink Normal View History

[Web Animations] Animation with a single keyframe is not accelerated https://bugs.webkit.org/show_bug.cgi?id=188730 <rdar://problem/43481113> Reviewed by Dean Jackson. Source/WebCore: Test: webanimations/accelerated-animation-single-keyframe.html Prior to attempting to run an accelerated effect, ensure that the KeyframeList passed to RenderLayerModelObject::startAnimation() does not have implicit keyframes since eventually GraphicsLayerCA::animationCanBeAccelerated() would be called and would reject a single-keyframe animation. To do this, we use the same code used in Style::Resolver::keyframeStylesForAnimation() which we refactor in the new KeyframeList::fillImplicitKeyframes() method. * animation/KeyframeEffect.cpp: (WebCore::KeyframeEffect::copyPropertiesFromSource): (WebCore::KeyframeEffect::applyPendingAcceleratedActions): * rendering/style/KeyframeList.cpp: (WebCore::KeyframeList::hasImplicitKeyframes const): (WebCore::KeyframeList::copyKeyframes): (WebCore::zeroPercentKeyframe): (WebCore::hundredPercentKeyframe): (WebCore::KeyframeList::fillImplicitKeyframes): * rendering/style/KeyframeList.h: * style/StyleResolver.cpp: (WebCore::Style::Resolver::keyframeStylesForAnimation): LayoutTests: Add a new test that runs a single-keyframe transform animation and checks that it runs accelerated. * webanimations/accelerated-animation-single-keyframe-expected.txt: Added. * webanimations/accelerated-animation-single-keyframe.html: Added. Canonical link: https://commits.webkit.org/224849@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261756 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-15 20:07:26 +00:00
<!DOCTYPE html>
<body>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<style>
#target {
position: absolute;
left: 0;
top: 0;
width: 100px;
height: 100px;
background-color: black;
}
</style>
<div id="target"></div>
<script>
async_test(async t => {
// Start an animation with an implicit from keyframe.
const animation = document.getElementById("target").animate({ transform: "translateX(600px)" }, { duration: 1000 * 1000 });
// Wait two frames for the accelerated animation to be committed.
await animation.ready;
await new Promise(requestAnimationFrame);
await new Promise(requestAnimationFrame);
assert_equals(internals.acceleratedAnimationsForElement(target).length, 1, "There should be an accelerated animation.");
t.done();
}, "A transform animation with a single keyframe should be able to run accelerated.");
</script>
</body>