Skip to content

[css-properties-values-api] Computed values for <color> #247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jyc opened this issue Jun 23, 2016 · 7 comments
Closed

[css-properties-values-api] Computed values for <color> #247

jyc opened this issue Jun 23, 2016 · 7 comments

Comments

@jyc
Copy link
Contributor

jyc commented Jun 23, 2016

Section 2.4 of the spec says:

For <custom-ident>, ident, <color>, <image>, <url>, <integer>, <angle>, <time>, <resolution>, <transform-function> or "*" values, the computed value is identical to the specified value.

But what if a color value is currentColor, or a color name like red?

css-color level 4 says that the computed value of the color property is an RGBA color.

Should the computed value of a variable with type <color> be an RGBA color as well?

@bfgeek
Copy link
Contributor

bfgeek commented Jun 24, 2016

@tabatkins and I ran into currentColor in #133 as well.

If I understood correctly currentColor now specified to be an actual color at used-value time.
css-color level 4 might be inconsistent with itself? (see: https://drafts.csswg.org/css-color-4/#currentcolor-color )

@tabatkins
Copy link
Member

The computed value of color is always an rgba color; that has nothing to do with currentcolor.

currentcolor, when used in any other <color> context, is indeed preserved at computed-value time, and only turned into rgba at used-value time.

@jyc
Copy link
Contributor Author

jyc commented Jun 24, 2016

Then is currentColor considered "computationally idempotent" in terms of the initialValue parameter?

@shans
Copy link
Contributor

shans commented Aug 17, 2016

There's a problem here.

background: currentcolor;
will repaint when color changes from red to green; but

background: paint(foo); --background-color: currentcolor; ... registerPaint(“foo”, …, [“--background-color”]);
will not repaint when color changes, because currentcolor is computationally idempotent.

You could just add color to the list of sensitivities in registerPaint, but that seems like a bit of a hack given that currentcolor is valid all over the shop. Would it make sense to special-case currentcolor instead? This would require --background-color to be registered as a color property.

@tabatkins
Copy link
Member

Yes, I think we should bite the bullet and special-case currentcolor. It's used as the initial value of a bunch of properties already (border-color, text-decoration-color, etc), and there's definitely custom property use-cases that want the same thing.

@shans
Copy link
Contributor

shans commented Aug 17, 2016

(Note this also applies for line-height and custom layout)

@tabatkins
Copy link
Member

My current definition actually captures this correctly:

A property value is computationally independent
if it can be converted into a computed value
using only the value of the property on the element,
and "global" information that cannot be changed by CSS.

"currentcolor" as a specified value becomes "currentcolor" as a computed value, no extra information necessary (or it becomes #000 for 'color', same deal). It's not until used-value time that extra information is pulled in to resolve it into something different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants