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] Rendering gradients with missing color components #9295

Open
mysteryDate opened this issue Sep 2, 2023 · 8 comments
Open

Comments

@mysteryDate
Copy link

mysteryDate commented Sep 2, 2023

There is disagreement over interactions between the css-color-4 and css-images-4 specifications here: crbug.com/1462612. Specifically, what is the desired behavior color stops with missing components in gradients. For example:

linear-gradient(to right in srgb, color(srgb 1 0 0), color(srgb none 0 0), color(srgb 0 0 1)

Intuitively, I assumed that the red channel of the above gradient should interpolate as if the 2nd color stop were not there and thus would be a linear interpolation of the surrounding color stops:

linear-gradient(to right in srgb, color(srgb 1 0 0), color(srgb 0.5 0 0), color(srgb 0 0 1)

Screenshot 2023-09-02 at 11 33 08 AM

@brianosman Pointed out several things that are problematic with this approach at here:

From https://csswg.sesse.net/css-color-4/#interpolation-missing:

If a color with a carried forward missing component is interpolated with another color which is not missing that component, the missing component is treated as having the other color’s component value.

And from https://csswg.sesse.net/css-images-4/#coloring-gradient-line:

Between two color stops, the gradient line’s color is interpolated between the colors of the two color stops

From these two things @brianosman concluded that the color of any point on a gradient should be fully determined neighboring color stops and that "none"s should be resolved by splitting into two color stops and interpolating with the neighbors, resulting in:

linear-gradient(to right in srgb, color(srgb 1 0 0), color(srgb 1 0 0) 50%, color(srgb 0 0 1) 50%, color(srgb 0 0 1)

Screenshot 2023-09-02 at 11 39 57 AM

This, to me, seems intuitively like the incorrect result. What is the correct behavior? Can we clarify the spec?

@svgeesus
Copy link
Contributor

svgeesus commented Sep 2, 2023

Intuitively, I assumed that the red channel of the above gradient should interpolate as if the 2nd color stop were not there

I don't see how that conclusion follows from any specification text.

If a color with a carried forward missing component is interpolated with another color which is not missing that component, the missing component is treated as having the other color’s component value.

Exactly.

"none"s should be resolved by splitting into two color stops and interpolating with the neighbor

Not two stops exactly, but yes the color at that stop has different values on one side and the other (because none is filled in with different values on each side) so it does behave like two co-incident stops, with a hard transition.

@svgeesus
Copy link
Contributor

svgeesus commented Sep 2, 2023

So

linear-gradient(in oklch, red, transparent, blue);

Would first transform all three color stops to oklch (rounding here):
linear-gradient(in oklch, oklch(0.628 0.26 29.23), oklch(0 0 none / 0), oklch(0.45 0.31 264.05));

Right. And then the first segment interpolates oklch(0.628 0.26 29.23) to ,oklch(0 0 29.23/ 0) while the second interpolates oklch(0 0 264.05/ 0) with oklch(0.45 0.31 264.05) which is as expected - the hue does not change along either of the two segments, they just fade to transparent black.

Doing some hue interpolation between two adjacent stops would cause the hue to gradually change on both segments.

@mysteryDate
Copy link
Author

Great, thanks! That clears everything up for me. Should we add an example to css-images-4 or just close this issue?

@svgeesus
Copy link
Contributor

svgeesus commented Sep 4, 2023

Given that you initially came to a different interpretation, I think it makes sense to add a clarifying example to Images 4.

@svgeesus svgeesus added Needs Example or Figure and removed css-color-4 Current Work labels Sep 4, 2023
@svgeesus svgeesus changed the title [css-color-4] Rendering gradients with missing color components [css-images-4] Rendering gradients with missing color components Sep 4, 2023
@argyleink
Copy link
Contributor

clarification definitely needed, as I expected @mysteryDate's first example and will be surprised when it ends up being the 2nd one. I'll adjust my mental model

@svgeesus
Copy link
Contributor

svgeesus commented Sep 5, 2023

@argyleink was there specific text wording that led you to that conclusion?

@argyleink
Copy link
Contributor

@argyleink was there specific text wording that led you to that conclusion?

Nah, just intent vs result. I can adapt to fit

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Sep 10, 2023
w3c/csswg-drafts#9295

I mistakenly thought earlier that missing parameters should resolve as
if that parameter were not there. In fact it should effectively become two stops in the same spot, taking non-missing parameters from
the left and right neighbors, respectively. If either neighbor is
missing then the parameter resolves to zero.

The test had to be updated.

Bug: 1462612
Change-Id: Ie3c55d17117537052fa7cecb66bfd2b953952a38
aarongable pushed a commit to chromium/chromium that referenced this issue Sep 12, 2023
w3c/csswg-drafts#9295

I mistakenly thought earlier that missing parameters should resolve as
if that parameter were not there. In fact it should effectively become two stops in the same spot, taking non-missing parameters from
the left and right neighbors, respectively. If either neighbor is
missing then the parameter resolves to zero.

The test had to be updated.

Bug: 1462612
Change-Id: Ie3c55d17117537052fa7cecb66bfd2b953952a38
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4834550
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Aaron Krajeski <aaronhk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1195374}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Sep 12, 2023
w3c/csswg-drafts#9295

I mistakenly thought earlier that missing parameters should resolve as
if that parameter were not there. In fact it should effectively become two stops in the same spot, taking non-missing parameters from
the left and right neighbors, respectively. If either neighbor is
missing then the parameter resolves to zero.

The test had to be updated.

Bug: 1462612
Change-Id: Ie3c55d17117537052fa7cecb66bfd2b953952a38
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4834550
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Aaron Krajeski <aaronhk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1195374}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Sep 12, 2023
w3c/csswg-drafts#9295

I mistakenly thought earlier that missing parameters should resolve as
if that parameter were not there. In fact it should effectively become two stops in the same spot, taking non-missing parameters from
the left and right neighbors, respectively. If either neighbor is
missing then the parameter resolves to zero.

The test had to be updated.

Bug: 1462612
Change-Id: Ie3c55d17117537052fa7cecb66bfd2b953952a38
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4834550
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Aaron Krajeski <aaronhk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1195374}
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Sep 28, 2023
…or stops with missing parameters, a=testonly

Automatic update from web-platform-tests
Take neighboring values for gradient color stops with missing parameters

w3c/csswg-drafts#9295

I mistakenly thought earlier that missing parameters should resolve as
if that parameter were not there. In fact it should effectively become two stops in the same spot, taking non-missing parameters from
the left and right neighbors, respectively. If either neighbor is
missing then the parameter resolves to zero.

The test had to be updated.

Bug: 1462612
Change-Id: Ie3c55d17117537052fa7cecb66bfd2b953952a38
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4834550
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Aaron Krajeski <aaronhk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1195374}

--

wpt-commits: d5f48fa66a23af619da2c75f198cbf7c79110a9f
wpt-pr: 41900
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Sep 29, 2023
…or stops with missing parameters, a=testonly

Automatic update from web-platform-tests
Take neighboring values for gradient color stops with missing parameters

w3c/csswg-drafts#9295

I mistakenly thought earlier that missing parameters should resolve as
if that parameter were not there. In fact it should effectively become two stops in the same spot, taking non-missing parameters from
the left and right neighbors, respectively. If either neighbor is
missing then the parameter resolves to zero.

The test had to be updated.

Bug: 1462612
Change-Id: Ie3c55d17117537052fa7cecb66bfd2b953952a38
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4834550
Reviewed-by: Brian Osman <brianosmangoogle.com>
Commit-Queue: Aaron Krajeski <aaronhkchromium.org>
Cr-Commit-Position: refs/heads/main{#1195374}

--

wpt-commits: d5f48fa66a23af619da2c75f198cbf7c79110a9f
wpt-pr: 41900

UltraBlame original commit: e5003ff328895b7286e43560ed1f2e0365c7a89a
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Sep 29, 2023
…or stops with missing parameters, a=testonly

Automatic update from web-platform-tests
Take neighboring values for gradient color stops with missing parameters

w3c/csswg-drafts#9295

I mistakenly thought earlier that missing parameters should resolve as
if that parameter were not there. In fact it should effectively become two stops in the same spot, taking non-missing parameters from
the left and right neighbors, respectively. If either neighbor is
missing then the parameter resolves to zero.

The test had to be updated.

Bug: 1462612
Change-Id: Ie3c55d17117537052fa7cecb66bfd2b953952a38
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4834550
Reviewed-by: Brian Osman <brianosmangoogle.com>
Commit-Queue: Aaron Krajeski <aaronhkchromium.org>
Cr-Commit-Position: refs/heads/main{#1195374}

--

wpt-commits: d5f48fa66a23af619da2c75f198cbf7c79110a9f
wpt-pr: 41900

UltraBlame original commit: e5003ff328895b7286e43560ed1f2e0365c7a89a
ErichDonGubler pushed a commit to ErichDonGubler/firefox that referenced this issue Sep 30, 2023
…or stops with missing parameters, a=testonly

Automatic update from web-platform-tests
Take neighboring values for gradient color stops with missing parameters

w3c/csswg-drafts#9295

I mistakenly thought earlier that missing parameters should resolve as
if that parameter were not there. In fact it should effectively become two stops in the same spot, taking non-missing parameters from
the left and right neighbors, respectively. If either neighbor is
missing then the parameter resolves to zero.

The test had to be updated.

Bug: 1462612
Change-Id: Ie3c55d17117537052fa7cecb66bfd2b953952a38
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4834550
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Aaron Krajeski <aaronhk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1195374}

--

wpt-commits: d5f48fa66a23af619da2c75f198cbf7c79110a9f
wpt-pr: 41900
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue Sep 30, 2023
…or stops with missing parameters, a=testonly

Automatic update from web-platform-tests
Take neighboring values for gradient color stops with missing parameters

w3c/csswg-drafts#9295

I mistakenly thought earlier that missing parameters should resolve as
if that parameter were not there. In fact it should effectively become two stops in the same spot, taking non-missing parameters from
the left and right neighbors, respectively. If either neighbor is
missing then the parameter resolves to zero.

The test had to be updated.

Bug: 1462612
Change-Id: Ie3c55d17117537052fa7cecb66bfd2b953952a38
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4834550
Reviewed-by: Brian Osman <brianosmangoogle.com>
Commit-Queue: Aaron Krajeski <aaronhkchromium.org>
Cr-Commit-Position: refs/heads/main{#1195374}

--

wpt-commits: d5f48fa66a23af619da2c75f198cbf7c79110a9f
wpt-pr: 41900

UltraBlame original commit: e5003ff328895b7286e43560ed1f2e0365c7a89a
@brianosman
Copy link
Contributor

brianosman commented Oct 27, 2023

edit: Ignore me. I'm over-thinking this. The hue interpolation makes no difference in this case, because all the intermediate colors are achromatic as well. Move along - nothing to see here.

Lightning00Blade pushed a commit to Lightning00Blade/wpt that referenced this issue Dec 11, 2023
w3c/csswg-drafts#9295

I mistakenly thought earlier that missing parameters should resolve as
if that parameter were not there. In fact it should effectively become two stops in the same spot, taking non-missing parameters from
the left and right neighbors, respectively. If either neighbor is
missing then the parameter resolves to zero.

The test had to be updated.

Bug: 1462612
Change-Id: Ie3c55d17117537052fa7cecb66bfd2b953952a38
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4834550
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Aaron Krajeski <aaronhk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1195374}
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

4 participants