mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:47:44 +00:00
LibWeb: Add CSS::Parser helper for parsing a standalone "calc()" value
This commit is contained in:
parent
f14ad0e8c1
commit
8869dec5fd
2 changed files with 12 additions and 2 deletions
|
@ -3038,7 +3038,7 @@ RefPtr<StyleValue> Parser::parse_builtin_value(ComponentValue const& component_v
|
||||||
return {};
|
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);
|
auto calc_expression = parse_calc_expression(component_values);
|
||||||
if (calc_expression == nullptr)
|
if (calc_expression == nullptr)
|
||||||
|
@ -6960,6 +6960,15 @@ bool Parser::is_builtin(StringView name)
|
||||||
|| name.equals_ignoring_case("unset"sv);
|
|| 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)
|
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)
|
if (tokens.is_empty() || property_id == CSS::PropertyID::Invalid || property_id == CSS::PropertyID::Custom)
|
||||||
|
|
|
@ -86,6 +86,7 @@ public:
|
||||||
RefPtr<StyleValue> parse_as_css_value(PropertyID);
|
RefPtr<StyleValue> parse_as_css_value(PropertyID);
|
||||||
|
|
||||||
static RefPtr<StyleValue> parse_css_value(Badge<StyleComputer>, ParsingContext const&, PropertyID, Vector<ComponentValue> const&);
|
static RefPtr<StyleValue> parse_css_value(Badge<StyleComputer>, ParsingContext const&, PropertyID, Vector<ComponentValue> const&);
|
||||||
|
static RefPtr<CalculatedStyleValue> parse_calculated_value(Badge<StyleComputer>, ParsingContext const&, Vector<ComponentValue> const&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class ParseError {
|
enum class ParseError {
|
||||||
|
@ -270,7 +271,7 @@ private:
|
||||||
RefPtr<StyleValue> parse_css_value(ComponentValue const&);
|
RefPtr<StyleValue> parse_css_value(ComponentValue const&);
|
||||||
RefPtr<StyleValue> parse_builtin_value(ComponentValue const&);
|
RefPtr<StyleValue> parse_builtin_value(ComponentValue const&);
|
||||||
RefPtr<StyleValue> parse_dynamic_value(ComponentValue const&);
|
RefPtr<StyleValue> parse_dynamic_value(ComponentValue const&);
|
||||||
RefPtr<StyleValue> parse_calculated_value(Vector<ComponentValue> const&);
|
RefPtr<CalculatedStyleValue> parse_calculated_value(Vector<ComponentValue> const&);
|
||||||
RefPtr<StyleValue> parse_dimension_value(ComponentValue const&);
|
RefPtr<StyleValue> parse_dimension_value(ComponentValue const&);
|
||||||
RefPtr<StyleValue> parse_numeric_value(ComponentValue const&);
|
RefPtr<StyleValue> parse_numeric_value(ComponentValue const&);
|
||||||
RefPtr<StyleValue> parse_identifier_value(ComponentValue const&);
|
RefPtr<StyleValue> parse_identifier_value(ComponentValue const&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue