Skip to content

[css-shapes][css-images-3] <radial-size> syntax seems incorrect #10812

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
romainmenke opened this issue Aug 31, 2024 · 3 comments
Open

[css-shapes][css-images-3] <radial-size> syntax seems incorrect #10812

romainmenke opened this issue Aug 31, 2024 · 3 comments
Labels
css-images-3 Current Work

Comments

@romainmenke
Copy link
Member

romainmenke commented Aug 31, 2024

https://drafts.csswg.org/css-images-3/#typedef-radial-size

<radial-size> = <radial-extent> | <length [0,∞]> | <length-percentage [0,∞]>{2}

This syntax does not allow this:

clip-path: ellipse(closest-side closest-side at 5rem 6rem);

Despite that being the implemented feature: https://codepen.io/romainmenke/pen/PordyZx

I think this was a regression in #9723

Grouping it seems to resolve the issue:

<radial-size> = [ <radial-extent> | <length [0,∞]> | <length-percentage [0,∞]> ]{2}

But I am not that familiar with the feature, so my suggestion might be incorrect.


Edit:

The suggested edit would break circle().
I think that that might be the root cause.

That both circle() and ellipse() are defined with <radial-size> while they should be different.

This might work though:

https://drafts.csswg.org/css-images-3/#typedef-radial-size

- <radial-size> = [ <radial-extent> | <length [0,∞]> | <length-percentage [0,∞]> ]{2}
+ <radial-size> = [ <radial-extent> | <length [0,∞]> | <length-percentage [0,∞]> ]

https://drafts.csswg.org/css-shapes/#funcdef-basic-shape-ellipse

- <ellipse()> = ellipse( <radial-size>? [ at <position> ]? )
+ <ellipse()> = ellipse( [ <radial-size>{2} ]? [ at <position> ]? )
@romainmenke romainmenke changed the title [css-shapes] [css-images-3] <radial-size> syntax seems incorrect [css-shapes][css-images-3] <radial-size> syntax seems incorrect Aug 31, 2024
@romainmenke romainmenke added the css-images-3 Current Work label Aug 31, 2024
@cdoublev
Copy link
Collaborator

cdoublev commented Sep 1, 2024

I think you missed the extension in CSS Images 4.

But I would also prefer (y)our suggested syntax (#9730).

@romainmenke
Copy link
Member Author

romainmenke commented Sep 1, 2024

Aha, I wasn't aware of the prose in that section. Thank you for finding this 🙇

Unfortunately we can't parse prose 😛

Two-component values remain invalid when specifying circle as the <radial-shape>, and otherwise indicate the horizontal (first) and vertical (second) radii of the ellipse.

(Working on a CSS declaration linter that uses @webref/css as the source of truth.)

@cdoublev
Copy link
Collaborator

cdoublev commented Sep 3, 2024

I closed #9730 in favor of this issue, to rephrase my questions about the <radial-size> extension in CSS Images 4.

As noted in the comments above, it would be great if the restriction to a single component value for circle() and a circle gradient shape could be hardcoded into the syntax.

Before this extension:

  • circle() could be specified with one <radial-extent> (restricted to *-side) or <length-percentage>
  • a circle gradient shape could be specified with one <radial-extent> or <length>
  • ellipse() could be specified with two <radial-extent>s (restricted to *-side) or <length-percentage>s
  • a ellipse gradient shape could be specified with one <radial-extent> or two <length-percentage>s

Now:

Now for ellipse() and ellipse gradient shape, reading #824, it is not clear whether accepting a single component value was intentional, what the default value (if any) of the second component value and the shortest serialization should be when omitted.

I suspect it should default to the first component value, except when the first is *-corner.

Since a single <length> (or <percentage>, presumably) indicates a circle gradient shape, how would you serialize ellipse 1px or ellipse 1px 1px:

  1. ellipse 1px
  2. 1px 1px

Or maybe it is fine to serialize 1px? Would it mean that ellipse(1px) should serialize as circle(1px)?

cdoublev added a commit to cdoublev/css that referenced this issue Sep 12, 2024
Temporary implementation:

- disallow mixing `*-corner` (w3c/csswg-drafts#10833)
- allow mixing `<radial-extent>` and `<length-percentage>`
  (w3c/csswg-drafts#9729)
- the second component value of `<radial-radius>` defaults to the first
  when omitted (w3c/csswg-drafts#10812)
- serialize `ellipse 1px` as `1px` (the gradient shape becomes
  `circle`)
- serialize `ellipse(1px)` as is (the basic shape does not become
  `circle()`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-images-3 Current Work
Projects
None yet
Development

No branches or pull requests

2 participants