Skip to content

Commit

Permalink
Allow non-percentages for hsl and hwb
Browse files Browse the repository at this point in the history
HSL and HWB have comma-less, "non-legacy" formats now with
css-color-4. In these formats saturation, lightness, whiteness and
blackness no longer need to be in percentages, but instead can be
bare numbers which get divided by 100 to represent percentages.

https://drafts.csswg.org/css-color-4/#typedef-modern-hsl-syntax
"""
The next two arguments are the saturation and lightness, respectively. For saturation, 100% or 100 is a fully-saturated, bright color, and 0% or 0 is a fully-unsaturated gray. For lightness, 50% or 50 represents the "normal" color, while 100% or 100 is white and 0% or 0 is black.
"""

Some colors that were assumed to be "invalid" for relative color use
bare numbers for hsl/hwb and thus are no longer invalid.

Bug: 1505787
Change-Id: Ie7fec239d0422da54a3d8ee0e46e64b1bee73fe2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5067499
Reviewed-by: Rune Lillesveen <[email protected]>
Commit-Queue: Aaron Krajeski <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1231332}
  • Loading branch information
mysteryDate authored and chromium-wpt-export-bot committed Nov 30, 2023
1 parent 37fc071 commit 0caf8c7
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions css/css-color/parsing/color-invalid-relative-color.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@
// hsl(from ...)

// Testing invalid values.
test_invalid_value(`color`, `hsl(from rebeccapurple h 10% 10)`);
test_invalid_value(`color`, `hsl(from rebeccapurple h 10 10%)`);
test_invalid_value(`color`, `hsl(from rebeccapurple 10% s l)`);
test_invalid_value(`color`, `hsl(from rgb(10%, 20%, 30%, 40%) h 10% 10)`);
test_invalid_value(`color`, `hsl(from rgb(10%, 20%, 30%, 40%) h 10 10%)`);
test_invalid_value(`color`, `hsl(from rgb(10%, 20%, 30%, 40%) 10% s l)`);

// Testing invalid component names
Expand All @@ -55,11 +51,7 @@
// hwb(from ...)

// Testing invalid values.
test_invalid_value(`color`, `hwb(from rebeccapurple h 10% 10)`);
test_invalid_value(`color`, `hwb(from rebeccapurple h 10 10%)`);
test_invalid_value(`color`, `hwb(from rebeccapurple 10% w b)`);
test_invalid_value(`color`, `hwb(from rgb(10%, 20%, 30%, 40%) h 10% 10)`);
test_invalid_value(`color`, `hwb(from rgb(10%, 20%, 30%, 40%) h 10 10%)`);
test_invalid_value(`color`, `hwb(from rgb(10%, 20%, 30%, 40%) 10% w b)`);

// Testing invalid component names
Expand Down

0 comments on commit 0caf8c7

Please sign in to comment.