LibWeb: Propagate 'auto' value of animation-duration

Avoids a crash when `animation-duration` was `auto`
This commit is contained in:
Callum Law 2025-11-23 17:29:06 +13:00 committed by Sam Atkins
parent c790de24dd
commit 826e947920
Notes: github-actions[bot] 2025-11-28 13:26:48 +00:00
2 changed files with 29 additions and 1 deletions

View file

@ -2287,7 +2287,27 @@ Vector<ComputedProperties::AnimationProperties> ComputedProperties::animations()
auto animation_fill_mode_style_value = coordinated_properties.get(PropertyID::AnimationFillMode).value()[i];
auto animation_composition_style_value = coordinated_properties.get(PropertyID::AnimationComposition).value()[i];
auto duration = Time::from_style_value(animation_duration_style_value, {}).to_milliseconds();
// https://drafts.csswg.org/css-animations-2/#animation-duration
auto duration = [&] -> Variant<double, String> {
// auto
if (animation_duration_style_value->to_keyword() == Keyword::Auto) {
// For time-driven animations, equivalent to 0s.
return 0;
// FIXME: For scroll-driven animations, equivalent to the duration necessary to fill the timeline in
// consideration of animation-range, animation-delay, and animation-iteration-count. See
// Scroll-driven Animations §4.1 Finite Timeline Calculations.
}
// <time [0s,∞]>
// FIXME: For scroll-driven animations, treated as auto.
// For time-driven animations, specifies the length of time that an animation takes to complete one cycle.
// A negative <time> is invalid.
return Time::from_style_value(animation_duration_style_value, {}).to_milliseconds();
}();
auto timing_function = EasingFunction::from_style_value(animation_timing_function_style_value);
auto iteration_count = [&] {

View file

@ -0,0 +1,8 @@
<!DOCTYPE html>
<style>
#foo {
animation-name: anim;
animation-duration: auto;
}
</style>
<div id="foo"></div>