forked from sailfishos/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1834164 - Serialize NaN and infinity numbers r=emilio
Added NaN/inf serialization of <number> and changed calc() code to not remove NaN/infinity in code using it. This change is unfortunately imperfect as some things using <number> still refuse to serialize NaN/infinity for some reason (scale()?), but this bug/patch is just for <number> so leaving that out of scope for this. Also added new WPT test file for number NaN/inf serialization based on existing serialization tests (all pass already!). 5 other WPT subtests now newly pass. Differential Revision: https://phabricator.services.mozilla.com/D178587
- Loading branch information
1 parent
71f8946
commit c0c95c1
Showing
6 changed files
with
87 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
testing/web-platform/tests/css/css-values/calc-infinity-nan-serialize-number.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<!DOCTYPE HTML> | ||
<title>Infinity and NaN: calc() serialization for number values.</title> | ||
<link rel="help" href="https://drafts.csswg.org/css-values/#calc-type-checking"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="../support/serialize-testcommon.js"></script> | ||
<div id="target"></div> | ||
<div id="log"></div> | ||
<script> | ||
function test_serialization(t,s, {prop="opacity"}={}) { | ||
test_specified_serialization(prop, t, s) | ||
} | ||
//TEST CASE | EXPECTED | ||
var test_map = { | ||
"NaN" :"calc(NaN)", | ||
"infinity" :"calc(infinity)", | ||
"-infinity" :"calc(-infinity)", | ||
"1 * NaN" :"calc(NaN)", | ||
"1 * nan" :"calc(NaN)", | ||
"1 * infinity / infinity" :"calc(NaN)", | ||
"1 * 0 * infinity" :"calc(NaN)", | ||
"1 * (infinity + -infinity)" :"calc(NaN)", | ||
"1 * (-infinity + infinity)" :"calc(NaN)", | ||
"1 * (infinity - infinity)" :"calc(NaN)", | ||
"1 * infinity" :"calc(infinity)", | ||
"1 * -infinity" :"calc(-infinity)", | ||
"1 * iNFinIty" :"calc(infinity)", | ||
"1 * (infinity + infinity)" :"calc(infinity)", | ||
"1 * (-infinity + -infinity)" :"calc(-infinity)", | ||
"1 * 1/infinity" :"calc(0)", | ||
"1 * infinity * infinity" :"calc(infinity)", | ||
"1 * -infinity * -infinity" :"calc(infinity)", | ||
"1 * max(INFinity*3, 0)" :"calc(infinity)", | ||
"1 * min(inFInity*4, 0)" :"calc(0)", | ||
"1 * max(nAn*2, 0)" :"calc(NaN)", | ||
"1 * min(nan*3, 0)" :"calc(NaN)", | ||
"1 * clamp(-INFINITY*20, 0, infiniTY*10)" :"calc(0)", | ||
|
||
"1 * max(NaN, min(0,10))" :"calc(NaN)", | ||
"1 * clamp(NaN, 0, 10)" :"calc(NaN)", | ||
|
||
"1 * max(0, min(10, NaN))" :"calc(NaN)", | ||
"1 * clamp(0, 10, NaN)" :"calc(NaN)", | ||
|
||
"1 * max(0, min(NaN, 10))" :"calc(NaN)", | ||
"1 * clamp(0, NaN, 10)" :"calc(NaN)", | ||
|
||
"1 * clamp(-Infinity, 0, infinity)" :"calc(0)", | ||
"1 * clamp(-inFinity, infinity, 10)" :"calc(10)", | ||
}; | ||
|
||
for (var exp in test_map) { | ||
test_serialization("calc("+exp+")", test_map[exp]); | ||
} | ||
</script> |