mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibWeb: Propagate NaN through CSS sign() function
This commit is contained in:
parent
d32f99b16f
commit
43b06cbbdd
Notes:
github-actions[bot]
2025-10-23 08:35:45 +00:00
Author: https://github.com/Calme1709
Commit: 43b06cbbdd
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6544
Reviewed-by: https://github.com/AtkinsSJ ✅
2 changed files with 11 additions and 5 deletions
|
|
@ -1405,6 +1405,13 @@ Optional<CalculatedStyleValue::CalculationResult> SignCalculationNode::run_opera
|
||||||
[](Percentage const& percentage) { return percentage.as_fraction(); },
|
[](Percentage const& percentage) { return percentage.as_fraction(); },
|
||||||
[](auto const& dimension) { return dimension.raw_value(); });
|
[](auto const& dimension) { return dimension.raw_value(); });
|
||||||
|
|
||||||
|
auto return_type = NumericType {}.made_consistent_with(numeric_child.numeric_type().value_or({}));
|
||||||
|
|
||||||
|
// https://drafts.csswg.org/css-values-4/#calc-ieee
|
||||||
|
// Any operation with at least one NaN argument produces NaN.
|
||||||
|
if (isnan(raw_value))
|
||||||
|
return CalculatedStyleValue::CalculationResult { AK::NaN<double>, return_type };
|
||||||
|
|
||||||
double sign = 0;
|
double sign = 0;
|
||||||
if (raw_value < 0) {
|
if (raw_value < 0) {
|
||||||
sign = -1;
|
sign = -1;
|
||||||
|
|
@ -1415,7 +1422,7 @@ Optional<CalculatedStyleValue::CalculationResult> SignCalculationNode::run_opera
|
||||||
sign = extractor.sign ? -0.0 : 0.0;
|
sign = extractor.sign ? -0.0 : 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return CalculatedStyleValue::CalculationResult { sign, NumericType {}.made_consistent_with(numeric_child.numeric_type().value_or({})) };
|
return CalculatedStyleValue::CalculationResult { sign, return_type };
|
||||||
}
|
}
|
||||||
|
|
||||||
void SignCalculationNode::dump(StringBuilder& builder, int indent) const
|
void SignCalculationNode::dump(StringBuilder& builder, int indent) const
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,7 @@ Harness status: OK
|
||||||
|
|
||||||
Found 16 tests
|
Found 16 tests
|
||||||
|
|
||||||
14 Pass
|
16 Pass
|
||||||
2 Fail
|
|
||||||
Pass 'scale(abs(1))' as a specified value should serialize as 'scale(calc(1))'.
|
Pass 'scale(abs(1))' as a specified value should serialize as 'scale(calc(1))'.
|
||||||
Pass 'scale(sign(.1))' as a specified value should serialize as 'scale(calc(1))'.
|
Pass 'scale(sign(.1))' as a specified value should serialize as 'scale(calc(1))'.
|
||||||
Pass 'scale(abs(1 + 2 + 3))' as a specified value should serialize as 'scale(calc(6))'.
|
Pass 'scale(abs(1 + 2 + 3))' as a specified value should serialize as 'scale(calc(6))'.
|
||||||
|
|
@ -18,5 +17,5 @@ Pass 'scale(calc(sign(infinity)))' as a specified value should serialize as 'sca
|
||||||
Pass 'scale(abs(infinity))' as a specified value should serialize as 'scale(calc(infinity))'.
|
Pass 'scale(abs(infinity))' as a specified value should serialize as 'scale(calc(infinity))'.
|
||||||
Pass 'scale(calc(abs(-infinity)))' as a specified value should serialize as 'scale(calc(infinity))'.
|
Pass 'scale(calc(abs(-infinity)))' as a specified value should serialize as 'scale(calc(infinity))'.
|
||||||
Pass 'scale(calc(sign(-1 * infinity)))' as a specified value should serialize as 'scale(calc(-1))'.
|
Pass 'scale(calc(sign(-1 * infinity)))' as a specified value should serialize as 'scale(calc(-1))'.
|
||||||
Fail 'scale(calc(sign(-1 * NaN)))' as a specified value should serialize as 'scale(calc(NaN))'.
|
Pass 'scale(calc(sign(-1 * NaN)))' as a specified value should serialize as 'scale(calc(NaN))'.
|
||||||
Fail 'scale(calc(sign(1 * NaN)))' as a specified value should serialize as 'scale(calc(NaN))'.
|
Pass 'scale(calc(sign(1 * NaN)))' as a specified value should serialize as 'scale(calc(NaN))'.
|
||||||
Loading…
Add table
Add a link
Reference in a new issue