haikuwebkit/LayoutTests/svg/animations/animate-calcMode-paced-over...

27 lines
918 B
HTML
Raw Permalink Normal View History

SVG paced value animations overwrite user-provided keyTimes https://bugs.webkit.org/show_bug.cgi?id=109010 Reviewed by Ryosuke Niwa. LayoutTests/imported/w3c: * web-platform-tests/svg/animations/scripted/paced-value-animation-overwrites-keyTimes-expected.txt: Source/WebCore: If the calcMode is Paced, the 'keyTimes' attribute is ignored. Distances between the 'values' are used produce an even pace of change across the animation. When changing calcMode, times defined in the 'keyTimes' attribute should be used instead. To fix this, SVGAnimationElement can maintain two lists for keyTimes: (1) keyTimesFromAttribute (2) keyTimesForPaced. One of these lists will be picked by a new function 'keyTimes()' based on the current calcMode. Specs: https://www.w3.org/TR/SVG11/animate.html#CalcModeAttribute Test: svg/animations/animate-calcMode-paced-overwrite-key-times.html * svg/SVGAnimationElement.cpp: (WebCore::SVGAnimationElement::parseAttribute): (WebCore::SVGAnimationElement::calculateKeyTimesForCalcModePaced): (WebCore::SVGAnimationElement::keyTimes const): (WebCore::SVGAnimationElement::calculateKeyTimesIndex const): (WebCore::SVGAnimationElement::calculatePercentFromKeyPoints const): (WebCore::SVGAnimationElement::calculatePercentForFromTo const): (WebCore::SVGAnimationElement::currentValuesFromKeyPoints const): (WebCore::SVGAnimationElement::currentValuesForValuesAnimation): (WebCore::SVGAnimationElement::startedActiveInterval): (WebCore::SVGAnimationElement::updateAnimation): * svg/SVGAnimationElement.h: LayoutTests: Simplified from the WPT paced-value-animation-overwrites-keyTimes.html. * svg/animations/animate-calcMode-paced-overwrite-key-times-expected.html: Added. * svg/animations/animate-calcMode-paced-overwrite-key-times.html: Added. Canonical link: https://commits.webkit.org/236433@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275868 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-13 08:05:24 +00:00
<body>
<svg id="svg" width="500" height="500">
<rect x="150" y="0" width="100" height="100" fill="red"/>
<rect width="100" height="100" fill="green">
<animate id="animate1" attributeName="x" dur="10s" calcMode="paced" values="100; 150; 200;" keyTimes="0; 0.2; 1"/>
</rect>
</svg>
<script>
window.addEventListener('load', (event) => {
if (window.testRunner)
testRunner.waitUntilDone();
window.requestAnimationFrame(() => {
let svg = document.getElementById('svg');
let animate1 = document.getElementById('animate1');
animate1.setAttribute('calcMode', 'linear');
svg.pauseAnimations();
svg.setCurrentTime(2);
if (window.testRunner)
testRunner.notifyDone();
});
});
</script>
</body>