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

@ -5,6 +5,7 @@
*/
#include "TreeCountingFunctionStyleValue.h"
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
#include <LibWeb/CSS/StyleValues/IntegerStyleValue.h>
#include <LibWeb/CSS/StyleValues/NumberStyleValue.h>
@ -34,6 +35,14 @@ size_t TreeCountingFunctionStyleValue::resolve(TreeCountingFunctionResolutionCon
VERIFY_NOT_REACHED();
}
RefPtr<CalculationNode const> TreeCountingFunctionStyleValue::resolve_to_calculation_node(CalculationContext const& calculation_context, CalculationResolutionContext const& calculation_resolution_context) const
{
if (!calculation_resolution_context.tree_counting_function_resolution_context.has_value())
return nullptr;
return NumericCalculationNode::create(Number { Number::Type::Number, static_cast<double>(resolve(calculation_resolution_context.tree_counting_function_resolution_context.value())) }, calculation_context);
}
ValueComparingNonnullRefPtr<StyleValue const> TreeCountingFunctionStyleValue::absolutized(ComputationContext const& computation_context) const
{
// FIXME: We should clamp this value in case it falls outside the valid range for the context it is in