Re: [csswg-drafts] [css-color-5] Clarification of rgb() syntax (#8231)

Thanks for your edits.

> The grammar of the [modern color syntax](https://drafts.csswg.org/css-color-4/#modern-color-syntax) [`rgb()`](https://drafts.csswg.org/css-color-4/#funcdef-rgb) and [`rgba()`](https://drafts.csswg.org/css-color-4/#funcdef-rgba) functions are extended as follows:
>
> ```
>         rgb() =  rgb( [ from <color> ]? [ <number> | <percentage> | none]{3} [ / [<alpha-value> | none] ]? )
>        rgba() = rgba( [ from <color> ]? [ <number> | <percentage> | none]{3} [ / [<alpha-value> | none] ]? )
> <alpha-value> = <number> | <percentage>
>```

`w3c/reffy` will extract `rgb()` and `rgba()` value definitions from both CSS Color 4 and CSS Color 5, but it will only keep those of CSS Color 5 (above), whereas they are respectively defined with `[<legacy-rgb-syntax> | <modern-rgb-syntax>]` and `[<legacy-rgba-syntax> | <modern-rgba-syntax>]` in CSS Color 4.

The same problem applies to `hsl()` and `hsla()`. Basically, `w3c/reffy` will loose `<legacy-*-syntax>`.

The choices you made in your edits may be intentional, and the proper definitions can be hard-coded, as an exception. If not, I think the following changes would fix this problem:

> The grammar of the [`<modern-rgb-syntax>`](https://drafts.csswg.org/css-color-4/#typedef-modern-rgb-syntax) and [`<modern-rgba-syntax>`](https://drafts.csswg.org/css-color-4/#typedef-modern-rgba-syntax) functions are extended as follows:
>
> ```
> <modern-rgb-syntax> = rgb( 
>    [ from <color> ]? 
>    [ <number> | <percentage> | none ]{3} 
>    [ / [<alpha-value> | none] ]? 
> )
> <modern-rgba-syntax> = rgba( 
>   [ from <color> ]? 
>   [ <number> | <percentage> | none ]{3} 
>   [ / [<alpha-value> | none] ]? 
> )
>```

I removed the definition of `<alpha-value>` because it is already [defined](https://drafts.csswg.org/css-color-4/#typedef-alpha-value) in CSS Color 4 with mixed `<number> | <percentage>`.

Legacy color syntaxes should not allow to mix them, but I think this is a different problem (#8311) that could be fixed by replacing `<alpha-value>` by `<number>` OR `<percentage>` in the appropriate locations of `<legacy-rgb-syntax>` and `<legacy-rgba-syntax>`:

```
 <legacy-rgb-syntax> = rgb( <number>#{3,4} ) | rgb( <<percentage>>#{3,4} )
<legacy-rgba-syntax> = rgba( <number>#{3,4} ) | rgba( <<percentage>>#{3,4} )
```

-- 
GitHub Notification of comment by cdoublev
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8231#issuecomment-1438583742 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 21 February 2023 14:27:00 UTC