Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 430a1af268a49ad83203e80e137af6a02dba85b7
https://github.com/WebKit/WebKit/commit/430a1af268a49ad83203e80e137af6a02dba85b7
Author: Dan Glastonbury <[email protected]>
Date: 2026-07-15 (Wed, 15 Jul 2026)
Changed paths:
A LayoutTests/fast/gradients/oklch-shorter-hue-wrap-expected.html
A LayoutTests/fast/gradients/oklch-shorter-hue-wrap.html
M LayoutTests/platform/glib/TestExpectations
M LayoutTests/platform/win/TestExpectations
M Source/WebCore/platform/graphics/SampledGradientBuilder.h
Log Message:
-----------
REGRESSION (310405@main): Oklch gradients sometimes have random bands of
colour in them
https://bugs.webkit.org/show_bug.cgi?id=317853
rdar://181244580
Reviewed by Simon Fraser.
When drawing a non-sRGB gradient in a hue interpolation space (HSL, LCH, OKLCH,
...), coarseSampleStops() bakes the hue rotation into a set of coarse samples
whose hue components are stored in [0, 360). evaluateLinearOS() then
interpolates each adjacent pair of coarse samples with a plain component-wise
lerp. When the rotation crosses the 0/360 boundary, the two samples bracketing
the crossing sit on opposite sides of the wrap (e.g. 0.5 and 359.5), so lerping
the hue directly sweeps ~360 degrees the long way around the wheel and paints a
band of unrelated colour in the middle of the gradient.
Fix this by unwrapping stop1's hue to within 180 degrees of stop0's before the
lerp, so interpolation follows the intended short step, then renormalizing the
result into [0, 360) before conversion to the output color space. The unwrap is
kept local to the interpolation step rather than applied to the stored coarse
samples, because HSL->sRGB conversion is only defined for hue in [0, 360) (it
uses fmod, which is not wrap-safe for negative angles), and those samples are
also converted directly by toColorTypeResolvingNone().
Test: fast/gradients/oklch-shorter-hue-wrap.html
* LayoutTests/fast/gradients/oklch-shorter-hue-wrap-expected.html: Added.
* LayoutTests/fast/gradients/oklch-shorter-hue-wrap.html: Added.
* LayoutTests/platform/glib/TestExpectations:
* LayoutTests/platform/win/TestExpectations:
* Source/WebCore/platform/graphics/SampledGradientBuilder.h:
(WebCore::evaluateLinearOS):
Canonical link: https://commits.webkit.org/317281@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications