LibWeb: Allow UseInitial in keyframes when updating animated style

This removes the AnimationRefresh argument from `collect_animation_into`
which was added in a9b8840 - it's only effect was disallowing
`UseInitial`s within keyframes when we were doing animated style
updates which I believe is unintentional.

Gains us 214 WPT tests.
This commit is contained in:
Callum Law 2025-08-27 21:28:52 +12:00 committed by Jelle Raaijmakers
commit ede80ccdfb
Notes: github-actions[bot] 2025-08-27 12:52:16 +00:00
25 changed files with 260 additions and 270 deletions

View file

@ -1002,7 +1002,7 @@ static void cascade_custom_properties(DOM::Element& element, Optional<CSS::Pseud
}
}
void StyleComputer::collect_animation_into(DOM::Element& element, Optional<CSS::PseudoElement> pseudo_element, GC::Ref<Animations::KeyframeEffect> effect, ComputedProperties& computed_properties, AnimationRefresh refresh) const
void StyleComputer::collect_animation_into(DOM::Element& element, Optional<CSS::PseudoElement> pseudo_element, GC::Ref<Animations::KeyframeEffect> effect, ComputedProperties& computed_properties) const
{
auto animation = effect->associated_animation();
if (!animation)
@ -1055,7 +1055,7 @@ void StyleComputer::collect_animation_into(DOM::Element& element, Optional<CSS::
}
// FIXME: Follow https://drafts.csswg.org/web-animations-1/#ref-for-computed-keyframes in whatever the right place is.
auto compute_keyframe_values = [refresh, &computed_properties, &element, &pseudo_element, this](auto const& keyframe_values) {
auto compute_keyframe_values = [&computed_properties, &element, &pseudo_element, this](auto const& keyframe_values) {
HashMap<PropertyID, RefPtr<StyleValue const>> result;
HashMap<PropertyID, PropertyID> longhands_set_by_property_id;
auto property_is_set_by_use_initial = MUST(Bitmap::create(number_of_longhand_properties, false));
@ -1108,12 +1108,10 @@ void StyleComputer::collect_animation_into(DOM::Element& element, Optional<CSS::
auto style_value = value.visit(
[&](Animations::KeyframeEffect::KeyFrameSet::UseInitial) -> RefPtr<StyleValue const> {
if (refresh == AnimationRefresh::Yes)
return {};
if (property_is_shorthand(property_id))
return {};
is_use_initial = true;
return computed_properties.property(property_id);
return computed_properties.property(property_id, ComputedProperties::WithAnimationsApplied::No);
},
[&](RefPtr<StyleValue const> value) -> RefPtr<StyleValue const> {
return value;
@ -1431,7 +1429,7 @@ void StyleComputer::start_needed_transitions(ComputedProperties const& previous_
auto transition = CSSTransition::start_a_transition(element, pseudo_element, property_id,
document().transition_generation(), delay, start_time, end_time, start_value, end_value, reversing_adjusted_start_value, reversing_shortening_factor);
// Immediately set the property's value to the transition's current value, to prevent single-frame jumps.
collect_animation_into(element, {}, as<Animations::KeyframeEffect>(*transition->effect()), new_style, AnimationRefresh::No);
collect_animation_into(element, {}, as<Animations::KeyframeEffect>(*transition->effect()), new_style);
};
// 1. If all of the following are true: