summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-11-02 20:25:50 +0100
committerAndreas Kling <kling@serenityos.org>2022-11-02 22:42:48 +0100
commit8869dec5fd7d776d25d451c54a603af497178821 (patch)
tree3169528d1f458ed3237389f16f5c6aebc983374a /Userland/Libraries
parentf14ad0e8c1016cedaf2df4bfa18171c08eefb650 (diff)
downloadserenity-8869dec5fd7d776d25d451c54a603af497178821.zip
LibWeb: Add CSS::Parser helper for parsing a standalone "calc()" value
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp11
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Parser.h3
2 files changed, 12 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
index cf996e4c59..8d87624c78 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
@@ -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)
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h
index 28f0e6e2ea..d224023bbc 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h
@@ -86,6 +86,7 @@ public:
RefPtr<StyleValue> parse_as_css_value(PropertyID);
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:
enum class ParseError {
@@ -270,7 +271,7 @@ private:
RefPtr<StyleValue> parse_css_value(ComponentValue const&);
RefPtr<StyleValue> parse_builtin_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_numeric_value(ComponentValue const&);
RefPtr<StyleValue> parse_identifier_value(ComponentValue const&);