From 524a161a511cd9e7472e174d6c153e732bd47c1d Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Tue, 9 Sep 2025 15:08:29 +0100 Subject: [PATCH] LibWeb: Take AbstractElement in start_a_transition() --- Libraries/LibWeb/CSS/CSSTransition.cpp | 22 +++++++++++----------- Libraries/LibWeb/CSS/CSSTransition.h | 4 ++-- Libraries/LibWeb/CSS/StyleComputer.cpp | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Libraries/LibWeb/CSS/CSSTransition.cpp b/Libraries/LibWeb/CSS/CSSTransition.cpp index de036a1451c..82a94f31720 100644 --- a/Libraries/LibWeb/CSS/CSSTransition.cpp +++ b/Libraries/LibWeb/CSS/CSSTransition.cpp @@ -19,12 +19,12 @@ namespace Web::CSS { GC_DEFINE_ALLOCATOR(CSSTransition); -GC::Ref CSSTransition::start_a_transition(DOM::Element& element, Optional pseudo_element, PropertyID property_id, +GC::Ref CSSTransition::start_a_transition(DOM::AbstractElement abstract_element, PropertyID property_id, size_t transition_generation, double delay, double start_time, double end_time, NonnullRefPtr start_value, NonnullRefPtr end_value, NonnullRefPtr reversing_adjusted_start_value, double reversing_shortening_factor) { - auto& realm = element.realm(); - return realm.create(realm, element, pseudo_element, property_id, transition_generation, delay, start_time, end_time, start_value, end_value, reversing_adjusted_start_value, reversing_shortening_factor); + auto& realm = abstract_element.element().realm(); + return realm.create(realm, abstract_element, property_id, transition_generation, delay, start_time, end_time, start_value, end_value, reversing_adjusted_start_value, reversing_shortening_factor); } Animations::AnimationClass CSSTransition::animation_class() const @@ -75,7 +75,7 @@ Optional CSSTransition::class_specific_composite_order(GC::Ref pseudo_element, PropertyID property_id, size_t transition_generation, +CSSTransition::CSSTransition(JS::Realm& realm, DOM::AbstractElement abstract_element, PropertyID property_id, size_t transition_generation, double delay, double start_time, double end_time, NonnullRefPtr start_value, NonnullRefPtr end_value, NonnullRefPtr reversing_adjusted_start_value, double reversing_shortening_factor) : Animations::Animation(realm) @@ -96,12 +96,12 @@ CSSTransition::CSSTransition(JS::Realm& realm, DOM::Element& element, Optional

set_target(&element); - if (pseudo_element.has_value()) - m_keyframe_effect->set_pseudo_element(Selector::PseudoElementSelector { pseudo_element.value() }); + m_keyframe_effect->set_target(&abstract_element.element()); + if (abstract_element.pseudo_element().has_value()) + m_keyframe_effect->set_pseudo_element(Selector::PseudoElementSelector { abstract_element.pseudo_element().value() }); m_keyframe_effect->set_start_delay(delay); m_keyframe_effect->set_iteration_duration(end_time - start_time); - m_keyframe_effect->set_timing_function(element.property_transition_attributes(pseudo_element, property_id)->timing_function); + m_keyframe_effect->set_timing_function(abstract_element.element().property_transition_attributes(abstract_element.pseudo_element(), property_id)->timing_function); auto key_frame_set = adopt_ref(*new Animations::KeyframeEffect::KeyFrameSet); Animations::KeyframeEffect::KeyFrameSet::ResolvedKeyFrame initial_keyframe; @@ -114,10 +114,10 @@ CSSTransition::CSSTransition(JS::Realm& realm, DOM::Element& element, Optional

keyframes_by_key.insert(100 * Animations::KeyframeEffect::AnimationKeyFrameKeyScaleFactor, final_keyframe); m_keyframe_effect->set_key_frame_set(key_frame_set); - set_timeline(element.document().timeline()); - set_owning_element(element); + set_timeline(abstract_element.document().timeline()); + set_owning_element(abstract_element.element()); set_effect(m_keyframe_effect); - element.set_transition(pseudo_element, m_transition_property, *this); + abstract_element.element().set_transition(abstract_element.pseudo_element(), m_transition_property, *this); HTML::TemporaryExecutionContext context(realm); play().release_value_but_fixme_should_propagate_errors(); diff --git a/Libraries/LibWeb/CSS/CSSTransition.h b/Libraries/LibWeb/CSS/CSSTransition.h index bc1ed4b24d3..238bebf741e 100644 --- a/Libraries/LibWeb/CSS/CSSTransition.h +++ b/Libraries/LibWeb/CSS/CSSTransition.h @@ -22,7 +22,7 @@ class CSSTransition : public Animations::Animation { GC_DECLARE_ALLOCATOR(CSSTransition); public: - static GC::Ref start_a_transition(DOM::Element&, Optional, PropertyID, + static GC::Ref start_a_transition(DOM::AbstractElement, PropertyID, size_t transition_generation, double delay, double start_time, double end_time, NonnullRefPtr start_value, NonnullRefPtr end_value, NonnullRefPtr reversing_adjusted_start_value, double reversing_shortening_factor); @@ -52,7 +52,7 @@ public: void set_previous_phase(Phase phase) { m_previous_phase = phase; } private: - CSSTransition(JS::Realm&, DOM::Element&, Optional, PropertyID, size_t transition_generation, + CSSTransition(JS::Realm&, DOM::AbstractElement, PropertyID, size_t transition_generation, double delay, double start_time, double end_time, NonnullRefPtr start_value, NonnullRefPtr end_value, NonnullRefPtr reversing_adjusted_start_value, double reversing_shortening_factor); diff --git a/Libraries/LibWeb/CSS/StyleComputer.cpp b/Libraries/LibWeb/CSS/StyleComputer.cpp index b69f641cfe8..33fe4c055b1 100644 --- a/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -1341,7 +1341,7 @@ void StyleComputer::start_needed_transitions(ComputedProperties const& previous_ auto start_a_transition = [&](auto delay, auto start_time, auto end_time, auto const& start_value, auto const& end_value, auto const& reversing_adjusted_start_value, auto reversing_shortening_factor) { dbgln_if(CSS_TRANSITIONS_DEBUG, "Starting a transition of {} from {} to {}", string_from_property_id(property_id), start_value->to_string(), end_value->to_string()); - auto transition = CSSTransition::start_a_transition(element, pseudo_element, property_id, + auto transition = CSSTransition::start_a_transition(abstract_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(abstract_element, as(*transition->effect()), new_style);