haikuwebkit/LayoutTests/animations/fill-mode.html

131 lines
3.9 KiB
HTML
Raw Permalink Normal View History

2010-03-05 Dean Jackson <dino@apple.com> Reviewed by Simon Fraser and Chris Marrin. Bug 26869: Add fill modes for CSS Animations https://bugs.webkit.org/show_bug.cgi?id=26869 Tests: animations/fill-mode-removed.html animations/fill-mode-transform.html animations/fill-mode.html * css/CSSComputedStyleDeclaration.cpp: * css/CSSParser.cpp: * css/CSSParser.h: * css/CSSPropertyNames.in: * css/CSSStyleSelector.cpp: * css/CSSStyleSelector.h: * css/CSSValueKeywords.in: - parse, assign and retrieve the value of the new -webkit-animation-fill-mode property * page/animation/AnimationBase.cpp: * page/animation/AnimationBase.h: - new state in animation engine for a finished animation that is "filling" forwards in time. This allows the engine to keep the animation around and not revert to the old style. - update the timer code to indicate it doesn't need to keep animating if it is filling - now that animations can extend beyond their elapsed time, make sure progress works correctly with iteration counts * page/animation/KeyframeAnimation.cpp: (WebCore::KeyframeAnimation::animate): - ensure correct style value is returned at the right time by checking for fill mode (WebCore::KeyframeAnimation::onAnimationEnd): - continue to send the end event, but only remove the animation if it isn't filling forwards * platform/animation/Animation.cpp: * platform/animation/Animation.h: - new fill mode member property * platform/animation/AnimationList.cpp: - ensure the fill mode is propagated to a list of style valus * platform/graphics/mac/GraphicsLayerCA.mm: - make hardware layers use Core Animation's fill mode Canonical link: https://commits.webkit.org/46873@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@55576 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-03-05 12:58:54 +00:00
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Test simple animation with fill modes</title>
<style type="text/css" media="screen">
.box {
position: relative;
left: 100px;
top: 10px;
height: 100px;
width: 100px;
-webkit-animation-delay: 0.1s;
-webkit-animation-duration: 0.1s;
-webkit-animation-timing-function: linear;
-webkit-animation-name: anim;
}
@-webkit-keyframes anim {
from { left: 200px; }
to { left: 300px; }
}
#a {
background-color: blue;
-webkit-animation-fill-mode: none;
}
#b {
background-color: red;
-webkit-animation-fill-mode: backwards;
}
#c {
background-color: green;
-webkit-animation-fill-mode: forwards;
}
#d {
background-color: yellow;
-webkit-animation-fill-mode: both;
}
#e {
background-color: #999;
-webkit-animation-fill-mode: both;
-webkit-animation-iteration-count: 2;
-webkit-animation-direction: alternate;
}
</style>
<script type="text/javascript" charset="utf-8">
const numAnims = 5;
var animsFinished = 0;
const allowance = 5;
const expectedValues = [
{id: "a", start: 100, end: 100},
{id: "b", start: 200, end: 100},
{id: "c", start: 100, end: 300},
{id: "d", start: 200, end: 300},
{id: "e", start: 200, end: 200}
];
var result = "";
Use testRunner instead of layoutTestController in animations tests https://bugs.webkit.org/show_bug.cgi?id=88757 Reviewed by Tony Chang. * animations/3d/change-transform-in-end-event.html: * animations/3d/replace-filling-transform.html: * animations/3d/state-at-end-event-transform.html: * animations/3d/transform-origin-vs-functions.html: * animations/animation-add-events-in-handler.html: * animations/animation-border-overflow.html: * animations/animation-controller-drt-api.html: * animations/animation-direction-reverse-fill-mode-hardware.html: * animations/animation-direction-reverse-fill-mode.html: * animations/animation-drt-api-multiple-keyframes.html: * animations/animation-drt-api.html: * animations/animation-end-event-destroy-renderer.html: * animations/animation-end-event-short-iterations.html: * animations/animation-hit-test-transform.html: * animations/animation-hit-test.html: * animations/animation-iteration-event-destroy-renderer.html: * animations/animation-matrix-negative-scale-unmatrix.html: * animations/animation-on-inline-crash.html: * animations/animation-shorthand-overriding.html: * animations/animation-shorthand-removed.html: * animations/animation-shorthand.html: * animations/animation-start-event-destroy-renderer.html: * animations/animation-welcome-safari.html: * animations/body-removal-crash.html: * animations/change-keyframes-name.html: * animations/change-transform-style-during-animation.html: * animations/combo-transform-translate+scale.html: * animations/empty-keyframes.html: * animations/fill-mode-forwards.html: * animations/fill-mode-iteration-count-non-integer.html: * animations/fill-mode-missing-from-to-keyframes.html: * animations/fill-mode-multiple-keyframes.html: * animations/fill-mode-removed.html: * animations/fill-mode-reverse.html: * animations/fill-mode-transform.html: * animations/fill-mode.html: * animations/fill-unset-properties.html: * animations/font-size-using-ems.html-disabled: * animations/import-crash.html: * animations/keyframe-timing-functions-transform.html: * animations/keyframe-timing-functions2.html: * animations/keyframes-iteration-count-non-integer.html: * animations/longhand-timing-function.html: * animations/missing-from-to-transforms.html: * animations/missing-from-to.html: * animations/pause-crash.html: * animations/resources/animation-test-helpers.js: (checkExpectedValue): (endTest): * animations/state-at-end-event.html: * animations/suspend-resume-animation-events.html: * animations/suspend-transform-animation.html: * animations/transition-and-animation-3.html: * animations/unanimated-style.html: Canonical link: https://commits.webkit.org/106621@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@119985 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-06-11 17:22:07 +00:00
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
2010-03-05 Dean Jackson <dino@apple.com> Reviewed by Simon Fraser and Chris Marrin. Bug 26869: Add fill modes for CSS Animations https://bugs.webkit.org/show_bug.cgi?id=26869 Tests: animations/fill-mode-removed.html animations/fill-mode-transform.html animations/fill-mode.html * css/CSSComputedStyleDeclaration.cpp: * css/CSSParser.cpp: * css/CSSParser.h: * css/CSSPropertyNames.in: * css/CSSStyleSelector.cpp: * css/CSSStyleSelector.h: * css/CSSValueKeywords.in: - parse, assign and retrieve the value of the new -webkit-animation-fill-mode property * page/animation/AnimationBase.cpp: * page/animation/AnimationBase.h: - new state in animation engine for a finished animation that is "filling" forwards in time. This allows the engine to keep the animation around and not revert to the old style. - update the timer code to indicate it doesn't need to keep animating if it is filling - now that animations can extend beyond their elapsed time, make sure progress works correctly with iteration counts * page/animation/KeyframeAnimation.cpp: (WebCore::KeyframeAnimation::animate): - ensure correct style value is returned at the right time by checking for fill mode (WebCore::KeyframeAnimation::onAnimationEnd): - continue to send the end event, but only remove the animation if it isn't filling forwards * platform/animation/Animation.cpp: * platform/animation/Animation.h: - new fill mode member property * platform/animation/AnimationList.cpp: - ensure the fill mode is propagated to a list of style valus * platform/graphics/mac/GraphicsLayerCA.mm: - make hardware layers use Core Animation's fill mode Canonical link: https://commits.webkit.org/46873@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@55576 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-03-05 12:58:54 +00:00
}
function animationEnded(event) {
if (++animsFinished == numAnims) {
setTimeout(endTest, 0); // this set timeout should be ok in the test environment
// since we're just giving style a chance to resolve
}
};
function endTest() {
for (var i=0; i < expectedValues.length; i++) {
var el = document.getElementById(expectedValues[i].id);
var expectedValue = expectedValues[i].end;
var realValue = window.getComputedStyle(el).getPropertyCSSValue("left").getFloatValue(CSSPrimitiveValue.CSS_NUMBER);
if (Math.abs(expectedValue - realValue) < allowance) {
result += "PASS";
} else {
result += "FAIL";
}
result += " - end of animation - id: " + expectedValues[i].id + " expected: " + expectedValue + " actual: " + realValue + "<br>";
}
document.getElementById('result').innerHTML = result;
Use testRunner instead of layoutTestController in animations tests https://bugs.webkit.org/show_bug.cgi?id=88757 Reviewed by Tony Chang. * animations/3d/change-transform-in-end-event.html: * animations/3d/replace-filling-transform.html: * animations/3d/state-at-end-event-transform.html: * animations/3d/transform-origin-vs-functions.html: * animations/animation-add-events-in-handler.html: * animations/animation-border-overflow.html: * animations/animation-controller-drt-api.html: * animations/animation-direction-reverse-fill-mode-hardware.html: * animations/animation-direction-reverse-fill-mode.html: * animations/animation-drt-api-multiple-keyframes.html: * animations/animation-drt-api.html: * animations/animation-end-event-destroy-renderer.html: * animations/animation-end-event-short-iterations.html: * animations/animation-hit-test-transform.html: * animations/animation-hit-test.html: * animations/animation-iteration-event-destroy-renderer.html: * animations/animation-matrix-negative-scale-unmatrix.html: * animations/animation-on-inline-crash.html: * animations/animation-shorthand-overriding.html: * animations/animation-shorthand-removed.html: * animations/animation-shorthand.html: * animations/animation-start-event-destroy-renderer.html: * animations/animation-welcome-safari.html: * animations/body-removal-crash.html: * animations/change-keyframes-name.html: * animations/change-transform-style-during-animation.html: * animations/combo-transform-translate+scale.html: * animations/empty-keyframes.html: * animations/fill-mode-forwards.html: * animations/fill-mode-iteration-count-non-integer.html: * animations/fill-mode-missing-from-to-keyframes.html: * animations/fill-mode-multiple-keyframes.html: * animations/fill-mode-removed.html: * animations/fill-mode-reverse.html: * animations/fill-mode-transform.html: * animations/fill-mode.html: * animations/fill-unset-properties.html: * animations/font-size-using-ems.html-disabled: * animations/import-crash.html: * animations/keyframe-timing-functions-transform.html: * animations/keyframe-timing-functions2.html: * animations/keyframes-iteration-count-non-integer.html: * animations/longhand-timing-function.html: * animations/missing-from-to-transforms.html: * animations/missing-from-to.html: * animations/pause-crash.html: * animations/resources/animation-test-helpers.js: (checkExpectedValue): (endTest): * animations/state-at-end-event.html: * animations/suspend-resume-animation-events.html: * animations/suspend-transform-animation.html: * animations/transition-and-animation-3.html: * animations/unanimated-style.html: Canonical link: https://commits.webkit.org/106621@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@119985 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-06-11 17:22:07 +00:00
if (window.testRunner)
testRunner.notifyDone();
2010-03-05 Dean Jackson <dino@apple.com> Reviewed by Simon Fraser and Chris Marrin. Bug 26869: Add fill modes for CSS Animations https://bugs.webkit.org/show_bug.cgi?id=26869 Tests: animations/fill-mode-removed.html animations/fill-mode-transform.html animations/fill-mode.html * css/CSSComputedStyleDeclaration.cpp: * css/CSSParser.cpp: * css/CSSParser.h: * css/CSSPropertyNames.in: * css/CSSStyleSelector.cpp: * css/CSSStyleSelector.h: * css/CSSValueKeywords.in: - parse, assign and retrieve the value of the new -webkit-animation-fill-mode property * page/animation/AnimationBase.cpp: * page/animation/AnimationBase.h: - new state in animation engine for a finished animation that is "filling" forwards in time. This allows the engine to keep the animation around and not revert to the old style. - update the timer code to indicate it doesn't need to keep animating if it is filling - now that animations can extend beyond their elapsed time, make sure progress works correctly with iteration counts * page/animation/KeyframeAnimation.cpp: (WebCore::KeyframeAnimation::animate): - ensure correct style value is returned at the right time by checking for fill mode (WebCore::KeyframeAnimation::onAnimationEnd): - continue to send the end event, but only remove the animation if it isn't filling forwards * platform/animation/Animation.cpp: * platform/animation/Animation.h: - new fill mode member property * platform/animation/AnimationList.cpp: - ensure the fill mode is propagated to a list of style valus * platform/graphics/mac/GraphicsLayerCA.mm: - make hardware layers use Core Animation's fill mode Canonical link: https://commits.webkit.org/46873@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@55576 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-03-05 12:58:54 +00:00
}
window.onload = function () {
for (var i=0; i < expectedValues.length; i++) {
var el = document.getElementById(expectedValues[i].id);
var expectedValue = expectedValues[i].start;
var realValue = window.getComputedStyle(el).getPropertyCSSValue("left").getFloatValue(CSSPrimitiveValue.CSS_NUMBER);
if (Math.abs(expectedValue - realValue) < allowance) {
result += "PASS";
} else {
result += "FAIL";
}
result += " - start of animation - id: " + expectedValues[i].id + " expected: " + expectedValue + " actual: " + realValue + "<br>";
}
document.addEventListener("webkitAnimationEnd", animationEnded, false);
};
</script>
</head>
<body>
This test performs an animation of the left property with four different
fill modes. It animates over 0.1 second with a 0.1 second delay.
It takes snapshots at document load and the end of the animation.
<div id="a" class="box">
None
</div>
<div id="b" class="box">
Backwards
</div>
<div id="c" class="box">
Forwards
</div>
<div id="d" class="box">
Both
</div>
<div id="e" class="box">
Both iterating
</div>
<div id="result">
</div>
</body>
</html>