[css-typed-arithmetic] Fix infinities escaping a calculation when typed arithmetic is involved
Categories
(Core :: CSS Parsing and Computation, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox155 | --- | fixed |
People
(Reporter: sajidanwar, Assigned: sajidanwar)
References
Details
Attachments
(1 file)
In the typed arithmetic patch in Bug 1827404, there was a failing case in typed_arithmetic.html related to escaping infinities. From my comment:
One test (
margin-left: calc(1px * 10em / -0em)) which is resolving to a value of -Infinity but which isn't being clamped to a finite value like it should.
| Assignee | ||
Comment 1•1 month ago
|
||
Discovered that this isn't actually the result of typed arithmetic, but rather a longstanding bug where infinity can escape when a length calc expression simplifies to an infinite value at computed-value-time. I downloaded Firefox 131 to be sure that this was present before my other calc changes, and I can reproduce the issue:
document.body.style = 'margin-left: calc(10em / sign(1em - 16px))';
getComputedStyle(document.body).getPropertyValue('margin-left')
// "Infinitypx"
This doesn't happen for something like margin-left: calc(10em / 0), which simplifies to a single length leaf node with an infinite em value. That gets clamped away to a finite value when the em is replaced with the computed font size.
Fix here is to perform the finite clamping here.
| Assignee | ||
Comment 2•1 month ago
|
||
Updated•1 month ago
|
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/61812 for changes under testing/web-platform/tests
Comment 5•1 month ago
|
||
| bugherder | ||
Upstream PR merged by moz-wptsync-bot
Updated•25 days ago
|
Description
•