Skip to content

[css-easings-2] linear() serialization does not conform to shortest principle #9288

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

Open
cdoublev opened this issue Sep 1, 2023 · 3 comments

Comments

@cdoublev
Copy link
Collaborator

cdoublev commented Sep 1, 2023

https://drafts.csswg.org/css-easing-2/#linear-easing-function-serializing

The serialization of linear() includes input values for each point, and input values are never less than the input of the previous point.

For example:

  • linear(0, 0.25, 1) serializes as linear(0 0%, 0.25 50%, 1 100%)
  • linear(0 20%, 0.5 10%, 1) serializes as linear(0 20%, 0.5 20%, 1 100%)
  • linear(0, 0.25 25% 75%, 1) serializes as linear(0 0%, 0.25 25%, 0.25 75%, 1 100%)

https://drafts.csswg.org/cssom-1/#serialize-a-css-value

If component values can be omitted or replaced with a shorter representation without changing the meaning of the value, omit/replace them.

It should probably be consistent with the serialization of a gradient color stop list (related).

@cdoublev cdoublev added the css-easing-2 Current Work label Sep 1, 2023
@tabatkins
Copy link
Member

I've adjusted the serialization algo to match what impls appear to do for gradients - expand double-% stops into two stops, but preserve omitted %s in the serialization.

I'll likely need to adjust WPTs to match, so keeping this open.

cdoublev added a commit to cdoublev/css that referenced this issue Sep 12, 2024
Gradient color stops specified with two positions, or linear() control
points specified with two input progress values, should be normalized
into two two color stops or control points (w3c/csswg-drafts#9288).
@cdoublev
Copy link
Collaborator Author

  1. Otherwise, append " " (U+0020 SPACE) to s, then serialize the control point’s output progress value as a <percentage> and append it to s.

I think it should be "input progress value" at this step of serialize a linear() control point.

@tabatkins
Copy link
Member

Thanks for the catch, fixed.

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

2 participants