Skip to content
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

[css-images-4] Allow a single color stop with two positions #10077

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cdoublev
Copy link
Collaborator

@cdoublev cdoublev commented Mar 14, 2024

Fixes #10092.

Also, the value definition of <color-stop-list> does not allow a single color stop implicitly representing two color stops

it needs a variant production that allows a single doubled stop

I am not sure this remains an editorial change. I assume a single color stop defined with two positions was supposed to become valid at the time the syntax of (more than one) color stop defined with two positions was specified.

Chrome and FF (at least) supports this syntax, but it is not tested.

Maybe this sentence should also be updated:

Color stops and transition hints are specified in a color stop list, which is a list of two or more color stops interleaved with optional transition hints:

@w3cbot
Copy link

w3cbot commented Mar 14, 2024

svgeesus marked as non substantive for IPR from ash-nazg.

@svgeesus svgeesus requested a review from LeaVerou March 14, 2024 16:32
@LeaVerou
Copy link
Member

LeaVerou commented Mar 14, 2024

Hey, thanks for working on this! Long overdue!

Here are some tests: https://codepen.io/leaverou/pen/eYodMoj (if anyone can port them to WPT after this is merged, that would be great)

And yes, the two position syntax works everywhere. Safari as well, just tested. No browser seems to support one or zero positions.

Looking at the change, it's a little unfortunate we have to define new separate tokens just to make sure that if we have a single color stop it has two positions. And it makes me wonder why do we actually need to enforce this. What purpose does it serve? What's the harm in simply allowing a single color stop, even if it has one position — or even none? You get a single color anyway, and allowing these would provide a smoother authoring experience for editors offering realtime updates. Even with the two color stop positions, you can specify both to be equal, so can't we just spec that a single position expands to that, and no position expands to 0% 100% or something? If anything, when you have a single color stop no position makes more sense!

cc @tabatkins thoughts?

@tabatkins
Copy link
Member

If you have a single color, any number of positions will produce the same thing (a solid-color gradient), so in theory that would be fine, but the current spec is just the most straightforward mapping of the earlier requirement (that you have at least two stops, so there's some notion of a "gradient" being defined) into the new ability for one stop to define two positions. If you just wanted a solid-color image, the intention is that you shouldn't reach for a gradient, but image(blue) (which has never been implemented, sadly).

I don't really have an opinion on this, but since impls all seem to agree, I'm inclined to just accept Guillaume's PR as-is.

@cdoublev
Copy link
Collaborator Author

I had not considered that browser vendors added support for a single color stop without a clear purpose. I thought it was an oversight in the spec. So the proposed change is substantive.

Fwiw, I have a preference for Lea's suggestion, which requires a simpler syntax change.

@LeaVerou
Copy link
Member

I just filed this issue so we can discuss there: #10092

But after enumerating the pros and cons, I think I'm pretty strongly in favor of dropping this restriction.

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

Successfully merging this pull request may close these issues.

[css-images-4] Allow gradients with a single color stop and 0-1 positions
4 participants