Closed Bug 1524319 Opened 5 years ago Closed 5 years ago

Alpha values in #RRGGBBAA format can lose accuracy

Categories

(DevTools :: Inspector: Rules, defect, P2)

defect

Tracking

(firefox67 fixed)

RESOLVED FIXED
Firefox 67
Tracking Status
firefox67 --- fixed

People

(Reporter: mgol, Assigned: miker)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Bug 1271191 added support for the #RRGGBBAA hexadecimal with alpha color format:
https://drafts.csswg.org/css-color/#hex-notation

However, when set via DevTools CSS Rules pane, the value is converted in a lossy way, losing the opacity precision.

To reproduce:

  1. Open DevTools.
  2. Focus some element.
  3. In the CSS Rules pane, add a new property: color: #fefefef0.
  4. Notice the browser changes it to color: #fefefee6.

The weird thing is this looks only as a representation problem - CSSOM APIs return the correct value:

document.body.style.color; // "rgba(254, 254, 254, 0.94)"

If you set the Firefox-modified value via CSSOM, you can see it's different:

document.body.style.color = '#fefefee6';
document.body.style.color; // "rgba(254, 254, 254, 0.90)"

Adding to the above STR:

You must first set the default color unit to "Hex" in settings.

Assignee: nobody → mratcliffe
Status: NEW → ASSIGNED
Has STR: --- → yes
OS: macOS → All
Priority: -- → P2
Hardware: Desktop → All
Summary: Colors in the #RRGGBBAA hexadecimal with alpha format are not preserved → Alpha values in #RRGGBBAA format can lose accuracy

(In reply to Mike Ratcliffe [:miker] [:mratcliffe] [:mikeratcliffe] from comment #1)

Adding to the above STR:

You must first set the default color unit to "Hex" in settings.

You don't have to, it also works with the default "As authored". If you changed that to a non-hex format then yes, my STR won't work.

Pushed by mratcliffe@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/2a4f6bb7524a
Alpha values in #RRGGBBAA format can lose accuracy r=nchevobbe
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 67
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: