Skip to content

Skip the interpolation method in linear gradient stops - #281

Merged
eXpl0it3r merged 1 commit into
masterfrom
fix/gradient-interpolation-method
Nov 10, 2026
Merged

eXpl0it3r merged 1 commit into
masterfrom
fix/gradient-interpolation-method

Conversation

@eXpl0it3r

Copy link
Copy Markdown
Collaborator

A linear gradient with a leading color interpolation method, e.g. linear-gradient(in srgb, red, blue) or linear-gradient(in oklab to right, red, blue), got painted with an extra first color stop and the default top to bottom direction. The CSS engine already validates the in <colorspace> part, but CssValueParser.ParseLinearGradient, which builds the gradient for painting, didn't know about it and handed in srgb to the color parser as the first stop. As such only to right in oklab happened to work, since the direction keywords get looked up by name and the rest of the group is ignored.

The parser now takes the interpolation method out of the first argument with the existing ColorInterpolationMethodGrammar, reads whatever is left as the angle or to <side> direction, and treats the group as a prelude, not as a color stop. An invalid method or a leftover that isn't a direction makes the gradient invalid. The gradient still interpolates in sRGB, actually using the given color space is a separate feature. Radial and conic gradients aren't painted yet, so only linear-gradient() and repeating-linear-gradient() are affected.

How to test this PR?

CI should succeed. GradientTests.ParseImageSkipsTheInterpolationMethod covers the method alone, before and after an angle or a side, with a hue interpolation method and on a repeating gradient, and fails on master. GradientTests.ParseImageRejectsAnInvalidInterpolationMethod checks that an invalid method drops the gradient.

@eXpl0it3r
eXpl0it3r force-pushed the fix/gradient-interpolation-method branch from 8199555 to d23302d Compare November 10, 2026 19:06
@eXpl0it3r
eXpl0it3r merged commit 3898af4 into master Nov 10, 2026
18 checks passed
@eXpl0it3r
eXpl0it3r deleted the fix/gradient-interpolation-method branch November 10, 2026 20:01
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.

1 participant