|
21 | 21 | #include <LibWeb/CSS/StyleValues/PercentageStyleValue.h> |
22 | 22 | #include <LibWeb/CSS/StyleValues/ShorthandStyleValue.h> |
23 | 23 | #include <LibWeb/CSS/StyleValues/StyleValueList.h> |
| 24 | +#include <LibWeb/CSS/StyleValues/TimeStyleValue.h> |
24 | 25 | #include <LibWeb/CSS/StyleValues/TransformationStyleValue.h> |
25 | 26 | #include <LibWeb/DOM/Document.h> |
26 | 27 | #include <LibWeb/DOM/Element.h> |
@@ -870,6 +871,38 @@ RefPtr<StyleValue const> CSSStyleProperties::style_value_for_computed_property(L |
870 | 871 | return TransformationStyleValue::create(PropertyID::Transform, TransformFunction::Matrix3d, move(parameters)); |
871 | 872 | } |
872 | 873 | } |
| 874 | + case PropertyID::AnimationDuration: { |
| 875 | + // https://drafts.csswg.org/css-animations-2/#animation-duration |
| 876 | + // For backwards-compatibility with Level 1, when the computed value of animation-timeline is auto (i.e. only |
| 877 | + // one list value, and that value being auto), the resolved value of auto for animation-duration is 0s whenever |
| 878 | + // its used value would also be 0s. |
| 879 | + auto const& animation_timeline_computed_value = get_computed_value(PropertyID::AnimationTimeline); |
| 880 | + auto const& animation_duration_computed_value = get_computed_value(PropertyID::AnimationDuration); |
| 881 | + |
| 882 | + if (animation_timeline_computed_value.to_keyword() == Keyword::Auto) { |
| 883 | + |
| 884 | + // FIXME: We can remove these two branches once parse_comma_separated_value_list always returns StyleValueList. |
| 885 | + if (animation_duration_computed_value.to_keyword() == Keyword::Auto) |
| 886 | + return TimeStyleValue::create(Time::make_seconds(0)); |
| 887 | + |
| 888 | + if (!animation_duration_computed_value.is_value_list()) |
| 889 | + return animation_duration_computed_value; |
| 890 | + |
| 891 | + StyleValueVector resolved_durations; |
| 892 | + |
| 893 | + for (auto const& duration : animation_duration_computed_value.as_value_list().values()) { |
| 894 | + if (duration->to_keyword() == Keyword::Auto) { |
| 895 | + resolved_durations.append(TimeStyleValue::create(Time::make_seconds(0))); |
| 896 | + } else { |
| 897 | + resolved_durations.append(duration); |
| 898 | + } |
| 899 | + } |
| 900 | + |
| 901 | + return StyleValueList::create(move(resolved_durations), StyleValueList::Separator::Comma); |
| 902 | + } |
| 903 | + |
| 904 | + return animation_duration_computed_value; |
| 905 | + } |
873 | 906 |
|
874 | 907 | // -> Any other property |
875 | 908 | // The resolved value is the computed value. |
|
0 commit comments