Closed Bug 2061083 Opened 1 month ago Closed 1 month ago

[css-typed-arithmetic] Fix infinities escaping a calculation when typed arithmetic is involved

Categories

(Core :: CSS Parsing and Computation, defect)

defect

Tracking

()

RESOLVED FIXED
155 Branch
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.

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.

Pushed by sajidanwar94@gmail.com: https://github.com/mozilla-firefox/firefox/commit/9165316d6b72 https://hg.mozilla.org/integration/autoland/rev/f67df042f451 Clamp infinite length-percentage calc expressions. r=firefox-style-system-reviewers,emilio
Severity: -- → S3

Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/61812 for changes under testing/web-platform/tests

Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 155 Branch

Upstream PR merged by moz-wptsync-bot

QA Whiteboard: [qa-triage-done-c156/b155]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: