diff --git a/Libraries/LibWeb/CSS/StyleComputer.cpp b/Libraries/LibWeb/CSS/StyleComputer.cpp index 152db16a978..1adfd73e0ff 100644 --- a/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -2411,7 +2411,7 @@ GC::Ptr StyleComputer::compute_style_impl(DOM::AbstractEleme } } - auto computed_properties = compute_properties(abstract_element.element(), abstract_element.pseudo_element(), cascaded_properties); + auto computed_properties = compute_properties(abstract_element, cascaded_properties); computed_properties->set_attempted_pseudo_class_matches(attempted_pseudo_class_matches); if (did_change_custom_properties.has_value() && abstract_element.custom_properties() != old_custom_properties) { @@ -2499,9 +2499,8 @@ RefPtr StyleComputer::recascade_font_size_if_needed(DOM::Abstr return CSS::LengthStyleValue::create(CSS::Length::make_px(current_size_in_px)); } -GC::Ref StyleComputer::compute_properties(DOM::Element& element, Optional pseudo_element, CascadedProperties& cascaded_properties) const +GC::Ref StyleComputer::compute_properties(DOM::AbstractElement abstract_element, CascadedProperties& cascaded_properties) const { - DOM::AbstractElement abstract_element { element, pseudo_element }; auto computed_style = document().heap().allocate(); auto new_font_size = recascade_font_size_if_needed(abstract_element, cascaded_properties); @@ -2564,6 +2563,10 @@ GC::Ref StyleComputer::compute_properties(DOM::Element& elem return animation_name.to_string(SerializationMode::Normal); }(); + // FIXME: Add some animation helpers to AbstractElement once pseudo-elements are animatable. + auto& element = abstract_element.element(); + auto pseudo_element = abstract_element.pseudo_element(); + if (animation_name.has_value()) { if (auto source_declaration = computed_style->animation_name_source()) { auto& realm = element.realm(); @@ -2626,13 +2629,13 @@ GC::Ref StyleComputer::compute_properties(DOM::Element& elem compute_math_depth(computed_style, abstract_element); // 3. Compute the font, since that may be needed for font-relative CSS units - compute_font(computed_style, DOM::AbstractElement { element, pseudo_element }); + compute_font(computed_style, abstract_element); // 4. Convert properties into their computed forms compute_property_values(computed_style); // 5. Run automatic box type transformations - transform_box_type_if_needed(computed_style, element, pseudo_element); + transform_box_type_if_needed(computed_style, abstract_element.element(), abstract_element.pseudo_element()); // 6. Apply any property-specific computed value logic resolve_effective_overflow_values(computed_style); @@ -2643,9 +2646,9 @@ GC::Ref StyleComputer::compute_properties(DOM::Element& elem // 8. Transition declarations [css-transitions-1] // 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, element, pseudo_element); - if (auto previous_style = element.computed_properties(pseudo_element)) { - start_needed_transitions(*previous_style, computed_style, element, pseudo_element); + 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()); } return computed_style; diff --git a/Libraries/LibWeb/CSS/StyleComputer.h b/Libraries/LibWeb/CSS/StyleComputer.h index 130549cc98c..8d9407f8132 100644 --- a/Libraries/LibWeb/CSS/StyleComputer.h +++ b/Libraries/LibWeb/CSS/StyleComputer.h @@ -189,7 +189,7 @@ public: size_t number_of_css_font_faces_with_loading_in_progress() const; - [[nodiscard]] GC::Ref compute_properties(DOM::Element&, Optional, CascadedProperties&) const; + [[nodiscard]] GC::Ref compute_properties(DOM::AbstractElement, CascadedProperties&) const; void compute_property_values(ComputedProperties&) const; void compute_font(ComputedProperties&, Optional) const;