[csswg-drafts] [css-values] when should values inside `mix()` be clamped? (#8158)

graouts has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-values] when should values inside `mix()` be clamped?  ==
CSS Values and Units Level 4 introduces the `mix()` function. It's not clear to me reading the spec at what point clamping should be applied for this example:

```html
<div style="font-size: 40px; line-height: mix(0.5, 40px, calc(40px - 3em))"></div>
```

The spec has this to say in the [Range Checking section for calc()](https://w3c.github.io/csswg-drafts/css-values/#calc-range):

> Parse-time range-checking of values is not performed within [math functions](https://w3c.github.io/csswg-drafts/css-values/#math-function), and therefore out-of-range values do not cause the declaration to become invalid. However, the value resulting from an expression must be clamped to the range allowed in the target context. 

I'm not sure what "resulting from an expression" means here. I think the above `mix()` value could resolve to either:

1. `20px` where we clamp the output of the `calc()` expression and mix between `40px` and `0px`,
1. `0px` where we only clamp the output of the entire `mix()` expression and mix between `40px` and `-80px`, clamping the result  `-20px` to `0px`

Assuming that "resulting from an expression" refers to any _math function_ then it would clearly be the first result since `mix()` is _not_ a math function.

This is somewhat related to https://github.com/w3c/csswg-drafts/issues/8157 where I raised the issue of what would happen when interpolating between the same two values in the context of an animation.

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


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

Received on Wednesday, 30 November 2022 14:53:06 UTC