Title: [286925] trunk
Revision
286925
Author
wei...@apple.com
Date
2021-12-12 09:31:36 -0800 (Sun, 12 Dec 2021)

Log Message

Pipe ColorInterpolationMethod into Gradient
https://bugs.webkit.org/show_bug.cgi?id=234205

Reviewed by Antti Koivisto.

Source/WebCore:

There is no functional change yet, this just adds a required ColorInterpolationMethod parameter to
Gradient, which for the moment has to be SRGB and non-premultiplied alpha. Subsequent changes will
support for specifying an interpolation method via CSS gradients as well as implementing support
for that in the platform gradient backends.

Also moves the ColorInterpolationMethod struct into its own file as it was getting quite long.

* Headers.cmake:
* WebCore.xcodeproj/project.pbxproj:
* css/CSSGradientValue.cpp:
(WebCore::CSSGradientValue::equals const):
(WebCore::CSSLinearGradientValue::createGradient):
(WebCore::CSSRadialGradientValue::createGradient):
(WebCore::CSSConicGradientValue::createGradient):
* css/CSSGradientValue.h:
(WebCore::CSSGradientValue::CSSGradientValue):
(WebCore::CSSGradientValue::colorInterpolationMethod const):
* css/parser/CSSPropertyParserHelpers.cpp:
(WebCore::CSSPropertyParserHelpers::consumeDeprecatedGradient):
(WebCore::CSSPropertyParserHelpers::consumeDeprecatedRadialGradient):
(WebCore::CSSPropertyParserHelpers::consumeRadialGradient):
(WebCore::CSSPropertyParserHelpers::consumeLinearGradient):
(WebCore::CSSPropertyParserHelpers::consumeConicGradient):
* html/HTMLInputElement.cpp:
(WebCore::autoFillStrongPasswordMaskImage):
* html/canvas/CanvasGradient.cpp:
(WebCore::CanvasGradient::CanvasGradient):
* platform/graphics/ColorInterpolation.h:
(WebCore::interpolateColorComponents):
(WebCore::ColorInterpolationMethod::encode const): Deleted.
(WebCore::ColorInterpolationMethod::decode): Deleted.
* platform/graphics/ColorInterpolationMethod.h: Added.
(WebCore::ColorInterpolationMethod::encode const):
(WebCore::ColorInterpolationMethod::decode):
(WebCore::add):
(WebCore::operator==):
* platform/graphics/Gradient.cpp:
(WebCore::Gradient::create):
(WebCore::Gradient::Gradient):
(WebCore::Gradient::hash const):
* platform/graphics/Gradient.h:
(WebCore::Gradient::encode const):
(WebCore::Gradient::decode):
* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::paintProgressBar):
(WebCore::RenderThemeIOS::checkboxRadioBackgroundGradient):
(WebCore::RenderThemeIOS::paintColorWellDecorations):
* rendering/svg/RenderSVGResourceLinearGradient.cpp:
(WebCore::RenderSVGResourceLinearGradient::buildGradient const):
* rendering/svg/RenderSVGResourceRadialGradient.cpp:
(WebCore::RenderSVGResourceRadialGradient::buildGradient const):

Tools:

Update calls to Gradient::create() to pass the now required ColorInterpolationMethod.

* TestWebKitAPI/Tests/WebCore/DisplayListTests.cpp:
(TestWebKitAPI::createGradient):
* TestWebKitAPI/Tests/WebCore/cg/BifurcatedGraphicsContextTestsCG.cpp:
(TestWebKitAPI::TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (286924 => 286925)


--- trunk/Source/WebCore/ChangeLog	2021-12-12 17:29:45 UTC (rev 286924)
+++ trunk/Source/WebCore/ChangeLog	2021-12-12 17:31:36 UTC (rev 286925)
@@ -1,3 +1,62 @@
+2021-12-12  Sam Weinig  <wei...@apple.com>
+
+        Pipe ColorInterpolationMethod into Gradient
+        https://bugs.webkit.org/show_bug.cgi?id=234205
+
+        Reviewed by Antti Koivisto.
+
+        There is no functional change yet, this just adds a required ColorInterpolationMethod parameter to
+        Gradient, which for the moment has to be SRGB and non-premultiplied alpha. Subsequent changes will
+        support for specifying an interpolation method via CSS gradients as well as implementing support
+        for that in the platform gradient backends.
+
+        Also moves the ColorInterpolationMethod struct into its own file as it was getting quite long.
+
+        * Headers.cmake:
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/CSSGradientValue.cpp:
+        (WebCore::CSSGradientValue::equals const):
+        (WebCore::CSSLinearGradientValue::createGradient):
+        (WebCore::CSSRadialGradientValue::createGradient):
+        (WebCore::CSSConicGradientValue::createGradient):
+        * css/CSSGradientValue.h:
+        (WebCore::CSSGradientValue::CSSGradientValue):
+        (WebCore::CSSGradientValue::colorInterpolationMethod const):
+        * css/parser/CSSPropertyParserHelpers.cpp:
+        (WebCore::CSSPropertyParserHelpers::consumeDeprecatedGradient):
+        (WebCore::CSSPropertyParserHelpers::consumeDeprecatedRadialGradient):
+        (WebCore::CSSPropertyParserHelpers::consumeRadialGradient):
+        (WebCore::CSSPropertyParserHelpers::consumeLinearGradient):
+        (WebCore::CSSPropertyParserHelpers::consumeConicGradient):
+        * html/HTMLInputElement.cpp:
+        (WebCore::autoFillStrongPasswordMaskImage):
+        * html/canvas/CanvasGradient.cpp:
+        (WebCore::CanvasGradient::CanvasGradient):
+        * platform/graphics/ColorInterpolation.h:
+        (WebCore::interpolateColorComponents):
+        (WebCore::ColorInterpolationMethod::encode const): Deleted.
+        (WebCore::ColorInterpolationMethod::decode): Deleted.
+        * platform/graphics/ColorInterpolationMethod.h: Added.
+        (WebCore::ColorInterpolationMethod::encode const):
+        (WebCore::ColorInterpolationMethod::decode):
+        (WebCore::add):
+        (WebCore::operator==):
+        * platform/graphics/Gradient.cpp:
+        (WebCore::Gradient::create):
+        (WebCore::Gradient::Gradient):
+        (WebCore::Gradient::hash const):
+        * platform/graphics/Gradient.h:
+        (WebCore::Gradient::encode const):
+        (WebCore::Gradient::decode):
+        * rendering/RenderThemeIOS.mm:
+        (WebCore::RenderThemeIOS::paintProgressBar):
+        (WebCore::RenderThemeIOS::checkboxRadioBackgroundGradient):
+        (WebCore::RenderThemeIOS::paintColorWellDecorations):
+        * rendering/svg/RenderSVGResourceLinearGradient.cpp:
+        (WebCore::RenderSVGResourceLinearGradient::buildGradient const):
+        * rendering/svg/RenderSVGResourceRadialGradient.cpp:
+        (WebCore::RenderSVGResourceRadialGradient::buildGradient const):
+
 2021-12-11  Don Olmstead  <don.olmst...@sony.com>
 
         SharedBuffer should use WTF::FileSystem when creating from a file

Modified: trunk/Source/WebCore/Headers.cmake (286924 => 286925)


--- trunk/Source/WebCore/Headers.cmake	2021-12-12 17:29:45 UTC (rev 286924)
+++ trunk/Source/WebCore/Headers.cmake	2021-12-12 17:31:36 UTC (rev 286925)
@@ -1400,6 +1400,7 @@
     platform/graphics/ColorConversion.h
     platform/graphics/ColorHash.h
     platform/graphics/ColorInterpolation.h
+    platform/graphics/ColorInterpolationMethod.h
     platform/graphics/ColorLuminance.h
     platform/graphics/ColorMatrix.h
     platform/graphics/ColorModels.h

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (286924 => 286925)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-12-12 17:29:45 UTC (rev 286924)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-12-12 17:31:36 UTC (rev 286925)
@@ -1254,8 +1254,8 @@
 		436708DF12D9CA4B00044234 /* RenderSVGResourcePattern.h in Headers */ = {isa = PBXBuildFile; fileRef = 436708A012D9CA4B00044234 /* RenderSVGResourcePattern.h */; };
 		436708E112D9CA4B00044234 /* RenderSVGResourceRadialGradient.h in Headers */ = {isa = PBXBuildFile; fileRef = 436708A212D9CA4B00044234 /* RenderSVGResourceRadialGradient.h */; };
 		436708E312D9CA4B00044234 /* RenderSVGResourceSolidColor.h in Headers */ = {isa = PBXBuildFile; fileRef = 436708A412D9CA4B00044234 /* RenderSVGResourceSolidColor.h */; };
+		436708E512D9CA4B00044234 /* LegacyRenderSVGRoot.h in Headers */ = {isa = PBXBuildFile; fileRef = 436708A612D9CA4B00044234 /* LegacyRenderSVGRoot.h */; };
 		436708E512D9DB4B00044234 /* RenderSVGRoot.h in Headers */ = {isa = PBXBuildFile; fileRef = 436708A612D9DB4B00044234 /* RenderSVGRoot.h */; };
-		436708E512D9CA4B00044234 /* LegacyRenderSVGRoot.h in Headers */ = {isa = PBXBuildFile; fileRef = 436708A612D9CA4B00044234 /* LegacyRenderSVGRoot.h */; };
 		436708E912D9CA4B00044234 /* RenderSVGTransformableContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 436708AA12D9CA4B00044234 /* RenderSVGTransformableContainer.h */; };
 		436708EB12D9CA4B00044234 /* RenderSVGViewportContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 436708AC12D9CA4B00044234 /* RenderSVGViewportContainer.h */; };
 		436708EE12D9CA4B00044234 /* SVGMarkerData.h in Headers */ = {isa = PBXBuildFile; fileRef = 436708AF12D9CA4B00044234 /* SVGMarkerData.h */; };
@@ -4095,6 +4095,7 @@
 		BC2B41312734A08600A2D191 /* DummyModelPlayerProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = BC2B412027335CB900A2D191 /* DummyModelPlayerProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		BC2CBF4E140F1ABD003879BE /* JSWebGLContextEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = BC2CBF4B140F1A65003879BE /* JSWebGLContextEvent.h */; };
 		BC2CCA102655DDB200B8C035 /* DestinationColorSpace.h in Headers */ = {isa = PBXBuildFile; fileRef = BC2CCA0E2655DDB200B8C035 /* DestinationColorSpace.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		BC2EE8EA2765943A0077768B /* ColorInterpolationMethod.h in Headers */ = {isa = PBXBuildFile; fileRef = BC2EE8E82765942A0077768B /* ColorInterpolationMethod.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		BC305C7A0C076BB300CD20F0 /* JSHTMLObjectElement.h in Headers */ = {isa = PBXBuildFile; fileRef = BC305C780C076BB300CD20F0 /* JSHTMLObjectElement.h */; };
 		BC348BD40DB7F804004ABAB9 /* JSXMLHttpRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = BC348BD20DB7F804004ABAB9 /* JSXMLHttpRequest.h */; };
 		BC348BD40DB7F804004ABABA /* WebCoreJSBuiltins.h in Headers */ = {isa = PBXBuildFile; fileRef = BC348BD20DB7F804004ABABA /* WebCoreJSBuiltins.h */; };
@@ -8986,10 +8987,10 @@
 		436708A212D9CA4B00044234 /* RenderSVGResourceRadialGradient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGResourceRadialGradient.h; sourceTree = "<group>"; };
 		436708A312D9CA4B00044234 /* RenderSVGResourceSolidColor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGResourceSolidColor.cpp; sourceTree = "<group>"; };
 		436708A412D9CA4B00044234 /* RenderSVGResourceSolidColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGResourceSolidColor.h; sourceTree = "<group>"; };
+		436708A512D9CA4B00044234 /* LegacyRenderSVGRoot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LegacyRenderSVGRoot.cpp; sourceTree = "<group>"; };
 		436708A512D9CA5C00044234 /* RenderSVGRoot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGRoot.cpp; sourceTree = "<group>"; };
+		436708A612D9CA4B00044234 /* LegacyRenderSVGRoot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LegacyRenderSVGRoot.h; sourceTree = "<group>"; };
 		436708A612D9DB4B00044234 /* RenderSVGRoot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGRoot.h; sourceTree = "<group>"; };
-		436708A512D9CA4B00044234 /* LegacyRenderSVGRoot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LegacyRenderSVGRoot.cpp; sourceTree = "<group>"; };
-		436708A612D9CA4B00044234 /* LegacyRenderSVGRoot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LegacyRenderSVGRoot.h; sourceTree = "<group>"; };
 		436708A912D9CA4B00044234 /* RenderSVGTransformableContainer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGTransformableContainer.cpp; sourceTree = "<group>"; };
 		436708AA12D9CA4B00044234 /* RenderSVGTransformableContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGTransformableContainer.h; sourceTree = "<group>"; };
 		436708AB12D9CA4B00044234 /* RenderSVGViewportContainer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGViewportContainer.cpp; sourceTree = "<group>"; };
@@ -10475,14 +10476,6 @@
 		5B7AB9F62567DB7E006592D0 /* ScrollSnapOffsetsInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollSnapOffsetsInfo.cpp; sourceTree = "<group>"; };
 		5B92C4292716E23300A37CC0 /* ScrollingTreeStickyNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollingTreeStickyNode.cpp; sourceTree = "<group>"; };
 		5B92C42B2716E23300A37CC0 /* ScrollingTreeStickyNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollingTreeStickyNode.h; sourceTree = "<group>"; };
-		5C1B1D1E26F15B1900882DA2 /* SharedWorkerGlobalScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedWorkerGlobalScope.cpp; sourceTree = "<group>"; };
-		5C1B1D2026F15B1A00882DA2 /* SharedWorker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedWorker.cpp; sourceTree = "<group>"; };
-		5C1B1D2126F15B1A00882DA2 /* SharedWorkerGlobalScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedWorkerGlobalScope.h; sourceTree = "<group>"; };
-		5C1B1D2226F15B1A00882DA2 /* SharedWorkerGlobalScope.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SharedWorkerGlobalScope.idl; sourceTree = "<group>"; };
-		5C1B1D2326F15B1A00882DA2 /* SharedWorker.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SharedWorker.idl; sourceTree = "<group>"; };
-		5C1B1D2426F15B1A00882DA2 /* SharedWorker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedWorker.h; sourceTree = "<group>"; };
-		5C001521250011000094AA93 /* TextCodecSingleByte.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextCodecSingleByte.cpp; sourceTree = "<group>"; };
-		5C001523250011010094AA93 /* TextCodecSingleByte.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextCodecSingleByte.h; sourceTree = "<group>"; };
 		5C1B1D2526F188D800882DA2 /* WorkerOptions.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WorkerOptions.idl; sourceTree = "<group>"; };
 		5C1B1D2626F18A4B00882DA2 /* WorkerOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkerOptions.h; sourceTree = "<group>"; };
 		5C1B1D3D26F3977F00882DA2 /* ResourceLoaderIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoaderIdentifier.h; sourceTree = "<group>"; };
@@ -15143,6 +15136,7 @@
 		BC2CCA0F2655DDB200B8C035 /* DestinationColorSpace.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DestinationColorSpace.cpp; sourceTree = "<group>"; };
 		BC2ED5540C6B9BD300920BFF /* JSElementCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSElementCustom.cpp; sourceTree = "<group>"; };
 		BC2ED6BB0C6BD2F000920BFF /* JSAttrCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAttrCustom.cpp; sourceTree = "<group>"; };
+		BC2EE8E82765942A0077768B /* ColorInterpolationMethod.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ColorInterpolationMethod.h; sourceTree = "<group>"; };
 		BC305C770C076BB300CD20F0 /* JSHTMLObjectElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLObjectElement.cpp; sourceTree = "<group>"; };
 		BC305C780C076BB300CD20F0 /* JSHTMLObjectElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLObjectElement.h; sourceTree = "<group>"; };
 		BC33FB1A0F30EE85002CDD7C /* RenderLineBoxList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderLineBoxList.cpp; sourceTree = "<group>"; };
@@ -28617,6 +28611,7 @@
 				3103B7DE1DB01556008BB890 /* ColorHash.h */,
 				BCDC642427517B040038FB39 /* ColorInterpolation.cpp */,
 				BCDC642527517B040038FB39 /* ColorInterpolation.h */,
+				BC2EE8E82765942A0077768B /* ColorInterpolationMethod.h */,
 				BC6EB84526266B61003225A7 /* ColorLuminance.cpp */,
 				BC4A23EB25EC160200AAC630 /* ColorLuminance.h */,
 				7CAC6AE8247F082000E61D59 /* ColorMatrix.h */,
@@ -33570,6 +33565,7 @@
 				3103B7DF1DB01567008BB890 /* ColorHash.h in Headers */,
 				F55B3DB41251F12D003EF269 /* ColorInputType.h in Headers */,
 				BC3A00C82754496D0047C0E5 /* ColorInterpolation.h in Headers */,
+				BC2EE8EA2765943A0077768B /* ColorInterpolationMethod.h in Headers */,
 				BC4A23EC25EC160200AAC630 /* ColorLuminance.h in Headers */,
 				EDE3A5000C7A430600956A37 /* ColorMac.h in Headers */,
 				7CAC6AE9247F082F00E61D59 /* ColorMatrix.h in Headers */,

Modified: trunk/Source/WebCore/css/CSSGradientValue.cpp (286924 => 286925)


--- trunk/Source/WebCore/css/CSSGradientValue.cpp	2021-12-12 17:29:45 UTC (rev 286924)
+++ trunk/Source/WebCore/css/CSSGradientValue.cpp	2021-12-12 17:31:36 UTC (rev 286925)
@@ -657,7 +657,8 @@
         && compareCSSValuePtr(m_secondY, other.m_secondY)
         && m_stops == other.m_stops
         && m_gradientType == other.m_gradientType
-        && m_repeating == other.m_repeating;
+        && m_repeating == other.m_repeating
+        && m_colorInterpolationMethod == other.m_colorInterpolationMethod;
 }
 
 static void appendGradientStops(StringBuilder& builder, const Vector<CSSGradientColorStop, 2>& stops)
@@ -871,7 +872,7 @@
     LinearGradientAdapter adapter { data };
     auto stops = computeStops(adapter, conversionData, renderer.style(), 1);
 
-    auto gradient = Gradient::create(WTFMove(data));
+    auto gradient = Gradient::create(WTFMove(data), colorInterpolationMethod());
     gradient->setSortedColorStops(WTFMove(stops));
     return gradient;
 }
@@ -1205,7 +1206,7 @@
     RadialGradientAdapter adapter { data };
     auto stops = computeStops(adapter, conversionData, renderer.style(), maxExtent);
 
-    auto gradient = Gradient::create(WTFMove(data));
+    auto gradient = Gradient::create(WTFMove(data), colorInterpolationMethod());
     gradient->setSortedColorStops(WTFMove(stops));
     return gradient;
 }
@@ -1279,7 +1280,7 @@
     ConicGradientAdapter adapter;
     auto stops = computeStops(adapter, conversionData, renderer.style(), 1);
 
-    auto gradient = Gradient::create(WTFMove(data));
+    auto gradient = Gradient::create(WTFMove(data), colorInterpolationMethod());
     gradient->setSortedColorStops(WTFMove(stops));
     return gradient;
 }

Modified: trunk/Source/WebCore/css/CSSGradientValue.h (286924 => 286925)


--- trunk/Source/WebCore/css/CSSGradientValue.h	2021-12-12 17:29:45 UTC (rev 286924)
+++ trunk/Source/WebCore/css/CSSGradientValue.h	2021-12-12 17:31:36 UTC (rev 286925)
@@ -27,6 +27,7 @@
 
 #include "CSSImageGeneratorValue.h"
 #include "CSSPrimitiveValue.h"
+#include "ColorInterpolationMethod.h"
 #include "Gradient.h"
 
 namespace WebCore {
@@ -81,10 +82,11 @@
     Ref<CSSGradientValue> valueWithStylesResolved(Style::BuilderState&);
 
 protected:
-    CSSGradientValue(ClassType classType, CSSGradientRepeat repeat, CSSGradientType gradientType)
+    CSSGradientValue(ClassType classType, CSSGradientRepeat repeat, CSSGradientType gradientType, ColorInterpolationMethod colorInterpolationMethod)
         : CSSImageGeneratorValue(classType)
         , m_gradientType(gradientType)
         , m_repeating(repeat == Repeating)
+        , m_colorInterpolationMethod(colorInterpolationMethod)
     {
     }
 
@@ -97,6 +99,7 @@
         , m_stops(other.m_stops)
         , m_gradientType(other.m_gradientType)
         , m_repeating(other.m_repeating)
+        , m_colorInterpolationMethod(other.m_colorInterpolationMethod)
         , m_hasColorDerivedFromElement(other.m_hasColorDerivedFromElement)
     {
     }
@@ -109,6 +112,7 @@
     auto secondY() const { return m_secondY.get(); }
     auto& stops() const { return m_stops; }
     bool isRepeating() const { return m_repeating; }
+    auto colorInterpolationMethod() const { return m_colorInterpolationMethod; }
 
     bool equals(const CSSGradientValue&) const;
 
@@ -123,6 +127,7 @@
     Vector<CSSGradientColorStop, 2> m_stops;
     CSSGradientType m_gradientType;
     bool m_repeating { false };
+    ColorInterpolationMethod m_colorInterpolationMethod;
 
     mutable std::optional<bool> m_hasColorDerivedFromElement;
 };
@@ -129,9 +134,9 @@
 
 class CSSLinearGradientValue final : public CSSGradientValue {
 public:
-    static Ref<CSSLinearGradientValue> create(CSSGradientRepeat repeat, CSSGradientType gradientType = CSSLinearGradient)
+    static Ref<CSSLinearGradientValue> create(CSSGradientRepeat repeat, CSSGradientType gradientType, ColorInterpolationMethod colorInterpolationMethod)
     {
-        return adoptRef(*new CSSLinearGradientValue(repeat, gradientType));
+        return adoptRef(*new CSSLinearGradientValue(repeat, gradientType, colorInterpolationMethod));
     }
 
     void setAngle(Ref<CSSPrimitiveValue>&& value) { m_angle = WTFMove(value); }
@@ -149,8 +154,8 @@
     bool equals(const CSSLinearGradientValue&) const;
 
 private:
-    CSSLinearGradientValue(CSSGradientRepeat repeat, CSSGradientType gradientType = CSSLinearGradient)
-        : CSSGradientValue(LinearGradientClass, repeat, gradientType)
+    CSSLinearGradientValue(CSSGradientRepeat repeat, CSSGradientType gradientType, ColorInterpolationMethod colorInterpolationMethod)
+        : CSSGradientValue(LinearGradientClass, repeat, gradientType, colorInterpolationMethod)
     {
     }
 
@@ -165,9 +170,9 @@
 
 class CSSRadialGradientValue final : public CSSGradientValue {
 public:
-    static Ref<CSSRadialGradientValue> create(CSSGradientRepeat repeat, CSSGradientType gradientType = CSSRadialGradient)
+    static Ref<CSSRadialGradientValue> create(CSSGradientRepeat repeat, CSSGradientType gradientType, ColorInterpolationMethod colorInterpolationMethod)
     {
-        return adoptRef(*new CSSRadialGradientValue(repeat, gradientType));
+        return adoptRef(*new CSSRadialGradientValue(repeat, gradientType, colorInterpolationMethod));
     }
 
     Ref<CSSRadialGradientValue> clone() const
@@ -192,8 +197,8 @@
     bool equals(const CSSRadialGradientValue&) const;
 
 private:
-    CSSRadialGradientValue(CSSGradientRepeat repeat, CSSGradientType gradientType = CSSRadialGradient)
-        : CSSGradientValue(RadialGradientClass, repeat, gradientType)
+    CSSRadialGradientValue(CSSGradientRepeat repeat, CSSGradientType gradientType, ColorInterpolationMethod colorInterpolationMethod)
+        : CSSGradientValue(RadialGradientClass, repeat, gradientType, colorInterpolationMethod)
     {
     }
 
@@ -225,9 +230,9 @@
 
 class CSSConicGradientValue final : public CSSGradientValue {
 public:
-    static Ref<CSSConicGradientValue> create(CSSGradientRepeat repeat)
+    static Ref<CSSConicGradientValue> create(CSSGradientRepeat repeat, ColorInterpolationMethod colorInterpolationMethod)
     {
-        return adoptRef(*new CSSConicGradientValue(repeat));
+        return adoptRef(*new CSSConicGradientValue(repeat, colorInterpolationMethod));
     }
 
     Ref<CSSConicGradientValue> clone() const
@@ -245,8 +250,8 @@
     bool equals(const CSSConicGradientValue&) const;
 
 private:
-    explicit CSSConicGradientValue(CSSGradientRepeat repeat)
-        : CSSGradientValue(ConicGradientClass, repeat, CSSConicGradient)
+    explicit CSSConicGradientValue(CSSGradientRepeat repeat, ColorInterpolationMethod colorInterpolationMethod)
+        : CSSGradientValue(ConicGradientClass, repeat, CSSConicGradient, colorInterpolationMethod)
     {
     }
 

Modified: trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp (286924 => 286925)


--- trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp	2021-12-12 17:29:45 UTC (rev 286924)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp	2021-12-12 17:31:36 UTC (rev 286925)
@@ -2952,9 +2952,9 @@
     CSSValueID id = args.consumeIncludingWhitespace().id();
     bool isDeprecatedRadialGradient = (id == CSSValueRadial);
     if (isDeprecatedRadialGradient)
-        result = CSSRadialGradientValue::create(NonRepeating, CSSDeprecatedRadialGradient);
+        result = CSSRadialGradientValue::create(NonRepeating, CSSDeprecatedRadialGradient, { ColorInterpolationMethod::SRGB { }, AlphaPremultiplication::Unpremultiplied });
     else if (id == CSSValueLinear)
-        result = CSSLinearGradientValue::create(NonRepeating, CSSDeprecatedLinearGradient);
+        result = CSSLinearGradientValue::create(NonRepeating, CSSDeprecatedLinearGradient, { ColorInterpolationMethod::SRGB { }, AlphaPremultiplication::Unpremultiplied });
     if (!result || !consumeCommaIncludingWhitespace(args))
         return nullptr;
 
@@ -3054,7 +3054,7 @@
 
 static RefPtr<CSSValue> consumeDeprecatedRadialGradient(CSSParserTokenRange& args, const CSSParserContext& context, CSSGradientRepeat repeating)
 {
-    auto result = CSSRadialGradientValue::create(repeating, CSSPrefixedRadialGradient);
+    auto result = CSSRadialGradientValue::create(repeating, CSSPrefixedRadialGradient, { ColorInterpolationMethod::SRGB { }, AlphaPremultiplication::Unpremultiplied });
 
     auto centerCoordinate = consumeOneOrTwoValuedPositionCoordinates(args, context.mode, UnitlessQuirk::Forbid);
     if (centerCoordinate && !consumeCommaIncludingWhitespace(args))
@@ -3098,7 +3098,7 @@
 
 static RefPtr<CSSValue> consumeRadialGradient(CSSParserTokenRange& args, const CSSParserContext& context, CSSGradientRepeat repeating)
 {
-    RefPtr<CSSRadialGradientValue> result = CSSRadialGradientValue::create(repeating, CSSRadialGradient);
+    RefPtr<CSSRadialGradientValue> result = CSSRadialGradientValue::create(repeating, CSSRadialGradient, { ColorInterpolationMethod::SRGB { }, AlphaPremultiplication::Unpremultiplied });
 
     RefPtr<CSSPrimitiveValue> shape;
     RefPtr<CSSPrimitiveValue> sizeKeyword;
@@ -3186,7 +3186,7 @@
 
 static RefPtr<CSSValue> consumeLinearGradient(CSSParserTokenRange& args, const CSSParserContext& context, CSSGradientRepeat repeating, CSSGradientType gradientType)
 {
-    RefPtr<CSSLinearGradientValue> result = CSSLinearGradientValue::create(repeating, gradientType);
+    RefPtr<CSSLinearGradientValue> result = CSSLinearGradientValue::create(repeating, gradientType, { ColorInterpolationMethod::SRGB { }, AlphaPremultiplication::Unpremultiplied });
 
     bool expectComma = true;
     RefPtr<CSSPrimitiveValue> angle = consumeAngle(args, context.mode, UnitlessQuirk::Forbid, UnitlessZeroQuirk::Allow);
@@ -3220,7 +3220,7 @@
 static RefPtr<CSSValue> consumeConicGradient(CSSParserTokenRange& args, const CSSParserContext& context, CSSGradientRepeat repeating)
 {
 #if ENABLE(CSS_CONIC_GRADIENTS)
-    RefPtr<CSSConicGradientValue> result = CSSConicGradientValue::create(repeating);
+    RefPtr<CSSConicGradientValue> result = CSSConicGradientValue::create(repeating, { ColorInterpolationMethod::SRGB { }, AlphaPremultiplication::Unpremultiplied });
 
     bool expectComma = false;
     if (args.peek().type() == IdentToken) {

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (286924 => 286925)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2021-12-12 17:29:45 UTC (rev 286924)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2021-12-12 17:31:36 UTC (rev 286925)
@@ -2139,7 +2139,7 @@
     secondStop.color = CSSValuePool::singleton().createColorValue(Color::transparentBlack);
     secondStop.position = CSSValuePool::singleton().createValue(100, CSSUnitType::CSS_PERCENTAGE);
 
-    auto gradient = CSSLinearGradientValue::create(CSSGradientRepeat::NonRepeating, CSSGradientType::CSSLinearGradient);
+    auto gradient = CSSLinearGradientValue::create(CSSGradientRepeat::NonRepeating, CSSGradientType::CSSLinearGradient, { ColorInterpolationMethod::SRGB { }, AlphaPremultiplication::Unpremultiplied });
     gradient->setAngle(CSSValuePool::singleton().createValue(90, CSSUnitType::CSS_DEG));
     gradient->addStop(WTFMove(firstStop));
     gradient->addStop(WTFMove(secondStop));

Modified: trunk/Source/WebCore/html/canvas/CanvasGradient.cpp (286924 => 286925)


--- trunk/Source/WebCore/html/canvas/CanvasGradient.cpp	2021-12-12 17:29:45 UTC (rev 286924)
+++ trunk/Source/WebCore/html/canvas/CanvasGradient.cpp	2021-12-12 17:31:36 UTC (rev 286925)
@@ -34,19 +34,19 @@
 namespace WebCore {
 
 CanvasGradient::CanvasGradient(const FloatPoint& p0, const FloatPoint& p1, CanvasBase& canvasBase)
-    : m_gradient(Gradient::create(Gradient::LinearData { p0, p1 }))
+    : m_gradient(Gradient::create(Gradient::LinearData { p0, p1 }, { ColorInterpolationMethod::SRGB { }, AlphaPremultiplication::Unpremultiplied }))
     , m_canvas(canvasBase)
 {
 }
 
 CanvasGradient::CanvasGradient(const FloatPoint& p0, float r0, const FloatPoint& p1, float r1, CanvasBase& canvasBase)
-    : m_gradient(Gradient::create(Gradient::RadialData { p0, p1, r0, r1, 1 }))
+    : m_gradient(Gradient::create(Gradient::RadialData { p0, p1, r0, r1, 1 }, { ColorInterpolationMethod::SRGB { }, AlphaPremultiplication::Unpremultiplied }))
     , m_canvas(canvasBase)
 {
 }
 
 CanvasGradient::CanvasGradient(const FloatPoint& centerPoint, float angleInRadians, CanvasBase& canvasBase)
-    : m_gradient(Gradient::create(Gradient::ConicData { centerPoint, angleInRadians }))
+    : m_gradient(Gradient::create(Gradient::ConicData { centerPoint, angleInRadians }, { ColorInterpolationMethod::SRGB { }, AlphaPremultiplication::Unpremultiplied }))
     , m_canvas(canvasBase)
 {
 }

Modified: trunk/Source/WebCore/platform/graphics/ColorInterpolation.h (286924 => 286925)


--- trunk/Source/WebCore/platform/graphics/ColorInterpolation.h	2021-12-12 17:29:45 UTC (rev 286924)
+++ trunk/Source/WebCore/platform/graphics/ColorInterpolation.h	2021-12-12 17:31:36 UTC (rev 286925)
@@ -26,88 +26,14 @@
 #pragma once
 
 #include "AlphaPremultiplication.h"
+#include "ColorInterpolationMethod.h"
+#include "ColorNormalization.h"
 #include "ColorTypes.h"
-#include "ColorNormalization.h"
-#include <optional>
-#include <variant>
-#include <wtf/EnumTraits.h>
 
 namespace WebCore {
 
-enum class HueInterpolationMethod : uint8_t {
-    Shorter,
-    Longer,
-    Increasing,
-    Decreasing,
-    Specified
-};
+// MARK: - Pre-interpolation normalization/fixup
 
-enum class ColorInterpolationColorSpace : uint8_t {
-    HSL,
-    HWB,
-    LCH,
-    Lab,
-    OKLCH,
-    OKLab,
-    SRGB,
-    SRGBLinear,
-    XYZD50,
-    XYZD65
-};
-    
-struct ColorInterpolationMethod {
-    struct HSL {
-        static constexpr auto interpolationColorSpace = ColorInterpolationColorSpace::HSL;
-        using ColorType = WebCore::HSLA<float>;
-        HueInterpolationMethod hueInterpolationMethod = HueInterpolationMethod::Shorter;
-    };
-    struct HWB {
-        static constexpr auto interpolationColorSpace = ColorInterpolationColorSpace::HWB;
-        using ColorType = WebCore::HWBA<float>;
-        HueInterpolationMethod hueInterpolationMethod = HueInterpolationMethod::Shorter;
-    };
-    struct LCH {
-        static constexpr auto interpolationColorSpace = ColorInterpolationColorSpace::LCH;
-        using ColorType = WebCore::LCHA<float>;
-        HueInterpolationMethod hueInterpolationMethod = HueInterpolationMethod::Shorter;
-    };
-    struct Lab {
-        static constexpr auto interpolationColorSpace = ColorInterpolationColorSpace::Lab;
-        using ColorType = WebCore::Lab<float>;
-    };
-    struct OKLCH {
-        static constexpr auto interpolationColorSpace = ColorInterpolationColorSpace::OKLCH;
-        using ColorType = WebCore::OKLCHA<float>;
-        HueInterpolationMethod hueInterpolationMethod = HueInterpolationMethod::Shorter;
-    };
-    struct OKLab {
-        static constexpr auto interpolationColorSpace = ColorInterpolationColorSpace::OKLab;
-        using ColorType = WebCore::OKLab<float>;
-    };
-    struct SRGB {
-        static constexpr auto interpolationColorSpace = ColorInterpolationColorSpace::SRGB;
-        using ColorType = WebCore::SRGBA<float>;
-    };
-    struct SRGBLinear {
-        static constexpr auto interpolationColorSpace = ColorInterpolationColorSpace::SRGBLinear;
-        using ColorType = WebCore::LinearSRGBA<float>;
-    };
-    struct XYZD50 {
-        static constexpr auto interpolationColorSpace = ColorInterpolationColorSpace::XYZD50;
-        using ColorType = WebCore::XYZA<float, WhitePoint::D50>;
-    };
-    struct XYZD65 {
-        static constexpr auto interpolationColorSpace = ColorInterpolationColorSpace::XYZD65;
-        using ColorType = WebCore::XYZA<float, WhitePoint::D65>;
-    };
-
-    template<typename Encoder> void encode(Encoder&) const;
-    template<typename Decoder> static std::optional<ColorInterpolationMethod> decode(Decoder&);
-
-    std::variant<HSL, HWB, LCH, Lab, OKLCH, OKLab, SRGB, SRGBLinear, XYZD50, XYZD65> colorSpace;
-    AlphaPremultiplication alphaPremultiplication;
-};
-
 std::pair<float, float> fixupHueComponentsPriorToInterpolation(HueInterpolationMethod, float, float);
 
 template<size_t I, AlphaPremultiplication alphaPremultiplication, typename InterpolationMethod>
@@ -139,6 +65,9 @@
     };
 }
 
+
+// MARK: - Post-interpolation normalization/fixup
+
 template<size_t I, AlphaPremultiplication alphaPremultiplication, typename InterpolationMethod>
 float postInterpolationNormalizationForComponent(InterpolationMethod, ColorComponents<float, 4> colorComponents)
 {
@@ -164,126 +93,25 @@
     };
  }
 
+
+// MARK: - Interpolation
+
 template<AlphaPremultiplication alphaPremultiplication, typename InterpolationMethod>
 typename InterpolationMethod::ColorType interpolateColorComponents(InterpolationMethod interpolationMethod, typename InterpolationMethod::ColorType color1, double color1Multiplier, typename InterpolationMethod::ColorType color2, double color2Multiplier)
 {
+    // 1. Apply pre-interpolation transforms (hue fixup for polar color spaces, alpha premultiplication if required).
     auto [normalizedColorComponents1, normalizedColorComponents2] = preInterpolationNormalization<alphaPremultiplication>(interpolationMethod, asColorComponents(color1), asColorComponents(color2));
 
+    // 2. Interpolate using the normalized components.
     auto interpolatedColorComponents = mapColorComponents([&] (auto componentFromColor1, auto componentFromColor2) -> float {
         return (componentFromColor1 * color1Multiplier) + (componentFromColor2 * color2Multiplier);
     }, normalizedColorComponents1, normalizedColorComponents2);
 
+    // 3. Apply post-interpolation trasforms (alpha un-premultiplication if required).
     auto normalizedInterpolatedColorComponents = postInterpolationNormalization<alphaPremultiplication>(interpolationMethod, interpolatedColorComponents);
 
+    // 4. Create color type from components, normalizing any components that may be out of range.
     return makeColorTypeByNormalizingComponents<typename InterpolationMethod::ColorType>(normalizedInterpolatedColorComponents);
 }
 
-template<typename Encoder> void ColorInterpolationMethod::encode(Encoder& encoder) const
-{
-    encoder << alphaPremultiplication;
-
-    WTF::switchOn(colorSpace,
-        [&] (auto& type) {
-            encoder << type.interpolationColorSpace;
-            if constexpr (decltype(type)::ColorType::Model::coordinateSystem == ColorSpaceCoordinateSystem::CylindricalPolar) {
-                encoder << type.hueInterpolationMethod;
-            }
-        }
-    );
 }
-
-template<typename Decoder> std::optional<ColorInterpolationMethod> ColorInterpolationMethod::decode(Decoder& decoder)
-{
-    std::optional<AlphaPremultiplication> alphaPremultiplication;
-    decoder >> alphaPremultiplication;
-    if (!alphaPremultiplication)
-        return std::nullopt;
-
-    std::optional<ColorInterpolationColorSpace> interpolationColorSpace;
-    decoder >> interpolationColorSpace;
-    if (!interpolationColorSpace)
-        return std::nullopt;
-
-    switch (*interpolationColorSpace) {
-    case ColorInterpolationColorSpace::HSL: {
-        std::optional<HueInterpolationMethod> hueInterpolationMethod;
-        decoder >> hueInterpolationMethod;
-        if (!hueInterpolationMethod)
-            return std::nullopt;
-
-        return ColorInterpolationMethod { ColorInterpolationMethod::HSL { *hueInterpolationMethod }, *alphaPremultiplication };
-    }
-    case ColorInterpolationColorSpace::HWB: {
-        std::optional<HueInterpolationMethod> hueInterpolationMethod;
-        decoder >> hueInterpolationMethod;
-        if (!hueInterpolationMethod)
-            return std::nullopt;
-
-        return ColorInterpolationMethod { ColorInterpolationMethod::HWB { *hueInterpolationMethod }, *alphaPremultiplication };
-    }
-    case ColorInterpolationColorSpace::LCH: {
-        std::optional<HueInterpolationMethod> hueInterpolationMethod;
-        decoder >> hueInterpolationMethod;
-        if (!hueInterpolationMethod)
-            return std::nullopt;
-
-        return ColorInterpolationMethod { ColorInterpolationMethod::LCH { *hueInterpolationMethod }, *alphaPremultiplication };
-    }
-    case ColorInterpolationColorSpace::OKLCH: {
-        std::optional<HueInterpolationMethod> hueInterpolationMethod;
-        decoder >> hueInterpolationMethod;
-        if (!hueInterpolationMethod)
-            return std::nullopt;
-
-        return ColorInterpolationMethod { ColorInterpolationMethod::OKLCH { *hueInterpolationMethod }, *alphaPremultiplication };
-    }
-    case ColorInterpolationColorSpace::Lab:
-        return ColorInterpolationMethod { ColorInterpolationMethod::Lab { }, *alphaPremultiplication };
-    case ColorInterpolationColorSpace::OKLab:
-        return ColorInterpolationMethod { ColorInterpolationMethod::OKLab { }, *alphaPremultiplication };
-    case ColorInterpolationColorSpace::SRGB:
-        return ColorInterpolationMethod { ColorInterpolationMethod::SRGB { }, *alphaPremultiplication };
-    case ColorInterpolationColorSpace::SRGBLinear:
-        return ColorInterpolationMethod { ColorInterpolationMethod::SRGBLinear { }, *alphaPremultiplication };
-    case ColorInterpolationColorSpace::XYZD50:
-        return ColorInterpolationMethod { ColorInterpolationMethod::XYZD50 { }, *alphaPremultiplication };
-    case ColorInterpolationColorSpace::XYZD65:
-        return ColorInterpolationMethod { ColorInterpolationMethod::XYZD65 { }, *alphaPremultiplication };
-    }
-
-    RELEASE_ASSERT_NOT_REACHED();
-    return std::nullopt;
-}
-
-}
-
-namespace WTF {
-
-template<> struct EnumTraits<WebCore::HueInterpolationMethod> {
-    using values = EnumValues<
-        WebCore::HueInterpolationMethod,
-        WebCore::HueInterpolationMethod::Shorter,
-        WebCore::HueInterpolationMethod::Longer,
-        WebCore::HueInterpolationMethod::Increasing,
-        WebCore::HueInterpolationMethod::Decreasing,
-        WebCore::HueInterpolationMethod::Specified
-    >;
-};
-
-template<> struct EnumTraits<WebCore::ColorInterpolationColorSpace> {
-    using values = EnumValues<
-        WebCore::ColorInterpolationColorSpace,
-        WebCore::ColorInterpolationColorSpace::HSL,
-        WebCore::ColorInterpolationColorSpace::HWB,
-        WebCore::ColorInterpolationColorSpace::LCH,
-        WebCore::ColorInterpolationColorSpace::Lab,
-        WebCore::ColorInterpolationColorSpace::OKLCH,
-        WebCore::ColorInterpolationColorSpace::OKLab,
-        WebCore::ColorInterpolationColorSpace::SRGB,
-        WebCore::ColorInterpolationColorSpace::SRGBLinear,
-        WebCore::ColorInterpolationColorSpace::XYZD50,
-        WebCore::ColorInterpolationColorSpace::XYZD65
-    >;
-};
-
-}

Copied: trunk/Source/WebCore/platform/graphics/ColorInterpolationMethod.h (from rev 286924, trunk/Source/WebCore/platform/graphics/ColorInterpolation.h) (0 => 286925)


--- trunk/Source/WebCore/platform/graphics/ColorInterpolationMethod.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/ColorInterpolationMethod.h	2021-12-12 17:31:36 UTC (rev 286925)
@@ -0,0 +1,287 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "AlphaPremultiplication.h"
+#include "ColorTypes.h"
+#include <optional>
+#include <variant>
+#include <wtf/EnumTraits.h>
+#include <wtf/Hasher.h>
+
+namespace WebCore {
+
+enum class HueInterpolationMethod : uint8_t {
+    Shorter,
+    Longer,
+    Increasing,
+    Decreasing,
+    Specified
+};
+
+enum class ColorInterpolationColorSpace : uint8_t {
+    HSL,
+    HWB,
+    LCH,
+    Lab,
+    OKLCH,
+    OKLab,
+    SRGB,
+    SRGBLinear,
+    XYZD50,
+    XYZD65
+};
+    
+struct ColorInterpolationMethod {
+    struct HSL {
+        static constexpr auto interpolationColorSpace = ColorInterpolationColorSpace::HSL;
+        using ColorType = WebCore::HSLA<float>;
+        HueInterpolationMethod hueInterpolationMethod = HueInterpolationMethod::Shorter;
+    };
+    struct HWB {
+        static constexpr auto interpolationColorSpace = ColorInterpolationColorSpace::HWB;
+        using ColorType = WebCore::HWBA<float>;
+        HueInterpolationMethod hueInterpolationMethod = HueInterpolationMethod::Shorter;
+    };
+    struct LCH {
+        static constexpr auto interpolationColorSpace = ColorInterpolationColorSpace::LCH;
+        using ColorType = WebCore::LCHA<float>;
+        HueInterpolationMethod hueInterpolationMethod = HueInterpolationMethod::Shorter;
+    };
+    struct Lab {
+        static constexpr auto interpolationColorSpace = ColorInterpolationColorSpace::Lab;
+        using ColorType = WebCore::Lab<float>;
+    };
+    struct OKLCH {
+        static constexpr auto interpolationColorSpace = ColorInterpolationColorSpace::OKLCH;
+        using ColorType = WebCore::OKLCHA<float>;
+        HueInterpolationMethod hueInterpolationMethod = HueInterpolationMethod::Shorter;
+    };
+    struct OKLab {
+        static constexpr auto interpolationColorSpace = ColorInterpolationColorSpace::OKLab;
+        using ColorType = WebCore::OKLab<float>;
+    };
+    struct SRGB {
+        static constexpr auto interpolationColorSpace = ColorInterpolationColorSpace::SRGB;
+        using ColorType = WebCore::SRGBA<float>;
+    };
+    struct SRGBLinear {
+        static constexpr auto interpolationColorSpace = ColorInterpolationColorSpace::SRGBLinear;
+        using ColorType = WebCore::LinearSRGBA<float>;
+    };
+    struct XYZD50 {
+        static constexpr auto interpolationColorSpace = ColorInterpolationColorSpace::XYZD50;
+        using ColorType = WebCore::XYZA<float, WhitePoint::D50>;
+    };
+    struct XYZD65 {
+        static constexpr auto interpolationColorSpace = ColorInterpolationColorSpace::XYZD65;
+        using ColorType = WebCore::XYZA<float, WhitePoint::D65>;
+    };
+
+    template<typename Encoder> void encode(Encoder&) const;
+    template<typename Decoder> static std::optional<ColorInterpolationMethod> decode(Decoder&);
+
+    std::variant<HSL, HWB, LCH, Lab, OKLCH, OKLab, SRGB, SRGBLinear, XYZD50, XYZD65> colorSpace;
+    AlphaPremultiplication alphaPremultiplication;
+};
+
+template<typename Encoder> void ColorInterpolationMethod::encode(Encoder& encoder) const
+{
+    encoder << alphaPremultiplication;
+
+    WTF::switchOn(colorSpace,
+        [&] (auto& type) {
+            encoder << type.interpolationColorSpace;
+            if constexpr (std::remove_reference_t<decltype(type)>::ColorType::Model::coordinateSystem == ColorSpaceCoordinateSystem::CylindricalPolar) {
+                encoder << type.hueInterpolationMethod;
+            }
+        }
+    );
+}
+
+template<typename Decoder> std::optional<ColorInterpolationMethod> ColorInterpolationMethod::decode(Decoder& decoder)
+{
+    std::optional<AlphaPremultiplication> alphaPremultiplication;
+    decoder >> alphaPremultiplication;
+    if (!alphaPremultiplication)
+        return std::nullopt;
+
+    std::optional<ColorInterpolationColorSpace> interpolationColorSpace;
+    decoder >> interpolationColorSpace;
+    if (!interpolationColorSpace)
+        return std::nullopt;
+
+    switch (*interpolationColorSpace) {
+    case ColorInterpolationColorSpace::HSL: {
+        std::optional<HueInterpolationMethod> hueInterpolationMethod;
+        decoder >> hueInterpolationMethod;
+        if (!hueInterpolationMethod)
+            return std::nullopt;
+
+        return ColorInterpolationMethod { ColorInterpolationMethod::HSL { *hueInterpolationMethod }, *alphaPremultiplication };
+    }
+    case ColorInterpolationColorSpace::HWB: {
+        std::optional<HueInterpolationMethod> hueInterpolationMethod;
+        decoder >> hueInterpolationMethod;
+        if (!hueInterpolationMethod)
+            return std::nullopt;
+
+        return ColorInterpolationMethod { ColorInterpolationMethod::HWB { *hueInterpolationMethod }, *alphaPremultiplication };
+    }
+    case ColorInterpolationColorSpace::LCH: {
+        std::optional<HueInterpolationMethod> hueInterpolationMethod;
+        decoder >> hueInterpolationMethod;
+        if (!hueInterpolationMethod)
+            return std::nullopt;
+
+        return ColorInterpolationMethod { ColorInterpolationMethod::LCH { *hueInterpolationMethod }, *alphaPremultiplication };
+    }
+    case ColorInterpolationColorSpace::OKLCH: {
+        std::optional<HueInterpolationMethod> hueInterpolationMethod;
+        decoder >> hueInterpolationMethod;
+        if (!hueInterpolationMethod)
+            return std::nullopt;
+
+        return ColorInterpolationMethod { ColorInterpolationMethod::OKLCH { *hueInterpolationMethod }, *alphaPremultiplication };
+    }
+    case ColorInterpolationColorSpace::Lab:
+        return ColorInterpolationMethod { ColorInterpolationMethod::Lab { }, *alphaPremultiplication };
+    case ColorInterpolationColorSpace::OKLab:
+        return ColorInterpolationMethod { ColorInterpolationMethod::OKLab { }, *alphaPremultiplication };
+    case ColorInterpolationColorSpace::SRGB:
+        return ColorInterpolationMethod { ColorInterpolationMethod::SRGB { }, *alphaPremultiplication };
+    case ColorInterpolationColorSpace::SRGBLinear:
+        return ColorInterpolationMethod { ColorInterpolationMethod::SRGBLinear { }, *alphaPremultiplication };
+    case ColorInterpolationColorSpace::XYZD50:
+        return ColorInterpolationMethod { ColorInterpolationMethod::XYZD50 { }, *alphaPremultiplication };
+    case ColorInterpolationColorSpace::XYZD65:
+        return ColorInterpolationMethod { ColorInterpolationMethod::XYZD65 { }, *alphaPremultiplication };
+    }
+
+    RELEASE_ASSERT_NOT_REACHED();
+    return std::nullopt;
+}
+
+inline void add(Hasher& hasher, const ColorInterpolationMethod& colorInterpolationMethod)
+{
+    add(hasher, colorInterpolationMethod.alphaPremultiplication);
+    WTF::switchOn(colorInterpolationMethod.colorSpace,
+        [&] (auto& type) {
+            add(hasher, type.interpolationColorSpace);
+            if constexpr (std::remove_reference_t<decltype(type)>::ColorType::Model::coordinateSystem == ColorSpaceCoordinateSystem::CylindricalPolar) {
+                add(hasher, type.hueInterpolationMethod);
+            }
+        }
+    );
+}
+
+inline constexpr bool operator==(const ColorInterpolationMethod::HSL& a, const ColorInterpolationMethod::HSL& b)
+{
+    return a.hueInterpolationMethod == b.hueInterpolationMethod;
+}
+
+inline constexpr bool operator==(const ColorInterpolationMethod::HWB& a, const ColorInterpolationMethod::HWB& b)
+{
+    return a.hueInterpolationMethod == b.hueInterpolationMethod;
+}
+
+inline constexpr bool operator==(const ColorInterpolationMethod::LCH& a, const ColorInterpolationMethod::LCH& b)
+{
+    return a.hueInterpolationMethod == b.hueInterpolationMethod;
+}
+
+inline constexpr bool operator==(const ColorInterpolationMethod::OKLCH& a, const ColorInterpolationMethod::OKLCH& b)
+{
+    return a.hueInterpolationMethod == b.hueInterpolationMethod;
+}
+
+inline constexpr bool operator==(const ColorInterpolationMethod::Lab&, const ColorInterpolationMethod::Lab&)
+{
+    return true;
+}
+
+inline constexpr bool operator==(const ColorInterpolationMethod::OKLab&, const ColorInterpolationMethod::OKLab&)
+{
+    return true;
+}
+
+inline constexpr bool operator==(const ColorInterpolationMethod::SRGB&, const ColorInterpolationMethod::SRGB&)
+{
+    return true;
+}
+
+inline constexpr bool operator==(const ColorInterpolationMethod::SRGBLinear&, const ColorInterpolationMethod::SRGBLinear&)
+{
+    return true;
+}
+
+inline constexpr bool operator==(const ColorInterpolationMethod::XYZD50&, const ColorInterpolationMethod::XYZD50&)
+{
+    return true;
+}
+
+inline constexpr bool operator==(const ColorInterpolationMethod::XYZD65&, const ColorInterpolationMethod::XYZD65&)
+{
+    return true;
+}
+
+inline constexpr bool operator==(const ColorInterpolationMethod& a, const ColorInterpolationMethod& b)
+{
+    return a.alphaPremultiplication == b.alphaPremultiplication && a.colorSpace == b.colorSpace;
+}
+
+}
+
+namespace WTF {
+
+template<> struct EnumTraits<WebCore::HueInterpolationMethod> {
+    using values = EnumValues<
+        WebCore::HueInterpolationMethod,
+        WebCore::HueInterpolationMethod::Shorter,
+        WebCore::HueInterpolationMethod::Longer,
+        WebCore::HueInterpolationMethod::Increasing,
+        WebCore::HueInterpolationMethod::Decreasing,
+        WebCore::HueInterpolationMethod::Specified
+    >;
+};
+
+template<> struct EnumTraits<WebCore::ColorInterpolationColorSpace> {
+    using values = EnumValues<
+        WebCore::ColorInterpolationColorSpace,
+        WebCore::ColorInterpolationColorSpace::HSL,
+        WebCore::ColorInterpolationColorSpace::HWB,
+        WebCore::ColorInterpolationColorSpace::LCH,
+        WebCore::ColorInterpolationColorSpace::Lab,
+        WebCore::ColorInterpolationColorSpace::OKLCH,
+        WebCore::ColorInterpolationColorSpace::OKLab,
+        WebCore::ColorInterpolationColorSpace::SRGB,
+        WebCore::ColorInterpolationColorSpace::SRGBLinear,
+        WebCore::ColorInterpolationColorSpace::XYZD50,
+        WebCore::ColorInterpolationColorSpace::XYZD65
+    >;
+};
+
+}

Modified: trunk/Source/WebCore/platform/graphics/Gradient.cpp (286924 => 286925)


--- trunk/Source/WebCore/platform/graphics/Gradient.cpp	2021-12-12 17:29:45 UTC (rev 286924)
+++ trunk/Source/WebCore/platform/graphics/Gradient.cpp	2021-12-12 17:31:36 UTC (rev 286925)
@@ -34,13 +34,14 @@
 
 namespace WebCore {
 
-Ref<Gradient> Gradient::create(Data&& data)
+Ref<Gradient> Gradient::create(Data&& data, ColorInterpolationMethod colorInterpolationMethod)
 {
-    return adoptRef(*new Gradient(WTFMove(data)));
+    return adoptRef(*new Gradient(WTFMove(data), colorInterpolationMethod));
 }
 
-Gradient::Gradient(Data&& data)
-    : m_data(WTFMove(data))
+Gradient::Gradient(Data&& data, ColorInterpolationMethod colorInterpolationMethod)
+    : m_data { WTFMove(data) }
+    , m_colorInterpolationMethod { colorInterpolationMethod }
 {
 }
 
@@ -154,7 +155,7 @@
 {
     if (!m_cachedHash) {
         sortStops();
-        m_cachedHash = computeHash(m_data, m_spreadMethod, m_stops);
+        m_cachedHash = computeHash(m_data, m_colorInterpolationMethod, m_spreadMethod, m_stops);
     }
     return m_cachedHash;
 }

Modified: trunk/Source/WebCore/platform/graphics/Gradient.h (286924 => 286925)


--- trunk/Source/WebCore/platform/graphics/Gradient.h	2021-12-12 17:29:45 UTC (rev 286924)
+++ trunk/Source/WebCore/platform/graphics/Gradient.h	2021-12-12 17:31:36 UTC (rev 286925)
@@ -29,6 +29,7 @@
 
 #include "AffineTransform.h"
 #include "Color.h"
+#include "ColorInterpolationMethod.h"
 #include "FloatPoint.h"
 #include "GraphicsTypes.h"
 #include <variant>
@@ -102,7 +103,7 @@
 
     using Data = "" RadialData, ConicData>;
 
-    WEBCORE_EXPORT static Ref<Gradient> create(Data&&);
+    WEBCORE_EXPORT static Ref<Gradient> create(Data&&, ColorInterpolationMethod);
 
     bool isZeroSize() const;
 
@@ -138,7 +139,7 @@
     template<typename Decoder> static std::optional<Ref<Gradient>> decode(Decoder&);
 
 private:
-    explicit Gradient(Data&&);
+    explicit Gradient(Data&&, ColorInterpolationMethod);
 
     void sortStops() const;
     void stopsChanged();
@@ -149,6 +150,7 @@
 #endif
 
     Data m_data;
+    ColorInterpolationMethod m_colorInterpolationMethod;
     mutable ColorStopVector m_stops;
     mutable bool m_stopsSorted { false };
     GradientSpreadMethod m_spreadMethod { GradientSpreadMethod::Pad };
@@ -268,6 +270,7 @@
 template<typename Encoder> void Gradient::encode(Encoder& encoder) const
 {
     encoder << m_data;
+    encoder << m_colorInterpolationMethod;
     encoder << m_stops;
     encoder << m_stopsSorted;
     encoder << m_spreadMethod;
@@ -279,8 +282,14 @@
     decoder >> data;
     if (!data)
         return std::nullopt;
-    auto gradient = Gradient::create(WTFMove(*data));
 
+    std::optional<ColorInterpolationMethod> colorInterpolationMethod;
+    decoder >> colorInterpolationMethod;
+    if (!colorInterpolationMethod)
+        return std::nullopt;
+
+    auto gradient = Gradient::create(WTFMove(*data), *colorInterpolationMethod);
+
     std::optional<ColorStopVector> stops;
     decoder >> stops;
     if (!stops)

Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (286924 => 286925)


--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2021-12-12 17:29:45 UTC (rev 286924)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2021-12-12 17:31:36 UTC (rev 286925)
@@ -1121,7 +1121,7 @@
     context.setStrokeStyle(SolidStroke);
 
     const float verticalRenderingPosition = rect.y() + verticalOffset;
-    auto strokeGradient = Gradient::create(Gradient::LinearData { FloatPoint(rect.x(), verticalRenderingPosition), FloatPoint(rect.x(), verticalRenderingPosition + progressBarHeight - 1) });
+    auto strokeGradient = Gradient::create(Gradient::LinearData { FloatPoint(rect.x(), verticalRenderingPosition), FloatPoint(rect.x(), verticalRenderingPosition + progressBarHeight - 1) }, { ColorInterpolationMethod::SRGB { }, AlphaPremultiplication::Unpremultiplied });
     strokeGradient->addColorStop({ 0.0f, SRGBA<uint8_t> { 141, 141, 141 } });
     strokeGradient->addColorStop({ 0.45f, SRGBA<uint8_t> { 238, 238, 238 } });
     strokeGradient->addColorStop({ 0.55f, SRGBA<uint8_t> { 238, 238, 238 } });
@@ -1141,7 +1141,7 @@
     paintInfo.context().clipRoundedRect(FloatRoundedRect(border, roundedCornerRadius, roundedCornerRadius, roundedCornerRadius, roundedCornerRadius));
 
     float upperGradientHeight = progressBarHeight / 2.;
-    auto upperGradient = Gradient::create(Gradient::LinearData { FloatPoint(rect.x(), verticalRenderingPosition + 0.5f), FloatPoint(rect.x(), verticalRenderingPosition + upperGradientHeight - 1.5) });
+    auto upperGradient = Gradient::create(Gradient::LinearData { FloatPoint(rect.x(), verticalRenderingPosition + 0.5f), FloatPoint(rect.x(), verticalRenderingPosition + upperGradientHeight - 1.5) }, { ColorInterpolationMethod::SRGB { }, AlphaPremultiplication::Unpremultiplied });
     upperGradient->addColorStop({ 0.0f, SRGBA<uint8_t> { 133, 133, 133, 188 } });
     upperGradient->addColorStop({ 1.0f, SRGBA<uint8_t> { 18, 18, 18, 51 } });
     context.setFillGradient(WTFMove(upperGradient));
@@ -1153,7 +1153,7 @@
         // 2) Draw the progress bar.
         double position = clampTo(renderProgress.position(), 0.0, 1.0);
         float barWidth = position * rect.width();
-        auto barGradient = Gradient::create(Gradient::LinearData { FloatPoint(rect.x(), verticalRenderingPosition + 0.5f), FloatPoint(rect.x(), verticalRenderingPosition + progressBarHeight - 1) });
+        auto barGradient = Gradient::create(Gradient::LinearData { FloatPoint(rect.x(), verticalRenderingPosition + 0.5f), FloatPoint(rect.x(), verticalRenderingPosition + progressBarHeight - 1) }, { ColorInterpolationMethod::SRGB { }, AlphaPremultiplication::Unpremultiplied });
         barGradient->addColorStop({ 0.0f, SRGBA<uint8_t> { 195, 217, 247 } });
         barGradient->addColorStop({ 0.45f, SRGBA<uint8_t> { 118, 164, 228 } });
         barGradient->addColorStop({ 0.49f, SRGBA<uint8_t> { 118, 164, 228 } });
@@ -1162,7 +1162,7 @@
         barGradient->addColorStop({ 1.0f, SRGBA<uint8_t> { 57, 142, 244 } });
         context.setFillGradient(WTFMove(barGradient));
 
-        auto barStrokeGradient = Gradient::create(Gradient::LinearData { FloatPoint(rect.x(), verticalRenderingPosition), FloatPoint(rect.x(), verticalRenderingPosition + progressBarHeight - 1) });
+        auto barStrokeGradient = Gradient::create(Gradient::LinearData { FloatPoint(rect.x(), verticalRenderingPosition), FloatPoint(rect.x(), verticalRenderingPosition + progressBarHeight - 1) }, { ColorInterpolationMethod::SRGB { }, AlphaPremultiplication::Unpremultiplied });
         barStrokeGradient->addColorStop({ 0.0f, SRGBA<uint8_t> { 95, 107, 183 } });
         barStrokeGradient->addColorStop({ 0.5f, SRGBA<uint8_t> { 66, 106, 174, 240 } });
         barStrokeGradient->addColorStop({ 1.0f, SRGBA<uint8_t> { 38, 104, 166 } });
@@ -2243,7 +2243,7 @@
         return nullptr;
 
     bool isEmpty = !states.containsAny({ ControlStates::States::Checked, ControlStates::States::Indeterminate });
-    auto gradient = Gradient::create(Gradient::LinearData { rect.minXMinYCorner(), rect.maxXMaxYCorner() });
+    auto gradient = Gradient::create(Gradient::LinearData { rect.minXMinYCorner(), rect.maxXMaxYCorner() }, { ColorInterpolationMethod::SRGB { }, AlphaPremultiplication::Unpremultiplied });
     gradient->addColorStop({ 0.0f, DisplayP3<float> { 0, 0, 0, isEmpty ? 0.05f : 0.125f }});
     gradient->addColorStop({ 1.0f, DisplayP3<float> { 0, 0, 0, 0 }});
     return gradient;
@@ -2816,7 +2816,7 @@
     };
     constexpr int numColorStops = std::size(colorStops);
 
-    auto gradient = Gradient::create(Gradient::ConicData { rect.center(), 0 });
+    auto gradient = Gradient::create(Gradient::ConicData { rect.center(), 0 }, { ColorInterpolationMethod::SRGB { }, AlphaPremultiplication::Unpremultiplied });
     for (int i = 0; i < numColorStops; ++i)
         gradient->addColorStop({ i * 1.0f / (numColorStops - 1), colorStops[i] });
 

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceLinearGradient.cpp (286924 => 286925)


--- trunk/Source/WebCore/rendering/svg/RenderSVGResourceLinearGradient.cpp	2021-12-12 17:29:45 UTC (rev 286924)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourceLinearGradient.cpp	2021-12-12 17:31:36 UTC (rev 286925)
@@ -53,7 +53,7 @@
 
 Ref<Gradient> RenderSVGResourceLinearGradient::buildGradient(const RenderStyle& style) const
 {
-    auto gradient = Gradient::create(Gradient::LinearData { startPoint(m_attributes), endPoint(m_attributes) });
+    auto gradient = Gradient::create(Gradient::LinearData { startPoint(m_attributes), endPoint(m_attributes) }, { ColorInterpolationMethod::SRGB { }, AlphaPremultiplication::Unpremultiplied });
     gradient->setSpreadMethod(platformSpreadMethodFromSVGType(m_attributes.spreadMethod()));
     addStops(gradient, m_attributes.stops(), style);
     return gradient;

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceRadialGradient.cpp (286924 => 286925)


--- trunk/Source/WebCore/rendering/svg/RenderSVGResourceRadialGradient.cpp	2021-12-12 17:29:45 UTC (rev 286924)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourceRadialGradient.cpp	2021-12-12 17:31:36 UTC (rev 286925)
@@ -64,7 +64,7 @@
 
 Ref<Gradient> RenderSVGResourceRadialGradient::buildGradient(const RenderStyle& style) const
 {
-    auto gradient = Gradient::create(Gradient::RadialData { focalPoint(m_attributes), centerPoint(m_attributes), focalRadius(m_attributes), radius(m_attributes), 1 });
+    auto gradient = Gradient::create(Gradient::RadialData { focalPoint(m_attributes), centerPoint(m_attributes), focalRadius(m_attributes), radius(m_attributes), 1 }, { ColorInterpolationMethod::SRGB { }, AlphaPremultiplication::Unpremultiplied });
     gradient->setSpreadMethod(platformSpreadMethodFromSVGType(m_attributes.spreadMethod()));
     addStops(gradient, m_attributes.stops(), style);
     return gradient;

Modified: trunk/Tools/ChangeLog (286924 => 286925)


--- trunk/Tools/ChangeLog	2021-12-12 17:29:45 UTC (rev 286924)
+++ trunk/Tools/ChangeLog	2021-12-12 17:31:36 UTC (rev 286925)
@@ -1,3 +1,17 @@
+2021-12-12  Sam Weinig  <wei...@apple.com>
+
+        Pipe ColorInterpolationMethod into Gradient
+        https://bugs.webkit.org/show_bug.cgi?id=234205
+
+        Reviewed by Antti Koivisto.
+
+        Update calls to Gradient::create() to pass the now required ColorInterpolationMethod.
+
+        * TestWebKitAPI/Tests/WebCore/DisplayListTests.cpp:
+        (TestWebKitAPI::createGradient):
+        * TestWebKitAPI/Tests/WebCore/cg/BifurcatedGraphicsContextTestsCG.cpp:
+        (TestWebKitAPI::TEST):
+
 2021-12-11  Commit Queue  <commit-qu...@webkit.org>
 
         Unreviewed, reverting r286893.

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/DisplayListTests.cpp (286924 => 286925)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/DisplayListTests.cpp	2021-12-12 17:29:45 UTC (rev 286924)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/DisplayListTests.cpp	2021-12-12 17:31:36 UTC (rev 286925)
@@ -42,7 +42,7 @@
 
 static Ref<Gradient> createGradient()
 {
-    auto gradient = Gradient::create(Gradient::ConicData { { 0., 0. }, 1.25 });
+    auto gradient = Gradient::create(Gradient::ConicData { { 0., 0. }, 1.25 }, { ColorInterpolationMethod::SRGB { }, AlphaPremultiplication::Unpremultiplied });
     gradient->addColorStop({ 0.1, Color::red });
     gradient->addColorStop({ 0.5, Color::green });
     gradient->addColorStop({ 0.9, Color::blue });

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/cg/BifurcatedGraphicsContextTestsCG.cpp (286924 => 286925)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/cg/BifurcatedGraphicsContextTestsCG.cpp	2021-12-12 17:29:45 UTC (rev 286924)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/cg/BifurcatedGraphicsContextTestsCG.cpp	2021-12-12 17:31:36 UTC (rev 286925)
@@ -139,7 +139,7 @@
     GraphicsContextCG secondaryContext(secondaryCGContext.get());
     BifurcatedGraphicsContext ctx(primaryContext, secondaryContext);
 
-    auto gradient = Gradient::create(Gradient::LinearData { { 0, 0 }, { 1, 1 } });
+    auto gradient = Gradient::create(Gradient::LinearData { { 0, 0 }, { 1, 1 } }, { ColorInterpolationMethod::SRGB { }, AlphaPremultiplication::Unpremultiplied });
     gradient->addColorStop({ 0, Color::red });
 
     auto gradientImage = GradientImage::create(gradient, FloatSize { 1, 1 });
@@ -171,7 +171,7 @@
     GraphicsContextCG secondaryContext(secondaryCGContext.get());
     BifurcatedGraphicsContext ctx(primaryContext, secondaryContext);
 
-    auto gradient = Gradient::create(Gradient::LinearData { { 0, 0 }, { 1, 1 } });
+    auto gradient = Gradient::create(Gradient::LinearData { { 0, 0 }, { 1, 1 } }, { ColorInterpolationMethod::SRGB { }, AlphaPremultiplication::Unpremultiplied });
     gradient->addColorStop({ 0, Color::red });
 
     auto gradientImage = GradientImage::create(gradient, FloatSize { 1, 1 });
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to