mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb: Simplify standalone CSS math functions when used outside calc()
Math functions like abs(), clamp(), round(), etc, can be used by themselves in property values, without wrapping them in calc(). Before this change, we were neglecting to run calc simplification on the generated calculation node trees. By doing that manually after parsing a standalone math function, we score at least a couple hundred WPT points.
This commit is contained in:
committed by
Andreas Kling
parent
94ae63c436
commit
0553bcb35b
Notes:
github-actions[bot]
2025-04-24 18:38:57 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/0553bcb35b3 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4458
@@ -3515,8 +3515,11 @@ RefPtr<CalculationNode const> Parser::parse_a_calc_function_node(Function const&
|
||||
if (function.name.equals_ignoring_ascii_case("calc"sv))
|
||||
return parse_a_calculation(function.value, context);
|
||||
|
||||
if (auto maybe_function = parse_math_function(function, context))
|
||||
return maybe_function;
|
||||
if (auto maybe_function = parse_math_function(function, context)) {
|
||||
// NOTE: We have to simplify manually here, since parse_math_function() is a helper for calc() parsing
|
||||
// that doesn't do it directly by itself.
|
||||
return simplify_a_calculation_tree(*maybe_function, context, CalculationResolutionContext {});
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user