LibWeb: Set up initial infrastructure for non-math functions in calc

There are some non-math functions (such as tree counting functions)
which we should allow within `calc()`s . This commit implements the
initial infrastructure for this.

We don't yet parse any of these non-math functions in
`parse_a_calculation` so there is no functional change.
This commit is contained in:
Callum Law 2025-09-30 16:39:23 +13:00 committed by Tim Ledbetter
commit 55bcdcf824
Notes: github-actions[bot] 2025-10-20 15:13:37 +00:00
5 changed files with 89 additions and 9 deletions

View file

@ -19,6 +19,7 @@
#include <AK/StringConversions.h>
#include <AK/TemporaryChange.h>
#include <LibWeb/CSS/FontFace.h>
#include <LibWeb/CSS/MathFunctions.h>
#include <LibWeb/CSS/Parser/ArbitrarySubstitutionFunctions.h>
#include <LibWeb/CSS/Parser/ErrorReporter.h>
#include <LibWeb/CSS/Parser/Parser.h>
@ -4249,8 +4250,7 @@ RefPtr<CalculationNode const> Parser::convert_to_calculation_node(CalcParsing::N
}
// 2. If leaf is a math function, replace leaf with the internal representation of that math function.
// NOTE: All function tokens at this point should be math functions.
if (component_value->is_function()) {
if (component_value->is_function() && math_function_from_string(component_value->function().name).has_value()) {
auto const& function = component_value->function();
auto leaf_calculation = parse_a_calc_function_node(function, context);
if (!leaf_calculation)