Skip to content

Commit cc00fe6

Browse files
committed
[scroll-animations] setting iterations to Infinity should throw for effects associated with a progress-based animation
https://bugs.webkit.org/show_bug.cgi?id=284446 rdar://141271158 Reviewed by NOBODY (OOPS!). It does not make sense to have an infinite duration for a progress-based animation, so we should throw in that situation. Since the relevant specifications do not call this out specifically yet, even though it is tested that way in WPT and Chrome implements this behavior, the following spec issue was filed: w3c/csswg-drafts#11343. * LayoutTests/imported/w3c/web-platform-tests/scroll-animations/scroll-timelines/effect-updateTiming-expected.txt: * Source/WebCore/animation/AnimationEffect.cpp: (WebCore::AnimationEffect::updateTiming):
1 parent 3fa7ffb commit cc00fe6

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

LayoutTests/imported/w3c/web-platform-tests/scroll-animations/scroll-timelines/effect-updateTiming-expected.txt

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ PASS Throws when setting invalid iterationStart value: NaN
2323
PASS Throws when setting invalid iterationStart value: Infinity
2424
PASS Throws when setting invalid iterationStart value: -Infinity
2525
PASS Allows setting iterations to a double value
26-
FAIL Throws when setting iterations to Infinity assert_throws_js: test function "() => {
27-
anim.effect.updateTiming({ iterations: Infinity });
28-
}" did not throw
26+
PASS Throws when setting iterations to Infinity
2927
PASS Allows setting the iterations of an animation in progress
3028
FAIL Allows setting the iterations of an animation in progress with duration "auto" assert_equals: progress after adding an iteration expected 1 but got 0
3129
PASS Allows setting the duration to 123.45

Source/WebCore/animation/AnimationEffect.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,18 @@ ExceptionOr<void> AnimationEffect::updateTiming(Document& document, std::optiona
190190
}
191191
}
192192

193+
if (auto iterations = timing->iterations) {
194+
// https://github.com/w3c/csswg-drafts/issues/11343
195+
if (std::isinf(*iterations)) {
196+
if (RefPtr animation = m_animation.get()) {
197+
if (RefPtr timeline = animation->timeline()) {
198+
if (timeline->isProgressBased())
199+
return Exception { ExceptionCode::TypeError, "The number of iterations cannot be set to Infinity for progress-based animations"_s };
200+
}
201+
}
202+
}
203+
}
204+
193205
// 4. If the easing member of input is present but cannot be parsed using the <timing-function> production [CSS-EASING-1], throw a TypeError and abort this procedure.
194206
if (!timing->easing.isNull()) {
195207
CSSParserContext parsingContext(document);

0 commit comments

Comments
 (0)