mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-28 21:54:40 +03:00
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.
This commit is contained in:
parent
3dd9f2715f
commit
0d70311c90
Notes:
sideshowbarker
2024-07-17 09:49:33 +09:00
Author: https://github.com/mattco98 Commit: https://github.com/SerenityOS/serenity/commit/0d70311c90 Pull-request: https://github.com/SerenityOS/serenity/pull/23622 Issue: https://github.com/SerenityOS/serenity/issues/23609
@ -830,13 +830,16 @@ WebIDL::ExceptionOr<void> KeyframeEffect::set_keyframes(Optional<JS::Handle<JS::
|
||||
|
||||
auto keyframe_set = adopt_ref(*new KeyFrameSet);
|
||||
m_target_properties.clear();
|
||||
auto target = this->target();
|
||||
|
||||
for (auto& keyframe : m_keyframes) {
|
||||
Animations::KeyframeEffect::KeyFrameSet::ResolvedKeyFrame resolved_keyframe;
|
||||
|
||||
auto key = static_cast<u64>(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<CSS::StyleValue const> { shorthand_value });
|
||||
|
Loading…
Reference in New Issue
Block a user