W3C home > Mailing lists > Public > public-css-archive@w3.org > February 2021

[csswg-drafts] [css-color-5] Clarification needed on type of r, g, b constants in "relative color syntax" for rgb() (#6044)

From: weinig via GitHub <sysbot+gh@w3.org>
Date: Sat, 27 Feb 2021 18:43:12 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-817991908-1614451391-sysbot+gh@w3.org>
weinig has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-color-5] Clarification needed on type of r, g, b constants in "relative color syntax" for rgb() ==
In CSS Color 5's Relative color syntax, https://drafts.csswg.org/css-color-5/#relative-RGB, the spec is inconsistent on the types/semantics for the r, g, and b, constants. The normative text says "r", "g", and "b" are percentages ("r is a <percentage> that corresponds to the origin color’s red channel after its conversion to sRGB"), but in Example 13, it is intermixing them with non-percentages:

    rgb(from indianred 255 g b)

It seems like this should resolve to

    rgb(255 36.0784% 36.0784%)
which is invalid.

In the investigative implementation in WebKit, to keep the example working, I implemented it to assume that "r", "g", and "b" can either be numbers or percentages, but they all have to be the same and match the constants as well. So in the example above, since the first parameter is 255, it forces "g" and "b" to use their numeric forms, and therefore resolves to:

    rgb(255 92, 92)

Which is what the example says is the result.

This leaves a weird case of no numeric constant being used for any parameter, like:
    rgb(from indianred calc(r+1) calc(g+1) calc(b+1))

in which case we need some default type. I have picked percentages, since that is what the spec text currently says is the type, but I am not sure if that is desirable.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6044 using your GitHub account

Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Saturday, 27 February 2021 18:43:14 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:42:28 UTC