Closed Bug 1867558 Opened 2 years ago Closed 2 years ago

[css-values] abs(-0) should be +0 instead of -0

Categories

(Core :: CSS Parsing and Computation, defect)

defect

Tracking

()

RESOLVED FIXED
122 Branch
Tracking Status
firefox122 --- fixed

People

(Reporter: Oriol, Assigned: connor.pearson)

References

Details

(Keywords: good-first-bug)

Attachments

(1 file)

This is one of the failures that I detected in https://github.com/web-platform-tests/wpt/pull/43430

<!DOCTYPE html>
<script>
var el = document.documentElement;
el.style.zIndex = "calc(1 / abs(-0))";
el.textContent = getComputedStyle(el).zIndex;
</script>

Expected: a big positive number
Actual: -2147483648

As per https://drafts.csswg.org/css-values/#sign-funcs

The abs(A) function contains one calculation A, and returns the absolute value of A, as the same type as the input: if A’s numeric value is positive or 0⁺, just A again; otherwise -1 * A.

https://searchfox.org/mozilla-central/rev/12ea2c521cdd071a6d25b0894f31f8f23b18b76a/servo/components/style/values/generics/calc.rs#1538

leaf.map(|v| if v.is_zero() { v } else { v.abs() });

Just do the v.abs() unconditionally?

See Also: → 1867565
Summary: abs(-0) should be +0 instead of -0 → [css-values] abs(-0) should be +0 instead of -0
See Also: → 1867569
Assignee: nobody → connor.pearson
Status: NEW → ASSIGNED
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a4cc8a5be7d4 abs(-0) should be +0 instead of -0. r=emilio
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 122 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: