Re: [csswg-drafts] [css-color-4] `rgba()` is legacy so does not support `none`. Right? (#7900)

I assume that the consensus is to accept `none` as an argument of `rgba()` and `hsla()` when they are aliases of the modern `rgb()` and `hsl()`, respectively, and that *legacy `rgba()`* or *legacy `hsla()`* are a short and confusing concept/naming for `rgba()` or `hsla()` as aliases of legacy `rgb()` or `hsl()`, that should be removed from the spec (like the link in the definition of [`<color>`](https://drafts.csswg.org/css-color-4/#typedef-color) directing from `<rgba()>` to the definition of *rgba() legacy color syntax*).

```css
  color:  rgb(0, 0, 0, none); /* invalid */
  color: rgba(0, 0, 0, none); /* invalid */
  color:  rgb(0 0 0 / none);  /* valid, serializes to rgba(0, 0, 0, 0) */
  color: rgba(0 0 0 / none);  /* valid, serializes to rgba(0, 0, 0, 0) */
```

---

Please allow me this additional observation, which is also valid for `<hsla()>`.

`<color>` includes both `... | <rgb()> | <rgba()> | ...`, therefore a CSS parser should not recognize `rgba` as a function name alias of `rgb` when matching against `<rgb()>`: an input specified with `rgba(...)` should match `<rgba()>` instead.

`<rgba()>` is not defined with a basic syntax therefore `w3c/reffy` only extracts [some prose](https://github.com/w3c/webref/blob/444c84e7c4a73229e86765d6943c58f55676526f/ed/css/css-color.json#L42) and a grammar-driven parser implementation must define it on its side. It cannot define it with `<rgba()> = <rgb()>` because this would require to recognize `rgba` as a function name alias of `rgb`.

It might tempting to say that `rgba()` should be defined in prose as a legacy alias for `rgb()` and that `<rgba()>` should be removed from `<color>`, but similarly, `<repeating-*-gradient()>` is not defined with a basic syntax, is clearly not legacy, and is semantically different than the corresponding `<*-gradient()>`.

In my opinion, an ideal solution would be to define the arguments of `<rgb()>` and `<rgba()>` with a non-terminal:

```
<rgb-fn-args> = [
    [<percentage> | none]{3} [/ [<alpha-value> | none]]?
  | [<number> | none]{3} [/ [<alpha-value> | none]]?
<rgb()> = rgb(<rgb-fn-args>)
<rgba()> = rgba(<rgb-fn-args>)
```

`<rgb-fn-args>` could even include `<legacy-rgb-fn-args>`, which would allow `w3c/webref` to remove [`legacyValue` for `<rgb()>`](https://github.com/w3c/webref/blob/444c84e7c4a73229e86765d6943c58f55676526f/ed/css/css-color.json#L75).

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


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

Received on Tuesday, 15 November 2022 14:33:45 UTC