1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 08:28:11 +00:00

LibWeb: Deduplicate calc-parsing code

We had `parse_calculated_value()` which parsed the contents of `calc()`,
and `parse_dynamic_value()` which parsed any math function, both of
which produce a CalculatedStyleValue, but return a plain StyleValue.
This was confusing, so let's combine them together, and return a
CalculatedStyleValue.

This also makes the other math functions work in
`StyleComputer::expand_unresolved_values()`.
This commit is contained in:
Sam Atkins 2023-08-17 14:43:36 +01:00 committed by Andreas Kling
parent 7bc7f376fa
commit 68dae8ab46
3 changed files with 40 additions and 89 deletions

View file

@ -89,7 +89,7 @@ public:
ErrorOr<RefPtr<StyleValue>> parse_as_css_value(PropertyID);
static ErrorOr<RefPtr<StyleValue>> parse_css_value(Badge<StyleComputer>, ParsingContext const&, PropertyID, Vector<ComponentValue> const&);
static ErrorOr<RefPtr<CalculatedStyleValue>> parse_calculated_value(Badge<StyleComputer>, ParsingContext const&, Vector<ComponentValue> const&);
static ErrorOr<RefPtr<CalculatedStyleValue>> parse_calculated_value(Badge<StyleComputer>, ParsingContext const&, ComponentValue const&);
[[nodiscard]] LengthOrCalculated parse_as_sizes_attribute();
@ -284,8 +284,7 @@ private:
};
ErrorOr<PropertyAndValue> parse_css_value_for_properties(ReadonlySpan<PropertyID>, TokenStream<ComponentValue>&);
ErrorOr<RefPtr<StyleValue>> parse_builtin_value(ComponentValue const&);
ErrorOr<RefPtr<StyleValue>> parse_dynamic_value(ComponentValue const&);
ErrorOr<RefPtr<CalculatedStyleValue>> parse_calculated_value(Vector<ComponentValue> const&);
ErrorOr<RefPtr<CalculatedStyleValue>> parse_calculated_value(ComponentValue const&);
// NOTE: Implemented in generated code. (GenerateCSSMathFunctions.cpp)
ErrorOr<OwnPtr<CalculationNode>> parse_math_function(PropertyID, Function const&);
ErrorOr<OwnPtr<CalculationNode>> parse_a_calc_function_node(Function const&);