Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Hue interpolation "specified" is not correctly implemented for hues <…
… 0 or > 360 https://bugs.webkit.org/show_bug.cgi?id=245552 <rdar://100344615> Reviewed by Darin Adler. Defers normalization of the hue component of lch(), oklch(), hsl() and hwb() colors until necessary, such as due to a color conversion, non-"specified" hue interpolation method use or serialization (though that one is unclear and is with the spec editors to decide on via w3c/csswg-drafts#7782). By deferring this normalization, we now implement the "specified" hue interpolation method correctly, which explicitly allows for a hue to rotate around the spectrum multiple times if the difference between angles requires it. To support this for hsl() and hwb(), which usually are stored as 8-bit sRGB, we use the same technique as was employed for "none" support, and conditionally use their extended form if an angle < 0 or > 360 is provided. This means that in the common cases there will be no change in memory usage. Additionally, I update the "longer" hue interpolation method to match the updated spec which changed a "< 0" to a "<= 0". Tests were added to show that gradients that prior to this change would render the same due to angle normalization, now render differently. * LayoutTests/fast/gradients/gradient-using-specified-hue-interpolation-method-hsl-expected-mismatch.html: Added. * LayoutTests/fast/gradients/gradient-using-specified-hue-interpolation-method-hsl.html: Added. * LayoutTests/fast/gradients/gradient-using-specified-hue-interpolation-method-hwb-expected-mismatch.html: Added. * LayoutTests/fast/gradients/gradient-using-specified-hue-interpolation-method-hwb.html: Added. * LayoutTests/fast/gradients/gradient-using-specified-hue-interpolation-method-lch-expected-mismatch.html: Added. * LayoutTests/fast/gradients/gradient-using-specified-hue-interpolation-method-lch.html: Added. * LayoutTests/fast/gradients/gradient-using-specified-hue-interpolation-method-oklch-expected-mismatch.html: Added. * LayoutTests/fast/gradients/gradient-using-specified-hue-interpolation-method-oklch.html: Added. * Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp: (WebCore::CSSPropertyParserHelpers::colorByNormalizingHSLComponents): (WebCore::CSSPropertyParserHelpers::parseHWBParameters): (WebCore::CSSPropertyParserHelpers::parseLCHParameters): * Source/WebCore/platform/graphics/ColorConversion.cpp: (WebCore::HSLA<float>>::convert): (WebCore::HWBA<float>>::convert): * Source/WebCore/platform/graphics/ColorInterpolation.cpp: (WebCore::fixupHueComponentsPriorToInterpolation): * Source/WebCore/platform/graphics/ColorModels.h: * Source/WebCore/platform/graphics/ColorNormalization.h: (WebCore::makeColorTypeByNormalizingComponents<HWBA<float>>): (WebCore::makeColorTypeByNormalizingComponents<HSLA<float>>): Deleted. (WebCore::makeColorTypeByNormalizingComponents<LCHA<float>>): Deleted. (WebCore::makeColorTypeByNormalizingComponents<OKLCHA<float>>): Deleted. * Source/WebCore/platform/graphics/ColorSerialization.cpp: (WebCore::serializationOfLabLikeColorsForCSS): (WebCore::serializationOfLCHLikeColorsForCSS): (WebCore::serializationForCSS): (WebCore::serializationOfLabFamilyForCSS): Deleted. Canonical link: https://commits.webkit.org/254833@main
- Loading branch information
Showing
15 changed files
with
258 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style> | ||
div { | ||
width: 400px; | ||
height: 100px; | ||
display: inline-block; | ||
} | ||
|
||
/* Ensures that when using the "specified" hue interpolation method that values < 0 and greater than 360 are respected and not normalized to the [0, 360] range. */ | ||
|
||
#gradient { | ||
background-image: linear-gradient(in hsl specified hue to right, hsl(120deg 100% 50%), hsl(300deg 100% 25.1%)); | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="gradient"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style> | ||
div { | ||
width: 400px; | ||
height: 100px; | ||
display: inline-block; | ||
} | ||
|
||
/* Ensures that when using the "specified" hue interpolation method that values < 0 and greater than 360 are respected and not normalized to the [0, 360] range. */ | ||
|
||
#gradient { | ||
background-image: linear-gradient(in hsl specified hue to right, hsl(-240deg 100% 50%), hsl(660deg 100% 25.1%)); | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="gradient"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style> | ||
div { | ||
width: 400px; | ||
height: 100px; | ||
display: inline-block; | ||
} | ||
|
||
/* Ensures that when using the "specified" hue interpolation method that values < 0 and greater than 360 are respected and not normalized to the [0, 360] range. */ | ||
|
||
#gradient { | ||
background-image: linear-gradient(in hwb specified hue to right, hwb(120deg 0% 0%), hwb(300deg 0% 50%)); | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="gradient"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style> | ||
div { | ||
width: 400px; | ||
height: 100px; | ||
display: inline-block; | ||
} | ||
|
||
/* Ensures that when using the "specified" hue interpolation method that values < 0 and greater than 360 are respected and not normalized to the [0, 360] range. */ | ||
|
||
#gradient { | ||
background-image: linear-gradient(in hwb specified hue to right, hwb(-240deg 0% 0%), hwb(660deg 0% 50%)); | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="gradient"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style> | ||
div { | ||
width: 400px; | ||
height: 100px; | ||
display: inline-block; | ||
} | ||
|
||
/* Ensures that when using the "specified" hue interpolation method that values < 0 and greater than 360 are respected and not normalized to the [0, 360] range. */ | ||
|
||
#gradient { | ||
background-image: linear-gradient(in lch specified hue to right, lch(70.55% 92.66 134.7deg), lch(31.32% 129.1 302.4deg)); | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="gradient"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style> | ||
div { | ||
width: 400px; | ||
height: 100px; | ||
display: inline-block; | ||
} | ||
|
||
/* Ensures that when using the "specified" hue interpolation method that values < 0 and greater than 360 are respected and not normalized to the [0, 360] range. */ | ||
|
||
#gradient { | ||
background-image: linear-gradient(in lch specified hue to right, lch(70.55% 92.66 -225.3deg), lch(31.32% 129.1 662.4deg)); | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="gradient"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style> | ||
div { | ||
width: 400px; | ||
height: 100px; | ||
display: inline-block; | ||
} | ||
|
||
/* Ensures that when using the "specified" hue interpolation method that values < 0 and greater than 360 are respected and not normalized to the [0, 360] range. */ | ||
|
||
#gradient { | ||
background-image: linear-gradient(in oklch specified hue to right, oklch(45.2% 0.313 264.1deg), oklch(72.26% 0.242 142.6deg)); | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="gradient"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style> | ||
div { | ||
width: 400px; | ||
height: 100px; | ||
display: inline-block; | ||
} | ||
|
||
/* Ensures that when using the "specified" hue interpolation method that values < 0 and greater than 360 are respected and not normalized to the [0, 360] range. */ | ||
|
||
#gradient { | ||
background-image: linear-gradient(in oklch specified hue to right, oklch(45.2% 0.313 -95.9deg), oklch(72.26% 0.242 502.6deg)); | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="gradient"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.