mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-22 01:08:56 +00:00
LibWeb: Take AbstractElement in resolve_unresolved_style_value()
This commit is contained in:
parent
40ab71e41e
commit
83aee2c7fc
Notes:
github-actions[bot]
2025-09-11 16:49:15 +00:00
Author: https://github.com/AtkinsSJ
Commit: 83aee2c7fc
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6118
4 changed files with 9 additions and 9 deletions
|
@ -65,7 +65,8 @@ void CascadedProperties::resolve_unresolved_properties(GC::Ref<DOM::Element> 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ public:
|
|||
|
||||
Vector<ComponentValue> parse_as_list_of_component_values();
|
||||
|
||||
static NonnullRefPtr<StyleValue const> resolve_unresolved_style_value(ParsingParams const&, DOM::Element&, Optional<PseudoElement>, PropertyIDOrCustomPropertyName, UnresolvedStyleValue const&, Optional<GuardedSubstitutionContexts&> = {});
|
||||
static NonnullRefPtr<StyleValue const> resolve_unresolved_style_value(ParsingParams const&, DOM::AbstractElement, PropertyIDOrCustomPropertyName, UnresolvedStyleValue const&, Optional<GuardedSubstitutionContexts&> = {});
|
||||
|
||||
[[nodiscard]] LengthOrCalculated parse_as_sizes_attribute(DOM::Element const& element, HTML::HTMLImageElement const* img = nullptr);
|
||||
|
||||
|
@ -524,7 +524,7 @@ private:
|
|||
|
||||
OwnPtr<BooleanExpression> parse_supports_feature(TokenStream<ComponentValue>&);
|
||||
|
||||
NonnullRefPtr<StyleValue const> resolve_unresolved_style_value(DOM::AbstractElement&, GuardedSubstitutionContexts&, PropertyIDOrCustomPropertyName, UnresolvedStyleValue const&);
|
||||
NonnullRefPtr<StyleValue const> resolve_unresolved_style_value(DOM::AbstractElement, GuardedSubstitutionContexts&, PropertyIDOrCustomPropertyName, UnresolvedStyleValue const&);
|
||||
|
||||
RefPtr<StyleValue const> parse_according_to_syntax_node(TokenStream<ComponentValue>& tokens, SyntaxNode const& syntax_node, Optional<DOM::AbstractElement> const& element);
|
||||
|
||||
|
|
|
@ -4623,13 +4623,12 @@ RefPtr<FontSourceStyleValue const> Parser::parse_font_source_value(TokenStream<C
|
|||
return FontSourceStyleValue::create(url.release_value(), move(format), move(tech));
|
||||
}
|
||||
|
||||
NonnullRefPtr<StyleValue const> Parser::resolve_unresolved_style_value(ParsingParams const& context, DOM::Element& element, Optional<PseudoElement> pseudo_element, PropertyIDOrCustomPropertyName property, UnresolvedStyleValue const& unresolved, Optional<GuardedSubstitutionContexts&> existing_guarded_contexts)
|
||||
NonnullRefPtr<StyleValue const> Parser::resolve_unresolved_style_value(ParsingParams const& context, DOM::AbstractElement abstract_element, PropertyIDOrCustomPropertyName property, UnresolvedStyleValue const& unresolved, Optional<GuardedSubstitutionContexts&> 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<StyleValue const> Parser::resolve_unresolved_style_value(ParsingPa
|
|||
}
|
||||
|
||||
// https://drafts.csswg.org/css-values-5/#property-replacement
|
||||
NonnullRefPtr<StyleValue const> Parser::resolve_unresolved_style_value(DOM::AbstractElement& element, GuardedSubstitutionContexts& guarded_contexts, PropertyIDOrCustomPropertyName property, UnresolvedStyleValue const& unresolved)
|
||||
NonnullRefPtr<StyleValue const> 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())
|
||||
|
|
|
@ -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, Optional<CSS::
|
|||
continue;
|
||||
|
||||
if (style_value->is_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<StyleValue const> 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue