Skip to content

Conversation

@cdoublev
Copy link
Collaborator

Fixes #7986.

The current syntax makes the color stop list optional, which is obviously unexpected.

This PR also aligns CSS Images 4 with CSS Images 3 regarding <size> renamed to <rg-size> (resolving a conflict with <ray()>) and <ending-shape> renamed to <rg-ending-shape> (for consistency, I guess).

I am not sure if a? b? || c is different than [a? b?]! || c so I prefered the first option for simplicity.

@tabatkins tabatkins merged commit dcbdd6d into w3c:main Jan 27, 2023
@tabatkins
Copy link
Member

I am not sure if a? b? || c is different than [a? b?]! || c so I prefered the first option for simplicity.

They're not equivalent (the first is allowed to produce nothing, the second isn't), but for the purpose of this spec what you did was correct.

@cdoublev cdoublev deleted the issue-7986 branch January 28, 2023 05:27
@cdoublev
Copy link
Collaborator Author

cdoublev commented Jan 30, 2023

Right, and actually I would have preferred the other syntax for two reasons.

First, the trailing ? in (conic gradient parameters) [[[from <angle>]? [at <position>]?] || <color-interpolation-method>]? and (radial gradient parameters) [[[<radial-shape> || <radial-size>]? [at <position>]?] || <color-interpolation-method>]? is useless, which does not seem right to me.

Second, the result is not consistent with the result from parsing <linear-gradient()>.

conic-gradient(red, cyan), linear-gradient(red, cyan), radial-gradient(red, cyan), produce the following pseudo-representations:

ConicGradient(
  List(
    List(
      Omitted('from <angle>'),
      Omitted('at <position>'),
    ),
    Omitted('<color-interpolation-method>'),
  ),
  ColorStopList(Keyword('red'), Keyword('cyan')),
)
LinearGradient(
  Omitted('[<angle> | to <side-or-corner>] || <color-interpolation-method>'),
  ColorStopList(Keyword('red'), Keyword('cyan')),
)
RadialGradient(
  List(
    List(
      Omitted('<radial-shape> || <radial-size>'),
      Omitted('at <position>'),
    ),
    Omitted('<color-interpolation-method>'),
  ),
  ColorStopList(Keyword('red'), Keyword('cyan')),
)

I would prefer to get this:

ConicGradient(
  Omitted('[[from <angle>]? [at <position>]?]! || <color-interpolation-method>'),
  ColorStopList(Keyword('red'), Keyword('cyan')),
)
LinearGradient(
  Omitted('[<angle> | to <side-or-corner>] || <color-interpolation-method>'),
  ColorStopList(Keyword('red'), Keyword('cyan')),
)
RadialGradient(
  Omitted('[[<radial-shape> || <radial-size>]? [at <position>]?]! || <color-interpolation-method>'),
  ColorStopList(Keyword('red'), Keyword('cyan')),
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[css-images-4] Relax color interpolation method syntax in gradients

2 participants