Content-Length: 465871 | pFad | http://github.com/web-platform-tests/wpt/commit/651e64ae18e891b54e7b4d2c744be19ba6cc940c

37 Add basic support for nan / infinity in calc(). · web-platform-tests/wpt@651e64a · GitHub
Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 651e64a

Browse files
emiliomoz-wptsync-bot
authored andcommittedAug 18, 2022
Add basic support for nan / infinity in calc().
Fix some tests to: * Not assume `double` precision. * Account for recent working group resolution with regards to NaN: w3c/csswg-drafts#7067 (comment) Not sure I caught all, but normalizing to 0 was already our existing behavior. This feature needs more work before it can be enabled more generally, so make it nightly-only, for now. Also, it's unclear per spec what the serialization for infinity*1s or so should be. Right now we serialize to <very-big-number>s, which seems reasonable, but some tests (but not others!) expect different behavior. I left those untouched for now. Differential Revision: https://phabricator.services.mozilla.com/D154883 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1682444 gecko-commit: bf0c0ff13cc1586a185bb0d9f39a9bbf6be554c3 gecko-reviewers: boris
1 parent 5fac799 commit 651e64a

File tree

2 files changed

+37
-30
lines changed

2 files changed

+37
-30
lines changed
 

‎css/css-values/animations/calc-interpolation.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,16 @@
3636
<div class="target"></div>
3737
</div>
3838
</template>
39+
<div class="target" id="inf-target"></div>
3940
<script>
41+
const APPROX_INFINITY = (function() {
42+
const target = document.getElementById("inf-target");
43+
target.style.letterSpacing = "calc(1px * infinity)";
44+
const inf = parseFloat(getComputedStyle(target).letterSpacing);
45+
target.remove();
46+
return inf;
47+
}());
4048

41-
const APPROX_INFINITY = 3.35544e+07;
4249
test_interpolation({
4350
property: 'left',
4451
from: '0px',

‎css/css-values/calc-infinity-nan-computed.html

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,46 +12,46 @@
1212
<body>
1313
<div id="target"></div>
1414
<script>
15-
const APPROX_INFINITY = 3.35544e+07;
16-
const APPROX_NEGATIVE_INFINITY = -APPROX_INFINITY;
15+
const REALLY_LARGE = 1e6;
16+
const REALLY_LARGE_NEGATIVE = -REALLY_LARGE;
1717

1818
// For <length>
19-
testComputedValueGreaterOrLowerThan("width", "calc(NaN * 1px)", APPROX_INFINITY);
20-
testComputedValueGreaterOrLowerThan("width", "calc(infinity * 1px)", APPROX_INFINITY);
21-
testComputedValueGreaterOrLowerThan("width", "calc(infinity * 1cm)", APPROX_INFINITY);
22-
testComputedValueGreaterOrLowerThan("width", "calc(NaN * 1rem)", APPROX_INFINITY);
23-
testComputedValueGreaterOrLowerThan("width", "calc(10.135262721212548pc - 199pt / NaN)", APPROX_INFINITY);
19+
test_computed_value("width", "calc(NaN * 1px)", "0px");
20+
testComputedValueGreaterOrLowerThan("width", "calc(infinity * 1px)", REALLY_LARGE);
21+
testComputedValueGreaterOrLowerThan("width", "calc(infinity * 1cm)", REALLY_LARGE);
22+
test_computed_value("width", "calc(NaN * 1rem)", "0px");
23+
test_computed_value("width", "calc(10.135262721212548pc - 199pt / NaN)", "0px");
2424

25-
testComputedValueGreaterOrLowerThan("width", "max(15px, NaN * 1px)", APPROX_INFINITY);
26-
testComputedValueGreaterOrLowerThan("width", "max(NaN * 1px, 15px)", APPROX_INFINITY);
27-
testComputedValueGreaterOrLowerThan("width", "min(15px, NaN * 1px)", APPROX_INFINITY);
28-
testComputedValueGreaterOrLowerThan("width", "min(NaN * 1px, 15px)", APPROX_INFINITY);
25+
test_computed_value("width", "max(15px, NaN * 1px)", "0px");
26+
test_computed_value("width", "max(NaN * 1px, 15px)", "0px");
27+
test_computed_value("width", "min(15px, NaN * 1px)", "0px");
28+
test_computed_value("width", "min(NaN * 1px, 15px)", "0px");
2929

30-
testComputedValueGreaterOrLowerThan("width", "calc(infinity * 1px - infinity * 1%)", APPROX_INFINITY);
31-
testComputedValueGreaterOrLowerThan("width", "calc(infinity * 1px + infinity * 1%)", APPROX_INFINITY);
32-
testComputedValueGreaterOrLowerThan("width", "calc(min(NaN * 1px, infinity * 1px) + max(infinity * 1px, -infinity * 1px))", APPROX_INFINITY);
33-
testComputedValueGreaterOrLowerThan("width", "calc(infinity * 1px - max(infinity * 1%, 0%))", APPROX_INFINITY);
30+
test_computed_value("width", "calc(infinity * 1px - infinity * 1%)", "0px");
31+
test_computed_value("width", "calc(infinity * 1px + infinity * 1%)", "0px");
32+
test_computed_value("width", "calc(min(NaN * 1px, infinity * 1px) + max(infinity * 1px, -infinity * 1px))", "0px");
33+
test_computed_value("width", "calc(infinity * 1px - max(infinity * 1%, 0%))", "0px");
3434

35-
testComputedValueGreaterOrLowerThan("width", "calc(max(infinity * 1px, 10px))", APPROX_INFINITY);
35+
testComputedValueGreaterOrLowerThan("width", "calc(max(infinity * 1px, 10px))", REALLY_LARGE);
3636

37-
testComputedValueGreaterOrLowerThan("margin-left", "calc(-infinity * 1px)", APPROX_NEGATIVE_INFINITY);
38-
testComputedValueGreaterOrLowerThan("margin-left", "calc(min(1px, -infinity * 1%))", APPROX_NEGATIVE_INFINITY);
37+
testComputedValueGreaterOrLowerThan("margin-left", "calc(-infinity * 1px)", REALLY_LARGE_NEGATIVE);
38+
testComputedValueGreaterOrLowerThan("margin-left", "calc(min(1px, -infinity * 1%))", REALLY_LARGE_NEGATIVE);
3939

40-
testComputedValueGreaterOrLowerThan("margin-left", "calc(-infinity * 1%)", APPROX_NEGATIVE_INFINITY);
41-
testComputedValueGreaterOrLowerThan("margin-left", "calc(max(10000px, 0px) + min(-infinity * 1px, infinity * 1px))", APPROX_NEGATIVE_INFINITY);
40+
testComputedValueGreaterOrLowerThan("margin-left", "calc(-infinity * 1%)", REALLY_LARGE_NEGATIVE);
41+
testComputedValueGreaterOrLowerThan("margin-left", "calc(max(10000px, 0px) + min(-infinity * 1px, infinity * 1px))", REALLY_LARGE_NEGATIVE);
4242

43-
testComputedValueGreaterOrLowerThan("margin-left", "calc(-infinity * 1px - infinity * 1px)", APPROX_NEGATIVE_INFINITY);
44-
testComputedValueGreaterOrLowerThan("margin-left", "calc(min(-infinity * 1px, 10px))", APPROX_NEGATIVE_INFINITY);
43+
testComputedValueGreaterOrLowerThan("margin-left", "calc(-infinity * 1px - infinity * 1px)", REALLY_LARGE_NEGATIVE);
44+
testComputedValueGreaterOrLowerThan("margin-left", "calc(min(-infinity * 1px, 10px))", REALLY_LARGE_NEGATIVE);
4545

4646
// For <time>
47-
testComputedValueGreaterOrLowerThan("animation-duration", "calc(NaN * 1s)", APPROX_INFINITY);
48-
testComputedValueGreaterOrLowerThan("animation-duration", "calc(infinity * 1s)", APPROX_INFINITY);
49-
testComputedValueGreaterOrLowerThan("animation-duration", "calc(1 / 0 * 1s)", APPROX_INFINITY);
50-
testComputedValueGreaterOrLowerThan("animation-duration", "calc(max(infinity * 1s, 10s)", APPROX_INFINITY);
47+
test_computed_value("animation-duration", "calc(NaN * 1s)", "0s");
48+
testComputedValueGreaterOrLowerThan("animation-duration", "calc(infinity * 1s)", REALLY_LARGE);
49+
test_computed_value("animation-duration", "calc(1 / 0 * 1s)", "0s");
50+
testComputedValueGreaterOrLowerThan("animation-duration", "calc(max(infinity * 1s, 10s)", REALLY_LARGE);
5151

52-
testComputedValueGreaterOrLowerThan("transition-delay", "calc(-infinity* 1s)", APPROX_NEGATIVE_INFINITY);
53-
testComputedValueGreaterOrLowerThan("transition-delay", "calc(max(10000s, 0s) + min(-infinity * 1s, infinity * 1s))", APPROX_NEGATIVE_INFINITY);
54-
testComputedValueGreaterOrLowerThan("transition-delay", "calc(min(-infinity * 1s, 10s))", APPROX_NEGATIVE_INFINITY);
52+
testComputedValueGreaterOrLowerThan("transition-delay", "calc(-infinity* 1s)", REALLY_LARGE_NEGATIVE);
53+
testComputedValueGreaterOrLowerThan("transition-delay", "calc(max(10000s, 0s) + min(-infinity * 1s, infinity * 1s))", REALLY_LARGE_NEGATIVE);
54+
testComputedValueGreaterOrLowerThan("transition-delay", "calc(min(-infinity * 1s, 10s))", REALLY_LARGE_NEGATIVE);
5555

5656
// For <angle>
5757
testTransformValuesCloseTo("rotate(calc(infinity * 1deg))", 0.0001, "rotate(0deg)");

0 commit comments

Comments
 (0)
Failed to load comments.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/web-platform-tests/wpt/commit/651e64ae18e891b54e7b4d2c744be19ba6cc940c

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy