From 83aee2c7fc26f8eb0c9fbccb06526df5f79abba5 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Fri, 5 Sep 2025 13:55:58 +0100 Subject: [PATCH] LibWeb: Take AbstractElement in resolve_unresolved_style_value() --- Libraries/LibWeb/CSS/CascadedProperties.cpp | 3 ++- Libraries/LibWeb/CSS/Parser/Parser.h | 4 ++-- Libraries/LibWeb/CSS/Parser/ValueParsing.cpp | 5 ++--- Libraries/LibWeb/CSS/StyleComputer.cpp | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Libraries/LibWeb/CSS/CascadedProperties.cpp b/Libraries/LibWeb/CSS/CascadedProperties.cpp index 79a26233e8e..21150c05247 100644 --- a/Libraries/LibWeb/CSS/CascadedProperties.cpp +++ b/Libraries/LibWeb/CSS/CascadedProperties.cpp @@ -65,7 +65,8 @@ void CascadedProperties::resolve_unresolved_properties(GC::Ref ele for (auto& entry : entries) { if (!entry.property.value->is_unresolved()) continue; - entry.property.value = Parser::Parser::resolve_unresolved_style_value(Parser::ParsingParams { element->document() }, element, pseudo_element, property_id, entry.property.value->as_unresolved()); + DOM::AbstractElement abstract_element { element, pseudo_element }; + entry.property.value = Parser::Parser::resolve_unresolved_style_value(Parser::ParsingParams { element->document() }, abstract_element, property_id, entry.property.value->as_unresolved()); } } } diff --git a/Libraries/LibWeb/CSS/Parser/Parser.h b/Libraries/LibWeb/CSS/Parser/Parser.h index 5541f8d71b2..822c12c915c 100644 --- a/Libraries/LibWeb/CSS/Parser/Parser.h +++ b/Libraries/LibWeb/CSS/Parser/Parser.h @@ -134,7 +134,7 @@ public: Vector parse_as_list_of_component_values(); - static NonnullRefPtr resolve_unresolved_style_value(ParsingParams const&, DOM::Element&, Optional, PropertyIDOrCustomPropertyName, UnresolvedStyleValue const&, Optional = {}); + static NonnullRefPtr resolve_unresolved_style_value(ParsingParams const&, DOM::AbstractElement, PropertyIDOrCustomPropertyName, UnresolvedStyleValue const&, Optional = {}); [[nodiscard]] LengthOrCalculated parse_as_sizes_attribute(DOM::Element const& element, HTML::HTMLImageElement const* img = nullptr); @@ -524,7 +524,7 @@ private: OwnPtr parse_supports_feature(TokenStream&); - NonnullRefPtr resolve_unresolved_style_value(DOM::AbstractElement&, GuardedSubstitutionContexts&, PropertyIDOrCustomPropertyName, UnresolvedStyleValue const&); + NonnullRefPtr resolve_unresolved_style_value(DOM::AbstractElement, GuardedSubstitutionContexts&, PropertyIDOrCustomPropertyName, UnresolvedStyleValue const&); RefPtr parse_according_to_syntax_node(TokenStream& tokens, SyntaxNode const& syntax_node, Optional const& element); diff --git a/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp b/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp index 1d5f90591e2..a1fcfbbf296 100644 --- a/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp +++ b/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp @@ -4623,13 +4623,12 @@ RefPtr Parser::parse_font_source_value(TokenStream Parser::resolve_unresolved_style_value(ParsingParams const& context, DOM::Element& element, Optional pseudo_element, PropertyIDOrCustomPropertyName property, UnresolvedStyleValue const& unresolved, Optional existing_guarded_contexts) +NonnullRefPtr Parser::resolve_unresolved_style_value(ParsingParams const& context, DOM::AbstractElement abstract_element, PropertyIDOrCustomPropertyName property, UnresolvedStyleValue const& unresolved, Optional existing_guarded_contexts) { // Unresolved always contains a var() or attr(), unless it is a custom property's value, in which case we shouldn't be trying // to produce a different StyleValue from it. VERIFY(unresolved.contains_arbitrary_substitution_function()); - DOM::AbstractElement abstract_element { element, pseudo_element }; auto parser = Parser::create(context, ""sv); if (existing_guarded_contexts.has_value()) return parser.resolve_unresolved_style_value(abstract_element, existing_guarded_contexts.value(), property, unresolved); @@ -4638,7 +4637,7 @@ NonnullRefPtr Parser::resolve_unresolved_style_value(ParsingPa } // https://drafts.csswg.org/css-values-5/#property-replacement -NonnullRefPtr Parser::resolve_unresolved_style_value(DOM::AbstractElement& element, GuardedSubstitutionContexts& guarded_contexts, PropertyIDOrCustomPropertyName property, UnresolvedStyleValue const& unresolved) +NonnullRefPtr Parser::resolve_unresolved_style_value(DOM::AbstractElement element, GuardedSubstitutionContexts& guarded_contexts, PropertyIDOrCustomPropertyName property, UnresolvedStyleValue const& unresolved) { // AD-HOC: Report that we might rely on custom properties. if (unresolved.includes_attr_function()) diff --git a/Libraries/LibWeb/CSS/StyleComputer.cpp b/Libraries/LibWeb/CSS/StyleComputer.cpp index 40d6b461e00..44345604ed6 100644 --- a/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -789,7 +789,7 @@ void StyleComputer::cascade_declarations( auto property_value = property.value; if (property_value->is_unresolved()) - property_value = Parser::Parser::resolve_unresolved_style_value(Parser::ParsingParams { element.document() }, element, pseudo_element, property.property_id, property_value->as_unresolved()); + property_value = Parser::Parser::resolve_unresolved_style_value(Parser::ParsingParams { element.document() }, DOM::AbstractElement { element, pseudo_element }, property.property_id, property_value->as_unresolved()); if (property_value->is_guaranteed_invalid()) { // https://drafts.csswg.org/css-values-5/#invalid-at-computed-value-time @@ -1007,7 +1007,7 @@ void StyleComputer::collect_animation_into(DOM::Element& element, Optionalis_unresolved()) - style_value = Parser::Parser::resolve_unresolved_style_value(Parser::ParsingParams { element.document() }, element, pseudo_element, property_id, style_value->as_unresolved()); + style_value = Parser::Parser::resolve_unresolved_style_value(Parser::ParsingParams { element.document() }, { element, pseudo_element }, property_id, style_value->as_unresolved()); for_each_property_expanding_shorthands(property_id, *style_value, [&](PropertyID longhand_id, StyleValue const& longhand_value) { auto physical_longhand_id = map_logical_alias_to_physical_property(longhand_id, LogicalAliasMappingContext { computed_properties.writing_mode(), computed_properties.direction() }); @@ -3067,7 +3067,7 @@ NonnullRefPtr StyleComputer::compute_value_of_custom_property( return value.release_nonnull(); auto& unresolved = value->as_unresolved(); - return Parser::Parser::resolve_unresolved_style_value(Parser::ParsingParams {}, abstract_element.element(), abstract_element.pseudo_element(), name, unresolved, guarded_contexts); + return Parser::Parser::resolve_unresolved_style_value(Parser::ParsingParams {}, abstract_element, name, unresolved, guarded_contexts); } void StyleComputer::compute_custom_properties(ComputedProperties&, DOM::AbstractElement abstract_element) const