Skip to content

Conversation

@frivoal
Copy link
Collaborator

@frivoal frivoal commented Jan 9, 2017

This is a proposal to resolve the lack of a generally usable definition for how colors, and in particular currentcolor are turned into computed values, used values, inherited...

This should help address #741, #480, and #867 (and maybe other issues I am not aware of).

If we agree on the concept, we should probably try to backport the relevant subset of this to css-colors-3. I can do this as an update to this PR or as a separate one, as the WG / editors prefer.

I have for now left undefined (and marked as an issue) the computed values of the functions that are not yet implemented. We should have that discussion as well, but it need not delay the introduction of the general concept and anchoring terminology.

For the functions that are implemented, the definition I provided is based on my observations of current inter-operable behavior.

This is a first pass at providing a centralized definition of how all
<<color>> values are treated at computed value and used value time.

This relates to w3c#741, w3c#480, w3c#867
@frivoal
Copy link
Collaborator Author

frivoal commented Jan 9, 2017

Agenda+ to discuss if this is the way to go, and if tweaks are needed.

4 and 8 digits <a>hex colors</a>,
comma separated ''rgba()'' colors with an alpha channel,
and comma separated ''hsla()'' colors with an alpha channel,
is the equivalent numeric value in comma separated ''rgba()'' notation with the alpha value.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't match what browsers currently do. Browsers use rgb() for opaque colors even if the color is specified from rgba(). See http://software.hixie.ch/utilities/js/live-dom-viewer/saved/4780

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Added a new commit to reflect that.

so descendants will use their own 'color' property to resolve it.

<li>
The computed value and used value of ''<color>/transparent'' is ''rgba(0,0,0,0)''.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be rgba(0, 0, 0, 0).

FWIW, it seems for all colors whose alpha channel is zero, Gecko returns transparent as the resolve value, which may make some sense given they are effectively the same for rendering. But other browsers' behavior that returns the rgba value seems to be better regarding consistency.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a huge fan of that behavior, but that's indeed what gecko does. Added an issue to call it out, so that we don't loose track of this difference and remember to resolve it later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, probably I should use "BTW" instead of "FWIW" here. The main issue I want to raise here is a small editoral issue that there should be a whitespace after each comma. rgba(0,0,0,0) without whitespaces doesn't match any browser, and could cause confusing.

Percentages: N/A
Media: visual
Computed value: an RGBA color
Computed value: See <a>resolving color values</a>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is actually wrong for the color property, since for color, currentColor should be resolved at computed value time. (I can't think of how this is observable today, but I'd much prefer it be defined this way.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've fixed the definition now, so this reference should now be fine.

Copy link
Contributor

@svgeesus svgeesus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't add inline issues; issues should be on GitHub and just linked from the spec.

Note: Multi-word keywords in CSS usually separate their component words with hyphens.
''currentcolor'' doesn't, because it was originally introduced in SVG
''<color>/currentcolor'' doesn't, because it was originally introduced in SVG
as a special attribute value spelled "currentColor",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it was introduced as a property value (and properties in SVG can be expressed in presentational attributes, as well as in style attributes, style elements, and external stylesheets).


<li>
The computed value and used value of ''<color>/transparent'' is ''rgba(0,0,0,0)''.
The computed value and used value of ''<color>/transparent'' is ''rgba(0, 0, 0, 0)''.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe worth calling out explicitly that the serialization syntax (with commas) differs - for historical reasons - from the comma-less syntax which CSS4 color is now using (commas now being reserved for lists of alternatives).

@svgeesus
Copy link
Contributor

Merging because reviews seem generally positive and review comments have been addressed. My comments about inline issues can easily be fixed later and should not hold up a merge.

@svgeesus svgeesus closed this Jan 24, 2017
@svgeesus svgeesus reopened this Jan 24, 2017
@svgeesus svgeesus merged commit 85be5fe into w3c:master Jan 24, 2017
triple-underscore added a commit to triple-underscore/triple-underscore.github.io that referenced this pull request Jan 25, 2017
@frivoal frivoal deleted the resolving-colors branch June 5, 2020 01:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

css-color-4 Current Work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants