LibWeb: Propagate NaN in CSS clamp function

Gains us 10 WPT tests.
This commit is contained in:
Callum Law 2025-08-05 22:14:23 +12:00 committed by Sam Atkins
parent 4ba54a7a1c
commit e260ba54e0
Notes: github-actions[bot] 2025-08-08 10:45:00 +00:00
6 changed files with 21 additions and 20 deletions

View file

@ -1269,6 +1269,11 @@ Optional<CalculatedStyleValue::CalculationResult> ClampCalculationNode::run_oper
if (!consistent_type.has_value())
return {};
// https://drafts.csswg.org/css-values-4/#calc-ieee
// Any operation with at least one NaN argument produces NaN.
if (isnan(min_result->value()) || isnan(center_result->value()) || isnan(max_result->value()))
return CalculatedStyleValue::CalculationResult { AK::NaN<double>, consistent_type.release_value() };
auto chosen_value = max(min_result->value(), min(center_result->value(), max_result->value()));
return CalculatedStyleValue::CalculationResult { chosen_value, consistent_type.release_value() };
}