mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-21 16:58:58 +00:00
LibWeb/CSS: Take AbstractElement in StyleComputer::compute_properties()
As noted, the chunk of this method that deals with animations could do with some helpers on AbstractElement, but I'm leaving that until it's clearer how animations and pseudo-elements should interact.
This commit is contained in:
parent
0293176429
commit
b2ee4a9444
Notes:
github-actions[bot]
2025-09-11 16:48:02 +00:00
Author: https://github.com/AtkinsSJ
Commit: b2ee4a9444
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6118
2 changed files with 12 additions and 9 deletions
|
@ -2411,7 +2411,7 @@ GC::Ptr<ComputedProperties> 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<StyleValue const> StyleComputer::recascade_font_size_if_needed(DOM::Abstr
|
|||
return CSS::LengthStyleValue::create(CSS::Length::make_px(current_size_in_px));
|
||||
}
|
||||
|
||||
GC::Ref<ComputedProperties> StyleComputer::compute_properties(DOM::Element& element, Optional<PseudoElement> pseudo_element, CascadedProperties& cascaded_properties) const
|
||||
GC::Ref<ComputedProperties> StyleComputer::compute_properties(DOM::AbstractElement abstract_element, CascadedProperties& cascaded_properties) const
|
||||
{
|
||||
DOM::AbstractElement abstract_element { element, pseudo_element };
|
||||
auto computed_style = document().heap().allocate<CSS::ComputedProperties>();
|
||||
|
||||
auto new_font_size = recascade_font_size_if_needed(abstract_element, cascaded_properties);
|
||||
|
@ -2564,6 +2563,10 @@ GC::Ref<ComputedProperties> 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<ComputedProperties> 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<ComputedProperties> 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;
|
||||
|
|
|
@ -189,7 +189,7 @@ public:
|
|||
|
||||
size_t number_of_css_font_faces_with_loading_in_progress() const;
|
||||
|
||||
[[nodiscard]] GC::Ref<ComputedProperties> compute_properties(DOM::Element&, Optional<PseudoElement>, CascadedProperties&) const;
|
||||
[[nodiscard]] GC::Ref<ComputedProperties> compute_properties(DOM::AbstractElement, CascadedProperties&) const;
|
||||
|
||||
void compute_property_values(ComputedProperties&) const;
|
||||
void compute_font(ComputedProperties&, Optional<DOM::AbstractElement>) const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue