[csswg-drafts] [css-easing-2] How to generate a computed value for linear-spline() (#7415)

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

== [css-easing-2] How to generate a computed value for linear-spline() ==
My initial thought was to serialize it the same as CSS gradients, as being similar to CSS gradients was one of the attractive parts of `linear-spline()`. However, @dshin-moz has pointed out how weird the computed value for gradients is.

```
Input:
linear-gradient(to right, <<color>>, <<color>> 50%, <<color>>)
Computed:
linear-gradient(to right, <<color>>, <<color>> 50%, <<color>>)
```

(I'm using `<<color>>` instead of values here, as Safari serializes them differently, and it's irrelevant to this issue)

The position value only appears in the output if it appeared in the declaration.

```
Input:
linear-gradient(to right, <<color>> 80%, <<color>> 10%)
Computed:
linear-gradient(to right, <<color>> 80%, <<color>> 10%)
```

Position values are not clamped to the position of their previous value.

```
Input:
linear-gradient(to right, <<color>>, <<color>> 50% 80%)
Computed:
linear-gradient(to right, <<color>>, <<color>> 50%, <<color>> 80%)
```

The second stop position is expanded into two entries.

So, what should we do for `linear-spline()`?

## Option 1: Copy linear-gradient

Follow all of the rules above, even though they're a bit weird.

## Option 2: Output fully computed value

- Unfold `0 50% 80%` into two entries: `0 50%, 0 80%`
- Include calculated positions, so `0, 0.5, 1` becomes `0 0%, 0.5 50%, 1 100%`
- Include corrections made to positions, so `0 50%, 1 20%` becomes `0 50%, 1 50%`

## Option 3: Output closer to authored format

- If a second stop is provided (eg `0 50% 80%`) it's retained in the output
- Positions are only included if they were included in the declaration, so `0, 0.5, 1` remains `0, 0.5, 1`
- Positions are not corrected, so `0 50%, 1 20%` remains `0 50%, 1 20%`.

My preference is option 2, as it allows developers to see the validation and calculation that took place.

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


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

Received on Friday, 24 June 2022 15:52:36 UTC