Closed Bug 1746251 Opened 4 years ago Closed 4 years ago

Percent normalization incorrect in color-mix()

Categories

(Core :: CSS Parsing and Computation, defect, P3)

Firefox 97
defect

Tracking

()

RESOLVED DUPLICATE of bug 1770616

People

(Reporter: chris, Unassigned, Mentored)

References

Details

(Keywords: good-first-bug)

Attachments

(3 files)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0

Steps to reproduce:

I created a test for wpt and Firefox failed one subtest, where percentages add to more than 100%.
I created a second test to explore this in more detail and Firefox fails all the subtests where percentages sum to more than 100

Actual results:

It looks as if there is no percentage normalization happening. Instead, the first percentage is taken as-is and the second one is ignored and computed as 100% minus the first percentage?

Expected results:

https://drafts.csswg.org/css-color-5/#color-mix

Let p1 be the first percentage and p2 the second one.

If both percentages are omitted, they each default to 50% (an equal mix of the two colors).

Otherwise, if p2 is omitted, it becomes 100% - p1

Otherwise, if p1 is omitted, it becomes 100% - p2

If the percentages sum to zero, the function is invalid.

Otherwise, if both are provided and add up to greater than 100%, they are scaled accordingly so that they add up to 100%.

Component: Untriaged → CSS Parsing and Computation
Product: Firefox → Core

Relevant code is here and this should be trivial to fix by checking whether left_weight and right_weight add up to more than 1 (and acting accordingly).

Mentor: emilio
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: good-first-bug

related WPT PR for these two tests
https://github.com/web-platform-tests/wpt/pull/32084

The severity field is not set for this bug.
:emilio, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(emilio)
Severity: -- → S3
Flags: needinfo?(emilio)
Priority: -- → P3

Bug 1770616 does this.

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: