mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWeb: Produce correct resolved value for animation-duration
This commit is contained in:
parent
c8d91c127e
commit
8a197b7ee5
Notes:
github-actions[bot]
2025-11-28 13:25:19 +00:00
Author: https://github.com/Calme1709
Commit: 8a197b7ee5
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6912
Reviewed-by: https://github.com/AtkinsSJ ✅
2 changed files with 37 additions and 4 deletions
|
|
@ -21,6 +21,7 @@
|
|||
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ShorthandStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValueList.h>
|
||||
#include <LibWeb/CSS/StyleValues/TimeStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/TransformationStyleValue.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
|
|
@ -870,6 +871,38 @@ RefPtr<StyleValue const> CSSStyleProperties::style_value_for_computed_property(L
|
|||
return TransformationStyleValue::create(PropertyID::Transform, TransformFunction::Matrix3d, move(parameters));
|
||||
}
|
||||
}
|
||||
case PropertyID::AnimationDuration: {
|
||||
// https://drafts.csswg.org/css-animations-2/#animation-duration
|
||||
// For backwards-compatibility with Level 1, when the computed value of animation-timeline is auto (i.e. only
|
||||
// one list value, and that value being auto), the resolved value of auto for animation-duration is 0s whenever
|
||||
// its used value would also be 0s.
|
||||
auto const& animation_timeline_computed_value = get_computed_value(PropertyID::AnimationTimeline);
|
||||
auto const& animation_duration_computed_value = get_computed_value(PropertyID::AnimationDuration);
|
||||
|
||||
if (animation_timeline_computed_value.to_keyword() == Keyword::Auto) {
|
||||
|
||||
// FIXME: We can remove these two branches once parse_comma_separated_value_list always returns StyleValueList.
|
||||
if (animation_duration_computed_value.to_keyword() == Keyword::Auto)
|
||||
return TimeStyleValue::create(Time::make_seconds(0));
|
||||
|
||||
if (!animation_duration_computed_value.is_value_list())
|
||||
return animation_duration_computed_value;
|
||||
|
||||
StyleValueVector resolved_durations;
|
||||
|
||||
for (auto const& duration : animation_duration_computed_value.as_value_list().values()) {
|
||||
if (duration->to_keyword() == Keyword::Auto) {
|
||||
resolved_durations.append(TimeStyleValue::create(Time::make_seconds(0)));
|
||||
} else {
|
||||
resolved_durations.append(duration);
|
||||
}
|
||||
}
|
||||
|
||||
return StyleValueList::create(move(resolved_durations), StyleValueList::Separator::Comma);
|
||||
}
|
||||
|
||||
return animation_duration_computed_value;
|
||||
}
|
||||
|
||||
// -> Any other property
|
||||
// The resolved value is the computed value.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue