mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-16 13:09:41 +00:00
LibWeb/CSS: Use PropertyNameAndID instead of old Variant
This commit is contained in:
parent
3af8e705c1
commit
c0ef7f09e4
Notes:
github-actions[bot]
2025-10-02 12:48:44 +00:00
Author: https://github.com/AtkinsSJ
Commit: c0ef7f09e4
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6310
5 changed files with 14 additions and 20 deletions
|
@ -22,6 +22,7 @@
|
|||
#include <LibWeb/CSS/Parser/ArbitrarySubstitutionFunctions.h>
|
||||
#include <LibWeb/CSS/Parser/ErrorReporter.h>
|
||||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/CSS/PropertyNameAndID.h>
|
||||
#include <LibWeb/CSS/StyleValues/AnchorSizeStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/AnchorStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/AngleStyleValue.h>
|
||||
|
@ -4625,7 +4626,7 @@ 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::AbstractElement abstract_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, PropertyNameAndID const& 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.
|
||||
|
@ -4639,7 +4640,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, PropertyNameAndID const& property, UnresolvedStyleValue const& unresolved)
|
||||
{
|
||||
// AD-HOC: Report that we might rely on custom properties.
|
||||
if (unresolved.includes_attr_function())
|
||||
|
@ -4648,16 +4649,10 @@ NonnullRefPtr<StyleValue const> Parser::resolve_unresolved_style_value(DOM::Abst
|
|||
element.element().set_style_uses_var_css_function();
|
||||
|
||||
// To replace substitution functions in a property prop:
|
||||
auto const& property_name = property.visit(
|
||||
[](PropertyID const& property_id) { return string_from_property_id(property_id); },
|
||||
[](FlyString const& name) { return name; });
|
||||
auto const& property_id = property.visit(
|
||||
[](PropertyID const& property_id) { return property_id; },
|
||||
[](FlyString const&) { return PropertyID::Custom; });
|
||||
|
||||
// 1. Substitute arbitrary substitution functions in prop’s value, given «"property", prop’s name» as the
|
||||
// substitution context. Let result be the returned component value sequence.
|
||||
auto result = substitute_arbitrary_substitution_functions(element, guarded_contexts, unresolved.values(), SubstitutionContext { SubstitutionContext::DependencyType::Property, property_name.to_string() });
|
||||
auto result = substitute_arbitrary_substitution_functions(element, guarded_contexts, unresolved.values(), SubstitutionContext { SubstitutionContext::DependencyType::Property, property.name().to_string() });
|
||||
|
||||
// 2. If result contains the guaranteed-invalid value, prop is invalid at computed-value time; return.
|
||||
if (contains_guaranteed_invalid_value(result))
|
||||
|
@ -4666,11 +4661,11 @@ NonnullRefPtr<StyleValue const> Parser::resolve_unresolved_style_value(DOM::Abst
|
|||
// 3. Parse result according to prop’s grammar. If this returns failure, prop is invalid at computed-value time; return.
|
||||
// NB: Custom properties have no grammar as such, so we skip this step for them.
|
||||
// FIXME: Parse according to @property syntax once we support that.
|
||||
if (property_id == PropertyID::Custom)
|
||||
if (property.is_custom_property())
|
||||
return UnresolvedStyleValue::create(move(result));
|
||||
|
||||
auto expanded_value_tokens = TokenStream { result };
|
||||
auto parsed_value = parse_css_value(property_id, expanded_value_tokens);
|
||||
auto parsed_value = parse_css_value(property.id(), expanded_value_tokens);
|
||||
if (parsed_value.is_error())
|
||||
return GuaranteedInvalidStyleValue::create();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue