Diff
Modified: trunk/LayoutTests/ChangeLog (272310 => 272311)
--- trunk/LayoutTests/ChangeLog 2021-02-03 14:28:16 UTC (rev 272310)
+++ trunk/LayoutTests/ChangeLog 2021-02-03 14:38:52 UTC (rev 272311)
@@ -1,3 +1,19 @@
+2021-02-03 Sam Weinig <[email protected]>
+
+ Add support for color(xyz ...) as part of CSS Color 4
+ https://bugs.webkit.org/show_bug.cgi?id=221190
+
+ Reviewed by Simon Fraser.
+
+ * TestExpectations:
+ Remove now passing xyz test. Update comment for the other xyz test which is invalid.
+ Getting it removed in https://github.com/web-platform-tests/wpt/pull/27416.
+
+ * fast/css/parsing-color-function-expected.txt:
+ * fast/css/parsing-color-function.html:
+ Add xyz specific parsing tests, as the rgb ones can't be reusued due to xyz
+ not supporting percentages for any component.
+
2021-02-03 Ziran Sun <[email protected]>
[css-grid][css-flex] <table> grid item should fill the grid area for 'stretch'/'normal' self alignment
Modified: trunk/LayoutTests/TestExpectations (272310 => 272311)
--- trunk/LayoutTests/TestExpectations 2021-02-03 14:28:16 UTC (rev 272310)
+++ trunk/LayoutTests/TestExpectations 2021-02-03 14:38:52 UTC (rev 272311)
@@ -4601,7 +4601,6 @@
webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-004.html [ ImageOnlyFailure ] # Invalid test, no colorspace specified
webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-014.html [ ImageOnlyFailure ] # Requires fallback (at parse time) support
webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-015.html [ ImageOnlyFailure ] # Requires fallback (at parse time) support (unclear if this makes sense)
-webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-016.html [ ImageOnlyFailure ] # Requires xyz support
-webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-017.html [ ImageOnlyFailure ] # Requires xyz support
+webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-017.html [ ImageOnlyFailure ] # Invalid test, percentages are not allowed for color(xyz).
webkit.org/b/218496 http/tests/loading/redirect-with-no-location-crash.html [ Skip ]
Modified: trunk/LayoutTests/fast/css/parsing-color-function-expected.txt (272310 => 272311)
--- trunk/LayoutTests/fast/css/parsing-color-function-expected.txt 2021-02-03 14:28:16 UTC (rev 272310)
+++ trunk/LayoutTests/fast/css/parsing-color-function-expected.txt 2021-02-03 14:38:52 UTC (rev 272311)
@@ -123,6 +123,38 @@
PASS computedStyle("background-color", "color(prophoto-rgb 0% 0 0deg)") is "rgba(0, 0, 0, 0)"
PASS computedStyle("background-color", "color(prophoto-rgb 0% 0% 0deg)") is "rgba(0, 0, 0, 0)"
PASS computedStyle("background-color", "color(prophoto-rgb 40% 0 0deg)") is "rgba(0, 0, 0, 0)"
+
+Testing color(xyz ...)
+PASS computedStyle("background-color", "color(xyz 0 0 0)") is "color(xyz 0 0 0)"
+PASS computedStyle("background-color", "color(xyz 0 0 0 / 1)") is "color(xyz 0 0 0)"
+PASS computedStyle("background-color", "color(xyz 1 1 1)") is "color(xyz 1 1 1)"
+PASS computedStyle("background-color", "color(xyz 1 1 1 / 1)") is "color(xyz 1 1 1)"
+PASS computedStyle("background-color", "color(xyz -1 -1 -1)") is "color(xyz -1 -1 -1)"
+PASS computedStyle("background-color", "color(xyz 0.1 0.1 0.1)") is "color(xyz 0.1 0.1 0.1)"
+PASS computedStyle("background-color", "color(xyz 10 10 10)") is "color(xyz 10 10 10)"
+PASS computedStyle("background-color", "color(xyz .2 .2 .25)") is "color(xyz 0.2 0.2 0.25)"
+PASS computedStyle("background-color", "color(xyz 0 0 0 / 0.5)") is "color(xyz 0 0 0 / 0.5)"
+PASS computedStyle("background-color", "color(xyz .20 0 10/0.5)") is "color(xyz 0.2 0 10 / 0.5)"
+PASS computedStyle("background-color", "color(xyz .20 0 10/50%)") is "color(xyz 0.2 0 10 / 0.5)"
+PASS computedStyle("background-color", "color(xyz 0 0 0 / -10%)") is "color(xyz 0 0 0 / 0)"
+PASS computedStyle("background-color", "color(xyz 0 0 0 / 110%)") is "color(xyz 0 0 0)"
+PASS computedStyle("background-color", "color(xyz 0 0 0 / 300%)") is "color(xyz 0 0 0)"
+PASS computedStyle("background-color", "color(xyz 1 1)") is "color(xyz 1 1 0)"
+PASS computedStyle("background-color", "color(xyz 1)") is "color(xyz 1 0 0)"
+PASS computedStyle("background-color", "color(xyz)") is "color(xyz 0 0 0)"
+PASS computedStyle("background-color", "color(xyz 1 1 / .5)") is "color(xyz 1 1 0 / 0.5)"
+PASS computedStyle("background-color", "color(xyz 1 / 0.5)") is "color(xyz 1 0 0 / 0.5)"
+PASS computedStyle("background-color", "color(xyz / 50%)") is "color(xyz 0 0 0 / 0.5)"
+
+Test invalid values
+PASS computedStyle("background-color", "color(xyz 0 0 0 0)") is "rgba(0, 0, 0, 0)"
+PASS computedStyle("background-color", "color(xyz 0deg 0% 0)") is "rgba(0, 0, 0, 0)"
+PASS computedStyle("background-color", "color(xyz 0% 0 0)") is "rgba(0, 0, 0, 0)"
+PASS computedStyle("background-color", "color(xyz 0% 0 0 1)") is "rgba(0, 0, 0, 0)"
+PASS computedStyle("background-color", "color(xyz 0% 0 0 10%)") is "rgba(0, 0, 0, 0)"
+PASS computedStyle("background-color", "color(xyz 0% 0 0deg)") is "rgba(0, 0, 0, 0)"
+PASS computedStyle("background-color", "color(xyz 0% 0% 0deg)") is "rgba(0, 0, 0, 0)"
+PASS computedStyle("background-color", "color(xyz 40% 0 0deg)") is "rgba(0, 0, 0, 0)"
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/css/parsing-color-function.html (272310 => 272311)
--- trunk/LayoutTests/fast/css/parsing-color-function.html 2021-02-03 14:28:16 UTC (rev 272310)
+++ trunk/LayoutTests/fast/css/parsing-color-function.html 2021-02-03 14:38:52 UTC (rev 272311)
@@ -68,6 +68,42 @@
testComputed("background-color", `color(${color} 0% 0% 0deg)`, `rgba(0, 0, 0, 0)`);
testComputed("background-color", `color(${color} 40% 0 0deg)`, `rgba(0, 0, 0, 0)`);
}
+
+ debug('');
+ debug(`Testing color(xyz ...)`);
+
+ testComputed("background-color", `color(xyz 0 0 0)`, `color(xyz 0 0 0)`);
+ testComputed("background-color", `color(xyz 0 0 0 / 1)`, `color(xyz 0 0 0)`);
+ testComputed("background-color", `color(xyz 1 1 1)`, `color(xyz 1 1 1)`);
+ testComputed("background-color", `color(xyz 1 1 1 / 1)`, `color(xyz 1 1 1)`);
+ testComputed("background-color", `color(xyz -1 -1 -1)`, `color(xyz -1 -1 -1)`);
+ testComputed("background-color", `color(xyz 0.1 0.1 0.1)`, `color(xyz 0.1 0.1 0.1)`);
+ testComputed("background-color", `color(xyz 10 10 10)`, `color(xyz 10 10 10)`);
+ testComputed("background-color", `color(xyz .2 .2 .25)`, `color(xyz 0.2 0.2 0.25)`);
+ testComputed("background-color", `color(xyz 0 0 0 / 0.5)`, `color(xyz 0 0 0 / 0.5)`);
+ testComputed("background-color", `color(xyz .20 0 10/0.5)`, `color(xyz 0.2 0 10 / 0.5)`);
+ testComputed("background-color", `color(xyz .20 0 10/50%)`, `color(xyz 0.2 0 10 / 0.5)`);
+ testComputed("background-color", `color(xyz 0 0 0 / -10%)`, `color(xyz 0 0 0 / 0)`);
+ testComputed("background-color", `color(xyz 0 0 0 / 110%)`, `color(xyz 0 0 0)`);
+ testComputed("background-color", `color(xyz 0 0 0 / 300%)`, `color(xyz 0 0 0)`);
+ testComputed("background-color", `color(xyz 1 1)`, `color(xyz 1 1 0)`);
+ testComputed("background-color", `color(xyz 1)`, `color(xyz 1 0 0)`);
+ testComputed("background-color", `color(xyz)`, `color(xyz 0 0 0)`);
+ testComputed("background-color", `color(xyz 1 1 / .5)`, `color(xyz 1 1 0 / 0.5)`);
+ testComputed("background-color", `color(xyz 1 / 0.5)`, `color(xyz 1 0 0 / 0.5)`);
+ testComputed("background-color", `color(xyz / 50%)`, `color(xyz 0 0 0 / 0.5)`);
+
+ debug('');
+ debug('Test invalid values');
+ testComputed("background-color", `color(xyz 0 0 0 0)`, `rgba(0, 0, 0, 0)`);
+ testComputed("background-color", `color(xyz 0deg 0% 0)`, `rgba(0, 0, 0, 0)`);
+ testComputed("background-color", `color(xyz 0% 0 0)`, `rgba(0, 0, 0, 0)`);
+ testComputed("background-color", `color(xyz 0% 0 0 1)`, `rgba(0, 0, 0, 0)`);
+ testComputed("background-color", `color(xyz 0% 0 0 10%)`, `rgba(0, 0, 0, 0)`);
+ testComputed("background-color", `color(xyz 0% 0 0deg)`, `rgba(0, 0, 0, 0)`);
+ testComputed("background-color", `color(xyz 0% 0% 0deg)`, `rgba(0, 0, 0, 0)`);
+ testComputed("background-color", `color(xyz 40% 0 0deg)`, `rgba(0, 0, 0, 0)`);
+
</script>
<script src=""
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (272310 => 272311)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-02-03 14:28:16 UTC (rev 272310)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2021-02-03 14:38:52 UTC (rev 272311)
@@ -1,3 +1,23 @@
+2021-02-03 Sam Weinig <[email protected]>
+
+ Add support for color(xyz ...) as part of CSS Color 4
+ https://bugs.webkit.org/show_bug.cgi?id=221190
+
+ Reviewed by Simon Fraser.
+
+ Add some new WPT tests for color(xyz ) that will be upstreamed shortly.
+
+ * web-platform-tests/css/css-color/xyz-001-expected.html: Added.
+ * web-platform-tests/css/css-color/xyz-001.html: Added.
+ * web-platform-tests/css/css-color/xyz-002-expected.html: Added.
+ * web-platform-tests/css/css-color/xyz-002.html: Added.
+ * web-platform-tests/css/css-color/xyz-003-expected.html: Added.
+ * web-platform-tests/css/css-color/xyz-003.html: Added.
+ * web-platform-tests/css/css-color/xyz-004-expected.html: Added.
+ * web-platform-tests/css/css-color/xyz-004.html: Added.
+ * web-platform-tests/css/css-color/xyz-005-expected.html: Added.
+ * web-platform-tests/css/css-color/xyz-005.html: Added.
+
2021-02-03 Ziran Sun <[email protected]>
[css-grid] max-height percentages are wrongly resolved for replaced grid items
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-001-expected.html (0 => 272311)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-001-expected.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-001-expected.html 2021-02-03 14:38:52 UTC (rev 272311)
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Green square reference</title>
+<style>
+ .test { background-color: #008000; width: 12em; height: 12em;}
+</style>
+<body>
+ <p>Test passes if you see a green square, and no red.</p>
+ <div class="test"></div>
+</body>
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-001.html (0 => 272311)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-001.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-001.html 2021-02-03 14:38:52 UTC (rev 272311)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Color 4: xyz</title>
+<link rel="author" title="Sam Weinig" href=""
+<link rel="help" href=""
+<link rel="match" href=""
+<meta name="assert" content="xyz with no alpha">
+<style>
+ .test { background-color: red; width: 12em; height: 12em; }
+ .test { background-color: color(xyz 0.08312 0.154746 0.020961); } /* green (sRGB #008000) converted to xyz */
+</style>
+<body>
+ <p>Test passes if you see a green square, and no red.</p>
+ <div class="test"></div>
+</body>
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-002-expected.html (0 => 272311)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-002-expected.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-002-expected.html 2021-02-03 14:38:52 UTC (rev 272311)
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Black square reference</title>
+<style>
+ .test { background-color: #000000; width: 12em; height: 12em; }
+</style>
+<body>
+ <p>Test passes if you see a black square, and no red.</p>
+ <div class="test"></div>
+</body>
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-002.html (0 => 272311)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-002.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-002.html 2021-02-03 14:38:52 UTC (rev 272311)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Color 4: xyz</title>
+<link rel="author" title="Sam Weinig" href=""
+<link rel="help" href=""
+<link rel="match" href=""
+<meta name="assert" content="xyz with no alpha">
+<style>
+ .test { background-color: red; width: 12em; height: 12em; }
+ .test { background-color: color(xyz 0 0 0); } /* black (sRGB #000000) converted to xyz */
+</style>
+<body>
+ <p>Test passes if you see a black square, and no red.</p>
+ <div class="test"></div>
+</body>
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-003-expected.html (0 => 272311)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-003-expected.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-003-expected.html 2021-02-03 14:38:52 UTC (rev 272311)
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Color 4: CSS Color 4: xyz</title>
+<style>
+ body { background-color: grey; }
+ .test { background-color: lab(100% 6.1097 -13.2268); width: 12em; height: 12em; } /* color(xyz 1 1 1) converted to Lab */
+</style>
+<body>
+ <p>Test passes if you see a single square, and not two rectangles of different colors.</p>
+ <div class="test"></div>
+</body>
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-003.html (0 => 272311)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-003.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-003.html 2021-02-03 14:38:52 UTC (rev 272311)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Color 4: xyz</title>
+<link rel="author" title="Sam Weinig" href=""
+<link rel="help" href=""
+<link rel="match" href=""
+<meta name="assert" content="xyz with no alpha">
+<style>
+ body { background-color: grey; }
+ .test { background-color: red; width: 12em; height: 6em; margin-top: 0; }
+ .ref { background-color: lab(100% 6.1097 -13.2268); width: 12em; height: 6em; margin-bottom: 0; } /* color(xyz 1 1 1) converted to Lab */
+ .test { background-color: color(xyz 1 1 1); }
+</style>
+<body>
+ <p>Test passes if you see a single square, and not two rectangles of different colors.</p>
+ <div class="ref"></div>
+ <div class="test"></div>
+</body>
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-004-expected.html (0 => 272311)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-004-expected.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-004-expected.html 2021-02-03 14:38:52 UTC (rev 272311)
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Color 4: CSS Color 4: xyz</title>
+<style>
+ .test { background-color: lab(100% -431.0345 172.4138); width: 12em; height: 12em; } /* color(xyz 0 1 0) converted to Lab */
+</style>
+<body>
+ <p>Test passes if you see a single square, and not two rectangles of different colors.</p>
+ <div class="test"></div>
+</body>
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-004.html (0 => 272311)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-004.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-004.html 2021-02-03 14:38:52 UTC (rev 272311)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Color 4: xyz</title>
+<link rel="author" title="Sam Weinig" href=""
+<link rel="help" href=""
+<link rel="match" href=""
+<meta name="assert" content="xyz with no alpha">
+<style>
+ .test { background-color: red; width: 12em; height: 6em; margin-top: 0; }
+ .ref { background-color: lab(100% -431.0345 172.4138); width: 12em; height: 6em; margin-bottom: 0; } /* color(xyz 0 1 0) converted to Lab */
+ .test { background-color: color(xyz 0 1 0); }
+</style>
+<body>
+ <p>Test passes if you see a single square, and not two rectangles of different colors.</p>
+ <div class="ref"></div>
+ <div class="test"></div>
+</body>
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-005-expected.html (0 => 272311)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-005-expected.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-005-expected.html 2021-02-03 14:38:52 UTC (rev 272311)
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Green square color(display-p3 0 1 0) reference</title>
+<style>
+ .test { background-color: color(display-p3 0 1 0); width: 12em; height: 12em; }
+</style>
+<body>
+ <p>Test passes if you see a green square, and no red.</p>
+ <div class="test"></div>
+</body>
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-005.html (0 => 272311)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-005.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/xyz-005.html 2021-02-03 14:38:52 UTC (rev 272311)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Color 4: xyz</title>
+<link rel="author" title="Sam Weinig" href=""
+<link rel="help" href=""
+<link rel="match" href=""
+<meta name="assert" content="xyz outside the sRGB gamut">
+<style>
+ .test { background-color: red; width: 12em; height: 12em; }
+ .test { background-color: color(xyz 0.29194 0.692236 0.041884); } /* green color(display-p3 0 1 0) converted to xyz */
+</style>
+<body>
+ <p>Test passes if you see a green square, and no red.</p>
+ <div class="test"></div>
+</body>
Modified: trunk/Source/WebCore/ChangeLog (272310 => 272311)
--- trunk/Source/WebCore/ChangeLog 2021-02-03 14:28:16 UTC (rev 272310)
+++ trunk/Source/WebCore/ChangeLog 2021-02-03 14:38:52 UTC (rev 272311)
@@ -1,3 +1,87 @@
+2021-02-03 Sam Weinig <[email protected]>
+
+ Add support for color(xyz ...) as part of CSS Color 4
+ https://bugs.webkit.org/show_bug.cgi?id=221190
+
+ Reviewed by Simon Fraser.
+
+ Add final (for now) predefined color space supported by color() in CSS Color 4, XYZ.
+
+ The specific XYZ use by CSS is the XYZ with D50 white point. To make the generic
+ XYZA<T, WhitePoint> type work in the infrastrucure, the colorSpace member was removed
+ from the color types, and the mapping from ColorSpace enum value to ColorType was
+ converted to use template specialization and can now be extracted using the syntax:
+
+ ColorSpaceFor<ColorType>
+
+ This change also removed the inclusion of all of the color type specific serialiazation
+ function declarations in ColorSerialization.h, and instead moved them to the cpp file.
+ They weren't being used, and to support the XYZA<float, WhitePoint::D50> would have required
+ incluing more headers, which seemed like the wrong tradeoff. If accessing serialization
+ without constructing a WebCore::Color is useful in the future, we can always add them back.
+
+ Tests: imported/w3c/web-platform-tests/css/css-color/xyz-001.html
+ imported/w3c/web-platform-tests/css/css-color/xyz-002.html
+ imported/w3c/web-platform-tests/css/css-color/xyz-003.html
+ imported/w3c/web-platform-tests/css/css-color/xyz-004.html
+ imported/w3c/web-platform-tests/css/css-color/xyz-005.html
+
+ * css/CSSValueKeywords.in:
+ Add xyz keyword.
+
+ * css/parser/CSSPropertyParserHelpers.cpp:
+ (WebCore::CSSPropertyParserHelpers::parseColorFunctionForXYZParameters):
+ (WebCore::CSSPropertyParserHelpers::parseColorFunctionParameters):
+ Add parsing for color(xyz ) parameters. This can't reuse the RGB parameter
+ parsing because xyz does not allow percentages for any parameter.
+
+ * platform/graphics/ColorConversion.h:
+ (WebCore::callWithColorType): Deleted.
+ Moved callWithColorType to ColorSpace.h, where it makes a bit more sense
+ now that the color mapping is also defined there. This puts most of the
+ color mapping in one place.
+
+ * platform/graphics/ColorModels.h:
+ Add some needed includes that fiddling with headers exposed.
+
+ * platform/graphics/ColorSerialization.cpp:
+ (WebCore::serialization):
+ (WebCore::serializationForCSS):
+ (WebCore::serializationForHTML):
+ (WebCore::serializationForRenderTreeAsText):
+ * platform/graphics/ColorSerialization.h:
+ Add support for serializing XYZA<float, WhitePoint::D50>, taking the chance
+ to move all the unnecessarily exposed type specific serialization functions.
+
+ * platform/graphics/ColorSpace.cpp:
+ (WebCore::operator<<):
+ Add support for XYZ_D50.
+
+ * platform/graphics/ColorSpace.h:
+ Add color mapping replacing previous explicit static members for colorSpace
+ mapping which are no longer usable due to the generic nature of XYZA.
+
+ (WebCore::callWithColorType):
+ Moved from ColorConversion.h.
+
+ * platform/graphics/ColorTypes.h:
+ Remove colorSpace members. Replaced by color space mapping in ColorSpace.h
+
+ * platform/graphics/ColorUtilities.h:
+ (WebCore::isBlack):
+ (WebCore::isWhite):
+ Add overloads for XYZA needed by Color.
+
+ * platform/graphics/ExtendedColor.h:
+ (WebCore::ExtendedColor::create):
+ Replace color.colorSpace with ColorSpaceFor<ColorType>.
+
+ * platform/graphics/cg/ColorSpaceCG.cpp:
+ (WebCore::xyzD50ColorSpaceRef):
+ * platform/graphics/cg/ColorSpaceCG.h:
+ (WebCore::cachedCGColorSpace):
+ Add CoreGraphics support for the XYZ color space. (kCGColorSpaceGenericXYZ maps to XYZ with a D50 white point.)
+
2021-02-03 Zalan Bujtas <[email protected]>
[LFC][IFC] Use the overflowing run to decide if the unbreakable content should stay on the current line
Modified: trunk/Source/WebCore/css/CSSValueKeywords.in (272310 => 272311)
--- trunk/Source/WebCore/css/CSSValueKeywords.in 2021-02-03 14:28:16 UTC (rev 272310)
+++ trunk/Source/WebCore/css/CSSValueKeywords.in 2021-02-03 14:38:52 UTC (rev 272311)
@@ -1409,6 +1409,7 @@
prophoto-rgb
// rec2020
// sRGB
+xyz
// prefers-default-appearance
prefers
Modified: trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp (272310 => 272311)
--- trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp 2021-02-03 14:28:16 UTC (rev 272310)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp 2021-02-03 14:38:52 UTC (rev 272311)
@@ -942,6 +942,36 @@
return Lab<float> { static_cast<float>(channels[0]), static_cast<float>(channels[1]), static_cast<float>(channels[2]), *alpha };
}
+static Color parseColorFunctionForXYZParameters(CSSParserTokenRange& args)
+{
+ ASSERT(args.peek().id() == CSSValueXyz);
+ consumeIdentRaw(args);
+
+ double channels[3] = { 0, 0, 0 };
+ [&] {
+ auto x = consumeNumberRaw(args, ValueRangeAll);
+ if (!x)
+ return;
+ channels[0] = *x;
+
+ auto y = consumeNumberRaw(args, ValueRangeAll);
+ if (!y)
+ return;
+ channels[1] = *y;
+
+ auto z = consumeNumberRaw(args, ValueRangeAll);
+ if (!z)
+ return;
+ channels[2] = *z;
+ }();
+
+ auto alpha = parseOptionalAlpha(args);
+ if (!alpha)
+ return { };
+
+ return XYZA<float, WhitePoint::D50> { static_cast<float>(channels[0]), static_cast<float>(channels[1]), static_cast<float>(channels[2]), *alpha };
+}
+
static Color parseColorFunctionParameters(CSSParserTokenRange& range)
{
ASSERT(range.peek().functionId() == CSSValueColor);
@@ -967,6 +997,9 @@
case CSSValueSRGB:
color = parseColorFunctionForRGBTypes<SRGBA<float>>(args);
break;
+ case CSSValueXyz:
+ color = parseColorFunctionForXYZParameters(args);
+ break;
default:
return { };
}
Modified: trunk/Source/WebCore/platform/graphics/ColorConversion.h (272310 => 272311)
--- trunk/Source/WebCore/platform/graphics/ColorConversion.h 2021-02-03 14:28:16 UTC (rev 272310)
+++ trunk/Source/WebCore/platform/graphics/ColorConversion.h 2021-02-03 14:38:52 UTC (rev 272311)
@@ -256,28 +256,4 @@
return toSRGBA(performChomaticAdapatation<SRGBA<float>>(toXYZA(color)));
}
-
-template<typename T, typename Functor> constexpr decltype(auto) callWithColorType(const ColorComponents<T>& components, ColorSpace colorSpace, Functor&& functor)
-{
- switch (colorSpace) {
- case ColorSpace::A98RGB:
- return std::invoke(std::forward<Functor>(functor), makeFromComponents<A98RGB<T>>(components));
- case ColorSpace::DisplayP3:
- return std::invoke(std::forward<Functor>(functor), makeFromComponents<DisplayP3<T>>(components));
- case ColorSpace::Lab:
- return std::invoke(std::forward<Functor>(functor), makeFromComponents<Lab<T>>(components));
- case ColorSpace::LinearRGB:
- return std::invoke(std::forward<Functor>(functor), makeFromComponents<LinearSRGBA<T>>(components));
- case ColorSpace::ProPhotoRGB:
- return std::invoke(std::forward<Functor>(functor), makeFromComponents<ProPhotoRGB<T>>(components));
- case ColorSpace::Rec2020:
- return std::invoke(std::forward<Functor>(functor), makeFromComponents<Rec2020<T>>(components));
- case ColorSpace::SRGB:
- return std::invoke(std::forward<Functor>(functor), makeFromComponents<SRGBA<T>>(components));
- }
-
- ASSERT_NOT_REACHED();
- return std::invoke(std::forward<Functor>(functor), makeFromComponents<SRGBA<T>>(components));
-}
-
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/ColorModels.h (272310 => 272311)
--- trunk/Source/WebCore/platform/graphics/ColorModels.h 2021-02-03 14:28:16 UTC (rev 272310)
+++ trunk/Source/WebCore/platform/graphics/ColorModels.h 2021-02-03 14:38:52 UTC (rev 272311)
@@ -25,6 +25,9 @@
#pragma once
+#include <array>
+#include <limits>
+
namespace WebCore {
template<typename> struct AlphaTraits;
Modified: trunk/Source/WebCore/platform/graphics/ColorSerialization.cpp (272310 => 272311)
--- trunk/Source/WebCore/platform/graphics/ColorSerialization.cpp 2021-02-03 14:28:16 UTC (rev 272310)
+++ trunk/Source/WebCore/platform/graphics/ColorSerialization.cpp 2021-02-03 14:38:52 UTC (rev 272311)
@@ -36,6 +36,43 @@
namespace WebCore {
+static String serializationForCSS(const A98RGB<float>&);
+static String serializationForHTML(const A98RGB<float>&);
+static String serializationForRenderTreeAsText(const A98RGB<float>&);
+
+static String serializationForCSS(const DisplayP3<float>&);
+static String serializationForHTML(const DisplayP3<float>&);
+static String serializationForRenderTreeAsText(const DisplayP3<float>&);
+
+static String serializationForCSS(const Lab<float>&);
+static String serializationForHTML(const Lab<float>&);
+static String serializationForRenderTreeAsText(const Lab<float>&);
+
+static String serializationForCSS(const LinearSRGBA<float>&);
+static String serializationForHTML(const LinearSRGBA<float>&);
+static String serializationForRenderTreeAsText(const LinearSRGBA<float>&);
+
+static String serializationForCSS(const ProPhotoRGB<float>&);
+static String serializationForHTML(const ProPhotoRGB<float>&);
+static String serializationForRenderTreeAsText(const ProPhotoRGB<float>&);
+
+static String serializationForCSS(const Rec2020<float>&);
+static String serializationForHTML(const Rec2020<float>&);
+static String serializationForRenderTreeAsText(const Rec2020<float>&);
+
+static String serializationForCSS(const SRGBA<float>&);
+static String serializationForHTML(const SRGBA<float>&);
+static String serializationForRenderTreeAsText(const SRGBA<float>&);
+
+static String serializationForCSS(SRGBA<uint8_t>);
+static String serializationForHTML(SRGBA<uint8_t>);
+static String serializationForRenderTreeAsText(SRGBA<uint8_t>);
+
+static String serializationForCSS(const XYZA<float, WhitePoint::D50>&);
+static String serializationForHTML(const XYZA<float, WhitePoint::D50>&);
+static String serializationForRenderTreeAsText(const XYZA<float, WhitePoint::D50>&);
+
+
String serializationForCSS(const Color& color)
{
return color.callOnUnderlyingType([] (auto underlyingColor) {
@@ -74,6 +111,8 @@
return "rec2020"_s;
case ColorSpace::SRGB:
return "srgb"_s;
+ case ColorSpace::XYZ_D50:
+ return "xyz"_s;
}
ASSERT_NOT_REACHED();
@@ -84,8 +123,8 @@
{
auto [c1, c2, c3, alpha] = color;
if (WTF::areEssentiallyEqual(alpha, 1.0f))
- return makeString("color(", serialization(color.colorSpace), ' ', c1, ' ', c2, ' ', c3, ')');
- return makeString("color(", serialization(color.colorSpace), ' ', c1, ' ', c2, ' ', c3, " / ", alpha, ')');
+ return makeString("color(", serialization(ColorSpaceFor<ColorType>), ' ', c1, ' ', c2, ' ', c3, ')');
+ return makeString("color(", serialization(ColorSpaceFor<ColorType>), ' ', c1, ' ', c2, ' ', c3, " / ", alpha, ')');
}
// MARK: A98RGB<float> overloads
@@ -260,4 +299,21 @@
return makeString('#', hex(red, 2), hex(green, 2), hex(blue, 2));
}
+// MARK: XYZA<float, WhitePoint::D50> overloads
+
+String serializationForCSS(const XYZA<float, WhitePoint::D50>& color)
+{
+ return serialization(color);
}
+
+String serializationForHTML(const XYZA<float, WhitePoint::D50>& color)
+{
+ return serialization(color);
+}
+
+String serializationForRenderTreeAsText(const XYZA<float, WhitePoint::D50>& color)
+{
+ return serialization(color);
+}
+
+}
Modified: trunk/Source/WebCore/platform/graphics/ColorSerialization.h (272310 => 272311)
--- trunk/Source/WebCore/platform/graphics/ColorSerialization.h 2021-02-03 14:28:16 UTC (rev 272310)
+++ trunk/Source/WebCore/platform/graphics/ColorSerialization.h 2021-02-03 14:38:52 UTC (rev 272311)
@@ -31,54 +31,12 @@
class Color;
-template<typename> struct A98RGB;
-template<typename> struct DisplayP3;
-template<typename> struct Lab;
-template<typename> struct LinearSRGBA;
-template<typename> struct ProPhotoRGB;
-template<typename> struct Rec2020;
-template<typename> struct SRGBA;
+// serializationForCSS returns the color serialized according to CSS <https://drafts.csswg.org/css-color-4/#serializing-color-values>.
+// serializationForHTML returns the color serialized according to HTML5 <https://html.spec.whatwg.org/multipage/scripting.html#fill-and-stroke-styles> (10 September 2015).
+// serializationForRenderTreeAsText returns the color serialized for DumpRenderTree, #RRGGBB, #RRGGBBAA or the CSS serialization.
-// serializationForHTML returns the color serialized according to HTML5 <https://html.spec.whatwg.org/multipage/scripting.html#fill-and-stroke-styles> (10 September 2015)
-// serializationForCSS returns the color serialized according to CSS
-// serializationForRenderTreeAsText returns the color serialized for DumpRenderTree, #RRGGBB, #RRGGBBAA or the CSS serialization
-
WEBCORE_EXPORT String serializationForCSS(const Color&);
WEBCORE_EXPORT String serializationForHTML(const Color&);
WEBCORE_EXPORT String serializationForRenderTreeAsText(const Color&);
-// Per-ColorType specializations.
-
-WEBCORE_EXPORT String serializationForCSS(const A98RGB<float>&);
-WEBCORE_EXPORT String serializationForHTML(const A98RGB<float>&);
-WEBCORE_EXPORT String serializationForRenderTreeAsText(const A98RGB<float>&);
-
-WEBCORE_EXPORT String serializationForCSS(const DisplayP3<float>&);
-WEBCORE_EXPORT String serializationForHTML(const DisplayP3<float>&);
-WEBCORE_EXPORT String serializationForRenderTreeAsText(const DisplayP3<float>&);
-
-WEBCORE_EXPORT String serializationForCSS(const Lab<float>&);
-WEBCORE_EXPORT String serializationForHTML(const Lab<float>&);
-WEBCORE_EXPORT String serializationForRenderTreeAsText(const Lab<float>&);
-
-WEBCORE_EXPORT String serializationForCSS(const LinearSRGBA<float>&);
-WEBCORE_EXPORT String serializationForHTML(const LinearSRGBA<float>&);
-WEBCORE_EXPORT String serializationForRenderTreeAsText(const LinearSRGBA<float>&);
-
-WEBCORE_EXPORT String serializationForCSS(const ProPhotoRGB<float>&);
-WEBCORE_EXPORT String serializationForHTML(const ProPhotoRGB<float>&);
-WEBCORE_EXPORT String serializationForRenderTreeAsText(const ProPhotoRGB<float>&);
-
-WEBCORE_EXPORT String serializationForCSS(const Rec2020<float>&);
-WEBCORE_EXPORT String serializationForHTML(const Rec2020<float>&);
-WEBCORE_EXPORT String serializationForRenderTreeAsText(const Rec2020<float>&);
-
-WEBCORE_EXPORT String serializationForCSS(const SRGBA<float>&);
-WEBCORE_EXPORT String serializationForHTML(const SRGBA<float>&);
-WEBCORE_EXPORT String serializationForRenderTreeAsText(const SRGBA<float>&);
-
-WEBCORE_EXPORT String serializationForCSS(SRGBA<uint8_t>);
-WEBCORE_EXPORT String serializationForHTML(SRGBA<uint8_t>);
-WEBCORE_EXPORT String serializationForRenderTreeAsText(SRGBA<uint8_t>);
-
}
Modified: trunk/Source/WebCore/platform/graphics/ColorSpace.cpp (272310 => 272311)
--- trunk/Source/WebCore/platform/graphics/ColorSpace.cpp 2021-02-03 14:28:16 UTC (rev 272310)
+++ trunk/Source/WebCore/platform/graphics/ColorSpace.cpp 2021-02-03 14:38:52 UTC (rev 272311)
@@ -54,6 +54,9 @@
case ColorSpace::SRGB:
ts << "sRGB";
break;
+ case ColorSpace::XYZ_D50:
+ ts << "XYZ";
+ break;
}
return ts;
}
Modified: trunk/Source/WebCore/platform/graphics/ColorSpace.h (272310 => 272311)
--- trunk/Source/WebCore/platform/graphics/ColorSpace.h 2021-02-03 14:28:16 UTC (rev 272310)
+++ trunk/Source/WebCore/platform/graphics/ColorSpace.h 2021-02-03 14:38:52 UTC (rev 272311)
@@ -25,6 +25,8 @@
#pragma once
+#include "ColorTypes.h"
+
namespace WTF {
class TextStream;
}
@@ -39,8 +41,48 @@
ProPhotoRGB,
Rec2020,
SRGB,
+ XYZ_D50,
};
WEBCORE_EXPORT WTF::TextStream& operator<<(WTF::TextStream&, ColorSpace);
+
+template<typename> struct ColorSpaceMapping;
+template<typename T> struct ColorSpaceMapping<A98RGB<T>> { static constexpr auto colorSpace { ColorSpace::A98RGB }; };
+template<typename T> struct ColorSpaceMapping<DisplayP3<T>> { static constexpr auto colorSpace { ColorSpace::DisplayP3 }; };
+template<typename T> struct ColorSpaceMapping<Lab<T>> { static constexpr auto colorSpace { ColorSpace::Lab }; };
+template<typename T> struct ColorSpaceMapping<LinearSRGBA<T>> { static constexpr auto colorSpace { ColorSpace::LinearRGB }; };
+template<typename T> struct ColorSpaceMapping<ProPhotoRGB<T>> { static constexpr auto colorSpace { ColorSpace::ProPhotoRGB }; };
+template<typename T> struct ColorSpaceMapping<Rec2020<T>> { static constexpr auto colorSpace { ColorSpace::Rec2020 }; };
+template<typename T> struct ColorSpaceMapping<SRGBA<T>> { static constexpr auto colorSpace { ColorSpace::SRGB }; };
+template<typename T> struct ColorSpaceMapping<XYZA<T, WhitePoint::D50>> { static constexpr auto colorSpace { ColorSpace::XYZ_D50 }; };
+
+template<typename ColorType> constexpr ColorSpace ColorSpaceFor = ColorSpaceMapping<ColorType>::colorSpace;
+
+
+template<typename T, typename Functor> constexpr decltype(auto) callWithColorType(const ColorComponents<T>& components, ColorSpace colorSpace, Functor&& functor)
+{
+ switch (colorSpace) {
+ case ColorSpace::A98RGB:
+ return std::invoke(std::forward<Functor>(functor), makeFromComponents<A98RGB<T>>(components));
+ case ColorSpace::DisplayP3:
+ return std::invoke(std::forward<Functor>(functor), makeFromComponents<DisplayP3<T>>(components));
+ case ColorSpace::Lab:
+ return std::invoke(std::forward<Functor>(functor), makeFromComponents<Lab<T>>(components));
+ case ColorSpace::LinearRGB:
+ return std::invoke(std::forward<Functor>(functor), makeFromComponents<LinearSRGBA<T>>(components));
+ case ColorSpace::ProPhotoRGB:
+ return std::invoke(std::forward<Functor>(functor), makeFromComponents<ProPhotoRGB<T>>(components));
+ case ColorSpace::Rec2020:
+ return std::invoke(std::forward<Functor>(functor), makeFromComponents<Rec2020<T>>(components));
+ case ColorSpace::SRGB:
+ return std::invoke(std::forward<Functor>(functor), makeFromComponents<SRGBA<T>>(components));
+ case ColorSpace::XYZ_D50:
+ return std::invoke(std::forward<Functor>(functor), makeFromComponents<XYZA<T, WhitePoint::D50>>(components));
+ }
+
+ ASSERT_NOT_REACHED();
+ return std::invoke(std::forward<Functor>(functor), makeFromComponents<SRGBA<T>>(components));
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/ColorTypes.h (272310 => 272311)
--- trunk/Source/WebCore/platform/graphics/ColorTypes.h 2021-02-03 14:28:16 UTC (rev 272310)
+++ trunk/Source/WebCore/platform/graphics/ColorTypes.h 2021-02-03 14:38:52 UTC (rev 272311)
@@ -27,7 +27,6 @@
#include "ColorComponents.h"
#include "ColorModels.h"
-#include "ColorSpace.h"
namespace WebCore {
@@ -149,9 +148,6 @@
#endif
-template<typename, typename = void> inline constexpr bool HasColorSpaceMember = false;
-template<typename T> inline constexpr bool HasColorSpaceMember<T, std::void_t<decltype(std::declval<T>().colorSpace)>> = true;
-
template<typename, typename = void> inline constexpr bool IsConvertibleToColorComponents = false;
template<typename T> inline constexpr bool IsConvertibleToColorComponents<T, std::void_t<decltype(asColorComponents(std::declval<T>()))>> = true;
@@ -162,8 +158,8 @@
template<typename T, typename U> inline constexpr bool HasComponentTypeValue<T, U, true> = std::is_same_v<typename T::ComponentType, U>;
template<typename T, typename U> inline constexpr bool HasComponentType = HasComponentTypeValue<T, U, HasComponentTypeMember<T>>;
-template<typename T> inline constexpr bool IsColorType = HasColorSpaceMember<T> && IsConvertibleToColorComponents<T> && HasComponentTypeMember<T>;
-template<typename T, typename U> inline constexpr bool IsColorTypeWithComponentType = HasColorSpaceMember<T> && IsConvertibleToColorComponents<T> && HasComponentType<T, U>;
+template<typename T> inline constexpr bool IsColorType = IsConvertibleToColorComponents<T> && HasComponentTypeMember<T>;
+template<typename T, typename U> inline constexpr bool IsColorTypeWithComponentType = IsConvertibleToColorComponents<T> && HasComponentType<T, U>;
template<typename Parent> struct ColorWithAlphaHelper {
// Helper to allow convenient syntax for working with color types.
@@ -228,7 +224,6 @@
using RGBAType<A98RGB, T, RGBModel<T>>::RGBAType;
using LinearCounterpart = LinearA98RGB<T>;
using ReferenceXYZ = XYZA<T, WhitePoint::D65>;
- static constexpr auto colorSpace = ColorSpace::A98RGB;
};
template<typename T> A98RGB(T, T, T, T) -> A98RGB<T>;
@@ -236,7 +231,6 @@
using RGBAType<DisplayP3, T, RGBModel<T>>::RGBAType;
using LinearCounterpart = LinearDisplayP3<T>;
using ReferenceXYZ = XYZA<T, WhitePoint::D65>;
- static constexpr auto colorSpace = ColorSpace::DisplayP3;
};
template<typename T> DisplayP3(T, T, T, T) -> DisplayP3<T>;
@@ -286,7 +280,6 @@
using RGBAType<LinearSRGBA, T, RGBModel<T>>::RGBAType;
using GammaEncodedCounterpart = SRGBA<T>;
using ReferenceXYZ = XYZA<T, WhitePoint::D65>;
- static constexpr auto colorSpace = ColorSpace::LinearRGB;
};
template<typename T> LinearSRGBA(T, T, T, T) -> LinearSRGBA<T>;
@@ -294,7 +287,6 @@
using RGBAType<ProPhotoRGB, T, RGBModel<T>>::RGBAType;
using LinearCounterpart = LinearProPhotoRGB<T>;
using ReferenceXYZ = XYZA<T, WhitePoint::D50>;
- static constexpr auto colorSpace = ColorSpace::ProPhotoRGB;
};
template<typename T> ProPhotoRGB(T, T, T, T) -> ProPhotoRGB<T>;
@@ -302,7 +294,6 @@
using RGBAType<Rec2020, T, RGBModel<T>>::RGBAType;
using LinearCounterpart = LinearRec2020<T>;
using ReferenceXYZ = XYZA<T, WhitePoint::D65>;
- static constexpr auto colorSpace { ColorSpace::Rec2020 };
};
template<typename T> Rec2020(T, T, T, T) -> Rec2020<T>;
@@ -310,7 +301,6 @@
using RGBAType<SRGBA, T, RGBModel<T>>::RGBAType;
using LinearCounterpart = LinearSRGBA<T>;
using ReferenceXYZ = XYZA<T, WhitePoint::D65>;
- static constexpr auto colorSpace { ColorSpace::SRGB };
};
template<typename T> SRGBA(T, T, T, T) -> SRGBA<T>;
@@ -320,7 +310,6 @@
using ComponentType = T;
using Model = LabModel<T>;
using ReferenceXYZ = XYZA<T, WhitePoint::D50>;
- static constexpr auto colorSpace = ColorSpace::Lab;
constexpr Lab(T lightness, T a, T b, T alpha = AlphaTraits<T>::opaque)
: lightness { lightness }
Modified: trunk/Source/WebCore/platform/graphics/ColorUtilities.h (272310 => 272311)
--- trunk/Source/WebCore/platform/graphics/ColorUtilities.h 2021-02-03 14:28:16 UTC (rev 272310)
+++ trunk/Source/WebCore/platform/graphics/ColorUtilities.h 2021-02-03 14:38:52 UTC (rev 272311)
@@ -171,6 +171,11 @@
return makeFromComponents<ColorType>(copy);
}
+template<WhitePoint W> constexpr bool isBlack(const XYZA<float, W>& color)
+{
+ return color.y == 0 && color.alpha == AlphaTraits<float>::opaque;
+}
+
constexpr bool isBlack(const Lab<float>& color)
{
return color.lightness == 0 && color.alpha == AlphaTraits<float>::opaque;
@@ -184,6 +189,11 @@
return c1 == ranges[0].min && c2 == ranges[1].min && c3 == ranges[2].min && alpha == AlphaTraits<typename ColorType::ComponentType>::opaque;
}
+template<WhitePoint W> constexpr bool isWhite(const XYZA<float, W>& color)
+{
+ return color.y == 1 && color.alpha == AlphaTraits<float>::opaque;
+}
+
constexpr bool isWhite(const Lab<float>& color)
{
return color.lightness == 100 && color.alpha == AlphaTraits<float>::opaque;
Modified: trunk/Source/WebCore/platform/graphics/ExtendedColor.h (272310 => 272311)
--- trunk/Source/WebCore/platform/graphics/ExtendedColor.h 2021-02-03 14:28:16 UTC (rev 272310)
+++ trunk/Source/WebCore/platform/graphics/ExtendedColor.h 2021-02-03 14:38:52 UTC (rev 272311)
@@ -66,7 +66,7 @@
template<typename ColorType> inline Ref<ExtendedColor> ExtendedColor::create(const ColorType& color)
{
- return adoptRef(*new ExtendedColor(asColorComponents(color), color.colorSpace));
+ return adoptRef(*new ExtendedColor(asColorComponents(color), ColorSpaceFor<ColorType>));
}
inline Ref<ExtendedColor> ExtendedColor::create(ColorComponents<float> components, ColorSpace colorSpace)
Modified: trunk/Source/WebCore/platform/graphics/cg/ColorSpaceCG.cpp (272310 => 272311)
--- trunk/Source/WebCore/platform/graphics/cg/ColorSpaceCG.cpp 2021-02-03 14:28:16 UTC (rev 272310)
+++ trunk/Source/WebCore/platform/graphics/cg/ColorSpaceCG.cpp 2021-02-03 14:38:52 UTC (rev 272311)
@@ -148,6 +148,20 @@
return sRGBColorSpace;
}
+CGColorSpaceRef xyzD50ColorSpaceRef()
+{
+ static CGColorSpaceRef xyzD50ColorSpace;
+ static std::once_flag onceFlag;
+ std::call_once(onceFlag, [] {
+#if PLATFORM(COCOA)
+ xyzD50ColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericXYZ);
+#else
+ xyzD50ColorSpace = sRGBColorSpaceRef();
+#endif
+ });
+ return xyzD50ColorSpace;
}
+}
+
#endif // USE(CG)
Modified: trunk/Source/WebCore/platform/graphics/cg/ColorSpaceCG.h (272310 => 272311)
--- trunk/Source/WebCore/platform/graphics/cg/ColorSpaceCG.h 2021-02-03 14:28:16 UTC (rev 272310)
+++ trunk/Source/WebCore/platform/graphics/cg/ColorSpaceCG.h 2021-02-03 14:38:52 UTC (rev 272311)
@@ -39,6 +39,7 @@
WEBCORE_EXPORT CGColorSpaceRef proPhotoRGBColorSpaceRef();
WEBCORE_EXPORT CGColorSpaceRef rec2020ColorSpaceRef();
WEBCORE_EXPORT CGColorSpaceRef sRGBColorSpaceRef();
+WEBCORE_EXPORT CGColorSpaceRef xyzD50ColorSpaceRef();
static inline CGColorSpaceRef cachedCGColorSpace(ColorSpace colorSpace)
{
@@ -57,6 +58,8 @@
return rec2020ColorSpaceRef();
case ColorSpace::SRGB:
return sRGBColorSpaceRef();
+ case ColorSpace::XYZ_D50:
+ return xyzD50ColorSpaceRef();
}
ASSERT_NOT_REACHED();
return sRGBColorSpaceRef();