From 0d70311c90f1b8181dbd7ce0f060597b4b78859e Mon Sep 17 00:00:00 2001 From: Matthew Olsson Date: Sun, 17 Mar 2024 17:32:09 -0700 Subject: [PATCH] LibWeb: Resolve unresolved style values eagerly in KeyframeEffect This isn't required as the StyleComputer will do this when animating, but this allows the properties to be resolved once instead of on every animation frame. Note that we still pass AllowUnresolved::Yes because the properties will not be resolved if there is no target. --- Userland/Libraries/LibWeb/Animations/KeyframeEffect.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/Animations/KeyframeEffect.cpp b/Userland/Libraries/LibWeb/Animations/KeyframeEffect.cpp index e19277e898b..5ce6e1ab78b 100644 --- a/Userland/Libraries/LibWeb/Animations/KeyframeEffect.cpp +++ b/Userland/Libraries/LibWeb/Animations/KeyframeEffect.cpp @@ -830,13 +830,16 @@ WebIDL::ExceptionOr KeyframeEffect::set_keyframes(Optionaltarget(); for (auto& keyframe : m_keyframes) { Animations::KeyframeEffect::KeyFrameSet::ResolvedKeyFrame resolved_keyframe; auto key = static_cast(keyframe.computed_offset.value() * 100 * AnimationKeyFrameKeyScaleFactor); - for (auto const& [property_id, property_value] : keyframe.parsed_properties()) { + for (auto [property_id, property_value] : keyframe.parsed_properties()) { + if (property_value->is_unresolved() && target) + property_value = CSS::Parser::Parser::resolve_unresolved_style_value(CSS::Parser::ParsingContext { target->document() }, *target, pseudo_element_type(), property_id, property_value->as_unresolved()); CSS::StyleComputer::for_each_property_expanding_shorthands(property_id, property_value, CSS::StyleComputer::AllowUnresolved::Yes, [&](CSS::PropertyID shorthand_id, CSS::StyleValue const& shorthand_value) { m_target_properties.set(shorthand_id); resolved_keyframe.properties.set(shorthand_id, NonnullRefPtr { shorthand_value });