Re: [csswg-drafts] [css-color] Inconsistency of inherited value for color (#10536)

Right, [CSS color 4 says](https://drafts.csswg.org/css-color-4/#resolving-other-colors):

> In the [color](https://drafts.csswg.org/css-color-4/#propdef-color) property, the used value of currentcolor is the [inherited value](https://drafts.csswg.org/css-cascade-5/#inherited-value). In any other property, its used value is the used value of the color property on the same element.

> Note: This means that if the [currentcolor](https://drafts.csswg.org/css-color-4/#valdef-color-currentcolor) value is inherited, it’s inherited as a keyword, not as the value of the [color](https://drafts.csswg.org/css-color-4/#propdef-color) property, so descendants will use their own color property to resolve it.

You said:

> Substituting that into the computed value gives me
> 
> ```
> color-mix(in srgb, color-mix(in srgb, currentcolor, color(srgb 1 0 0)))
> ```
> 
> which is bad, since we haven't gotten rid of currentcolor this way.

Yes, that gives you the _used_ value of the color property.  Consider

```<div> 
  <div>
    <b>What color is <em>this</em> text?</b>
  </div>
</div>
```
and 

```
em { color: lime}
```

the _used_ value of the color property is `color-mix(in srgb, color-mix(in srgb, currentcolor, color(srgb 1 0 0)))` and the _actual_ value will be `color-mix(in srgb, color-mix(in srgb, color(srgb 0 0 1), color(srgb 1 0 0)))` on the `<b>` and `color-mix(in srgb, color-mix(in srgb, lime, color(srgb 1 0 0)))` on the `<em>`.



> If we bend the interpretation of the color spec to mean that inside the color property, currentcolor is replaced by the used value of the color property on the parent element, we end up with
> 
> ```
> color-mix(in srgb, color(srgb 0.5 0 0.5), color(srgb 1 0 0))
> ```

That isn't bending, but it does give you the actual value.



> But when I look at browsers, I get
> 
> ```
> color(srgb 0.5 0 0.5)
> ```

which is why they [fail a bunch of WPT tests related to currentColor](https://wpt.fyi/results/css/css-color?label=master&label=experimental&aligned&q=current), at the moment.

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


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

Received on Monday, 15 July 2024 18:27:30 UTC