diff --git a/Libraries/LibWeb/CSS/StyleComputer.cpp b/Libraries/LibWeb/CSS/StyleComputer.cpp index 6d71e0ecca3..0cc94981267 100644 --- a/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -1310,9 +1310,8 @@ static void compute_transitioned_properties(ComputedProperties const& style, DOM } // https://drafts.csswg.org/css-transitions/#starting -void StyleComputer::start_needed_transitions(ComputedProperties const& previous_style, ComputedProperties& new_style, DOM::Element& element, Optional pseudo_element) const +void StyleComputer::start_needed_transitions(ComputedProperties const& previous_style, ComputedProperties& new_style, DOM::AbstractElement abstract_element) const { - // https://drafts.csswg.org/css-transitions/#transition-combined-duration auto combined_duration = [](Animations::Animatable::TransitionAttributes const& transition_attributes) { // Define the combined duration of the transition as the sum of max(matching transition duration, 0s) and the matching transition delay. @@ -1322,6 +1321,10 @@ void StyleComputer::start_needed_transitions(ComputedProperties const& previous_ // For each element and property, the implementation must act as follows: auto style_change_event_time = m_document->timeline()->current_time().value(); + // FIXME: Add some transition helpers to AbstractElement. + auto& element = abstract_element.element(); + auto pseudo_element = abstract_element.pseudo_element(); + for (auto i = to_underlying(CSS::first_longhand_property_id); i <= to_underlying(CSS::last_longhand_property_id); ++i) { auto property_id = static_cast(i); auto matching_transition_properties = element.property_transition_attributes(pseudo_element, property_id); @@ -1338,7 +1341,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(abstract_element, as(*transition->effect()), new_style); }; // 1. If all of the following are true: @@ -2648,7 +2651,7 @@ GC::Ref StyleComputer::compute_properties(DOM::AbstractEleme // Theoretically this should be part of the cascade, but it works with computed values, which we don't have until now. compute_transitioned_properties(computed_style, abstract_element.element(), abstract_element.pseudo_element()); if (auto previous_style = abstract_element.computed_properties()) { - start_needed_transitions(*previous_style, computed_style, abstract_element.element(), abstract_element.pseudo_element()); + start_needed_transitions(*previous_style, computed_style, abstract_element); } return computed_style; diff --git a/Libraries/LibWeb/CSS/StyleComputer.h b/Libraries/LibWeb/CSS/StyleComputer.h index 5e2018e2234..0ed6dda7576 100644 --- a/Libraries/LibWeb/CSS/StyleComputer.h +++ b/Libraries/LibWeb/CSS/StyleComputer.h @@ -237,7 +237,7 @@ private: RefPtr font_matching_algorithm(FlyString const& family_name, int weight, int slope, float font_size_in_pt) const; void compute_custom_properties(ComputedProperties&, DOM::AbstractElement) const; void compute_math_depth(ComputedProperties&, Optional) const; - void start_needed_transitions(ComputedProperties const& old_style, ComputedProperties& new_style, DOM::Element&, Optional) const; + void start_needed_transitions(ComputedProperties const& old_style, ComputedProperties& new_style, DOM::AbstractElement) const; void resolve_effective_overflow_values(ComputedProperties&) const; void transform_box_type_if_needed(ComputedProperties&, DOM::Element const&, Optional) const;