1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 16:18:12 +00:00

LibWeb: Add CSS::Parser helper for parsing a standalone "calc()" value

This commit is contained in:
Andreas Kling 2022-11-02 20:25:50 +01:00
parent f14ad0e8c1
commit 8869dec5fd
2 changed files with 12 additions and 2 deletions

View file

@ -3038,7 +3038,7 @@ RefPtr<StyleValue> Parser::parse_builtin_value(ComponentValue const& component_v
return {};
}
RefPtr<StyleValue> Parser::parse_calculated_value(Vector<ComponentValue> const& component_values)
RefPtr<CalculatedStyleValue> Parser::parse_calculated_value(Vector<ComponentValue> const& component_values)
{
auto calc_expression = parse_calc_expression(component_values);
if (calc_expression == nullptr)
@ -6960,6 +6960,15 @@ bool Parser::is_builtin(StringView name)
|| name.equals_ignoring_case("unset"sv);
}
RefPtr<CalculatedStyleValue> Parser::parse_calculated_value(Badge<StyleComputer>, ParsingContext const& context, Vector<ComponentValue> const& tokens)
{
if (tokens.is_empty())
return {};
Parser parser(context, ""sv);
return parser.parse_calculated_value(tokens);
}
RefPtr<StyleValue> Parser::parse_css_value(Badge<StyleComputer>, ParsingContext const& context, PropertyID property_id, Vector<ComponentValue> const& tokens)
{
if (tokens.is_empty() || property_id == CSS::PropertyID::Invalid || property_id == CSS::PropertyID::Custom)