LibWeb: Take AbstractElement in start_a_transition()

This commit is contained in:
Sam Atkins 2025-09-09 15:08:29 +01:00 committed by Alexander Kalenik
commit 524a161a51
Notes: github-actions[bot] 2025-09-11 16:46:43 +00:00
3 changed files with 14 additions and 14 deletions

View file

@ -19,12 +19,12 @@ namespace Web::CSS {
GC_DEFINE_ALLOCATOR(CSSTransition); GC_DEFINE_ALLOCATOR(CSSTransition);
GC::Ref<CSSTransition> CSSTransition::start_a_transition(DOM::Element& element, Optional<PseudoElement> pseudo_element, PropertyID property_id, GC::Ref<CSSTransition> CSSTransition::start_a_transition(DOM::AbstractElement abstract_element, PropertyID property_id,
size_t transition_generation, double delay, double start_time, double end_time, NonnullRefPtr<StyleValue const> start_value, size_t transition_generation, double delay, double start_time, double end_time, NonnullRefPtr<StyleValue const> start_value,
NonnullRefPtr<StyleValue const> end_value, NonnullRefPtr<StyleValue const> reversing_adjusted_start_value, double reversing_shortening_factor) NonnullRefPtr<StyleValue const> end_value, NonnullRefPtr<StyleValue const> reversing_adjusted_start_value, double reversing_shortening_factor)
{ {
auto& realm = element.realm(); auto& realm = abstract_element.element().realm();
return realm.create<CSSTransition>(realm, element, pseudo_element, property_id, transition_generation, delay, start_time, end_time, start_value, end_value, reversing_adjusted_start_value, reversing_shortening_factor); return realm.create<CSSTransition>(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 Animations::AnimationClass CSSTransition::animation_class() const
@ -75,7 +75,7 @@ Optional<int> CSSTransition::class_specific_composite_order(GC::Ref<Animations::
return {}; return {};
} }
CSSTransition::CSSTransition(JS::Realm& realm, DOM::Element& element, Optional<PseudoElement> 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<StyleValue const> start_value, NonnullRefPtr<StyleValue const> end_value, double delay, double start_time, double end_time, NonnullRefPtr<StyleValue const> start_value, NonnullRefPtr<StyleValue const> end_value,
NonnullRefPtr<StyleValue const> reversing_adjusted_start_value, double reversing_shortening_factor) NonnullRefPtr<StyleValue const> reversing_adjusted_start_value, double reversing_shortening_factor)
: Animations::Animation(realm) : Animations::Animation(realm)
@ -96,12 +96,12 @@ CSSTransition::CSSTransition(JS::Realm& realm, DOM::Element& element, Optional<P
// that have been disassociated from their owning element but are still idle do not have a defined composite order. // that have been disassociated from their owning element but are still idle do not have a defined composite order.
// Construct a KeyframesEffect for our animation // Construct a KeyframesEffect for our animation
m_keyframe_effect->set_target(&element); m_keyframe_effect->set_target(&abstract_element.element());
if (pseudo_element.has_value()) if (abstract_element.pseudo_element().has_value())
m_keyframe_effect->set_pseudo_element(Selector::PseudoElementSelector { pseudo_element.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_start_delay(delay);
m_keyframe_effect->set_iteration_duration(end_time - start_time); 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); auto key_frame_set = adopt_ref(*new Animations::KeyframeEffect::KeyFrameSet);
Animations::KeyframeEffect::KeyFrameSet::ResolvedKeyFrame initial_keyframe; Animations::KeyframeEffect::KeyFrameSet::ResolvedKeyFrame initial_keyframe;
@ -114,10 +114,10 @@ CSSTransition::CSSTransition(JS::Realm& realm, DOM::Element& element, Optional<P
key_frame_set->keyframes_by_key.insert(100 * Animations::KeyframeEffect::AnimationKeyFrameKeyScaleFactor, final_keyframe); key_frame_set->keyframes_by_key.insert(100 * Animations::KeyframeEffect::AnimationKeyFrameKeyScaleFactor, final_keyframe);
m_keyframe_effect->set_key_frame_set(key_frame_set); m_keyframe_effect->set_key_frame_set(key_frame_set);
set_timeline(element.document().timeline()); set_timeline(abstract_element.document().timeline());
set_owning_element(element); set_owning_element(abstract_element.element());
set_effect(m_keyframe_effect); 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); HTML::TemporaryExecutionContext context(realm);
play().release_value_but_fixme_should_propagate_errors(); play().release_value_but_fixme_should_propagate_errors();

View file

@ -22,7 +22,7 @@ class CSSTransition : public Animations::Animation {
GC_DECLARE_ALLOCATOR(CSSTransition); GC_DECLARE_ALLOCATOR(CSSTransition);
public: public:
static GC::Ref<CSSTransition> start_a_transition(DOM::Element&, Optional<PseudoElement>, PropertyID, static GC::Ref<CSSTransition> start_a_transition(DOM::AbstractElement, PropertyID,
size_t transition_generation, double delay, double start_time, double end_time, NonnullRefPtr<StyleValue const> start_value, size_t transition_generation, double delay, double start_time, double end_time, NonnullRefPtr<StyleValue const> start_value,
NonnullRefPtr<StyleValue const> end_value, NonnullRefPtr<StyleValue const> reversing_adjusted_start_value, double reversing_shortening_factor); NonnullRefPtr<StyleValue const> end_value, NonnullRefPtr<StyleValue const> reversing_adjusted_start_value, double reversing_shortening_factor);
@ -52,7 +52,7 @@ public:
void set_previous_phase(Phase phase) { m_previous_phase = phase; } void set_previous_phase(Phase phase) { m_previous_phase = phase; }
private: private:
CSSTransition(JS::Realm&, DOM::Element&, Optional<PseudoElement>, PropertyID, size_t transition_generation, CSSTransition(JS::Realm&, DOM::AbstractElement, PropertyID, size_t transition_generation,
double delay, double start_time, double end_time, NonnullRefPtr<StyleValue const> start_value, NonnullRefPtr<StyleValue const> end_value, double delay, double start_time, double end_time, NonnullRefPtr<StyleValue const> start_value, NonnullRefPtr<StyleValue const> end_value,
NonnullRefPtr<StyleValue const> reversing_adjusted_start_value, double reversing_shortening_factor); NonnullRefPtr<StyleValue const> reversing_adjusted_start_value, double reversing_shortening_factor);

View file

@ -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) { 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()); 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); 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. // Immediately set the property's value to the transition's current value, to prevent single-frame jumps.
collect_animation_into(abstract_element, as<Animations::KeyframeEffect>(*transition->effect()), new_style); collect_animation_into(abstract_element, as<Animations::KeyframeEffect>(*transition->effect()), new_style);