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

@cdoublev I'm not sure I'm following your explanation/argument. Allow me to be deliberately verbose in order to ensure we're all on the same page.

---

css-color-3 defines `rgb()` with one syntax (3 comma-separated arguments) and `rgba()` with another syntax (4 comma-separated arguments):

|             | `rgb()` | `rgba()` |
|-------------|---------|----------|
| 3 arguments | ✔️ | ❌ |
| 4 arguments | ❌ | ✔️ |

css-color-4 expands those definitions into a superset "legacy color syntax", using either 3 or 4 comma-separated arguments, invoked using either `rgb()` or `rgba()`:

|             | `rgb()` | `rgba()` |
|-------------|---------|----------|
| 3 arguments | ✔️ | ✔️ |
| 4 arguments | ✔️ | ✔️ |

That `rgba()` is what I refer to as "legacy `rgba()`" and is apparently already settled.

---

css-color-4 also defines a new syntax for `rgb()`, using only spaces and a slash to separate the alpha value, and allowing `none`. Under discussion here is whether that syntax is also available to `rgba()` - what I refer to as "modern `rgba()`".

The two options mentioned in the original comment are as follows:

a) `rgba()` is legacy syntax only
|               | `rgb()` | `rgba()` |
|---------------|---------|----------|
| legacy syntax | ✔️ | ✔️ |
| modern syntax | ✔️ | ❌ |

b) `rgba()` is a complete alias of `rgb()`
|               | `rgb()` | `rgba()` |
|---------------|---------|----------|
| legacy syntax | ✔️ | ✔️ |
| modern syntax | ✔️ | ✔️ |

Consensus appears to be (b).

----

After having ruminated and reread  your comment, I think you are merely arguing over how to define this grammatically? (When you say `rgba()` and `hsla()` "should be removed from the spec" you mean just as a distinct grammatical rule, rather than the entire concept?)

If that's the target, this is one way to do it:
```
<legacy-rgb-syntax> = <percentage>#{3} , <alpha-value>? | <number>#{3} , <alpha-value>?
<modern-rgb-syntax> = [<percentage> | none]{3} [ / [<alpha-value> | none] ]? | [<number> | none]{3} [ / [<alpha-value> | none] ]?
<rgb-function-name> = rgb | rgba
<rgb()> = <rgb-function-name>(<legacy-rgb-syntax> | <modern-rgb-syntax>)
```

But if not, this could also work:
```
<rgb()> = rgb(<legacy-rgb-syntax> | <modern-rgb-syntax>)
<rgba()> = rgba(<legacy-rgb-syntax> | <modern-rgb-syntax>)
```

(And similarly for `hsl()` and `hsla()`.)

The first option is essentially how I've implemented it.

The second option seems unnecessarily redundant if consensus is not interpretation (a), as it ostensibly requires `rgb()` and `rgba()` to be parsed independently.

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


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

Received on Wednesday, 16 November 2022 03:54:28 UTC