From 50c0b4549cc98501b0e4fc3a9c57fb3ac3e9c272 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Tue, 9 Sep 2025 13:49:34 +0100 Subject: [PATCH] LibWeb/CSS: Take AbstractElement in collect_animation_into() --- Libraries/LibWeb/Animations/KeyframeEffect.cpp | 6 +++--- Libraries/LibWeb/CSS/StyleComputer.cpp | 16 ++++++++-------- Libraries/LibWeb/CSS/StyleComputer.h | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Libraries/LibWeb/Animations/KeyframeEffect.cpp b/Libraries/LibWeb/Animations/KeyframeEffect.cpp index 91c06be2488..bc06821e30f 100644 --- a/Libraries/LibWeb/Animations/KeyframeEffect.cpp +++ b/Libraries/LibWeb/Animations/KeyframeEffect.cpp @@ -925,14 +925,14 @@ void KeyframeEffect::update_computed_properties(AnimationUpdateContext& context) auto computed_properties = target->computed_properties(pseudo_element_type()); if (!computed_properties) return; - - context.elements.ensure(DOM::AbstractElement { *target, pseudo_element_type() }, [computed_properties] { + DOM::AbstractElement abstract_element { *target, pseudo_element_type() }; + context.elements.ensure(abstract_element, [computed_properties] { auto old_animated_properties = computed_properties->animated_property_values(); computed_properties->reset_animated_properties({}); return make(move(old_animated_properties), computed_properties); }); - target->document().style_computer().collect_animation_into(*target, pseudo_element_type(), *this, *computed_properties); + target->document().style_computer().collect_animation_into(abstract_element, *this, *computed_properties); } } diff --git a/Libraries/LibWeb/CSS/StyleComputer.cpp b/Libraries/LibWeb/CSS/StyleComputer.cpp index 1adfd73e0ff..0806c8f9a8b 100644 --- a/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -877,7 +877,7 @@ static void cascade_custom_properties(DOM::Element& element, Optional pseudo_element, GC::Ref effect, ComputedProperties& computed_properties) const +void StyleComputer::collect_animation_into(DOM::AbstractElement abstract_element, GC::Ref effect, ComputedProperties& computed_properties) const { auto animation = effect->associated_animation(); if (!animation) @@ -930,7 +930,7 @@ void StyleComputer::collect_animation_into(DOM::Element& element, Optional> result; HashMap longhands_set_by_property_id; auto property_is_set_by_use_initial = MUST(Bitmap::create(number_of_longhand_properties, false)); @@ -972,7 +972,7 @@ void StyleComputer::collect_animation_into(DOM::Element& element, Optionalis_unresolved()) - style_value = Parser::Parser::resolve_unresolved_style_value(Parser::ParsingParams { element.document() }, { element, pseudo_element }, property_id, style_value->as_unresolved()); + style_value = Parser::Parser::resolve_unresolved_style_value(Parser::ParsingParams { abstract_element.document() }, abstract_element, property_id, style_value->as_unresolved()); for_each_property_expanding_shorthands(property_id, *style_value, [&](PropertyID longhand_id, StyleValue const& longhand_value) { auto physical_longhand_id = map_logical_alias_to_physical_property(longhand_id, LogicalAliasMappingContext { computed_properties.writing_mode(), computed_properties.direction() }); @@ -1022,10 +1022,10 @@ void StyleComputer::collect_animation_into(DOM::Element& element, Optional StyleValue const& { if (longhand_value.is_inherit() || (longhand_value.is_unset() && is_inherited_property(longhand_id))) { - if (auto inherited_animated_value = get_animated_inherit_value(longhand_id, { element }); inherited_animated_value.has_value()) + if (auto inherited_animated_value = get_animated_inherit_value(longhand_id, abstract_element); inherited_animated_value.has_value()) return inherited_animated_value.value(); - return get_inherit_value(longhand_id, { element }); + return get_inherit_value(longhand_id, abstract_element); } if (longhand_value.is_initial() || longhand_value.is_unset()) @@ -1338,7 +1338,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(*transition->effect()), new_style); + collect_animation_into({ element }, as(*transition->effect()), new_style); }; // 1. If all of the following are true: @@ -2617,7 +2617,7 @@ GC::Ref StyleComputer::compute_properties(DOM::AbstractEleme if (auto effect = animation->effect(); effect && effect->is_keyframe_effect()) { auto& keyframe_effect = *static_cast(effect.ptr()); if (keyframe_effect.pseudo_element_type() == pseudo_element) - collect_animation_into(element, pseudo_element, keyframe_effect, computed_style); + collect_animation_into(abstract_element, keyframe_effect, computed_style); } } } diff --git a/Libraries/LibWeb/CSS/StyleComputer.h b/Libraries/LibWeb/CSS/StyleComputer.h index 8d9407f8132..2c583a00796 100644 --- a/Libraries/LibWeb/CSS/StyleComputer.h +++ b/Libraries/LibWeb/CSS/StyleComputer.h @@ -182,7 +182,7 @@ public: void set_viewport_rect(Badge, CSSPixelRect const& viewport_rect) { m_viewport_rect = viewport_rect; } - void collect_animation_into(DOM::Element&, Optional, GC::Ref animation, ComputedProperties&) const; + void collect_animation_into(DOM::AbstractElement, GC::Ref animation, ComputedProperties&) const; [[nodiscard]] bool may_have_has_selectors() const; [[nodiscard]] bool have_has_selectors() const;