LibWeb: Support tree counting functions within calc()

This commit is contained in:
Callum Law 2025-10-01 21:32:14 +13:00 committed by Tim Ledbetter
commit e9036c7c75
Notes: github-actions[bot] 2025-10-20 15:13:31 +00:00
15 changed files with 62 additions and 44 deletions

View file

@ -4314,6 +4314,10 @@ RefPtr<CalculationNode const> Parser::convert_to_calculation_node(CalcParsing::N
if (component_value->is(Token::Type::Percentage))
return NumericCalculationNode::create(Percentage { component_value->token().percentage() }, context);
auto tree_counting_function_tokens = TokenStream<ComponentValue>::of_single_token(component_value);
if (auto tree_counting_function = parse_tree_counting_function(tree_counting_function_tokens, TreeCountingFunctionStyleValue::ComputedType::Number))
return NonMathFunctionCalculationNode::create(tree_counting_function.release_nonnull(), NumericType {});
// NOTE: If we get here, then we have a ComponentValue that didn't get replaced with something else,
// so the calc() is invalid.
ErrorReporter::the().report(InvalidValueError {