Diff
Modified: trunk/LayoutTests/ChangeLog (272122 => 272123)
--- trunk/LayoutTests/ChangeLog 2021-01-30 23:35:46 UTC (rev 272122)
+++ trunk/LayoutTests/ChangeLog 2021-01-31 07:52:56 UTC (rev 272123)
@@ -1,3 +1,21 @@
+2021-01-30 Sam Weinig <wei...@apple.com>
+
+ Add support for color(rec2020 ...) as part of CSS Color 4
+ https://bugs.webkit.org/show_bug.cgi?id=221114
+
+ Reviewed by Antti Koivisto.
+
+ * TestExpectations:
+ Remove now passing rec2020 tests.
+
+ * fast/css/parsing-a98rgb-colors-expected.txt: Removed.
+ * fast/css/parsing-a98rgb-colors.html: Removed.
+ * fast/css/parsing-color-function-expected.txt: Added.
+ * fast/css/parsing-color-function.html: Added.
+ Re-write parsing-a98rgb-colors.html to test all rgb types in the color() function as
+ they all have the same parsing requirements. Color(lab ) must still be parsed separately
+ as it has a different grammar.
+
2021-01-30 Wenson Hsieh <wenson_hs...@apple.com>
[macOS] Remove support for image controls
Modified: trunk/LayoutTests/TestExpectations (272122 => 272123)
--- trunk/LayoutTests/TestExpectations 2021-01-30 23:35:46 UTC (rev 272122)
+++ trunk/LayoutTests/TestExpectations 2021-01-31 07:52:56 UTC (rev 272123)
@@ -4606,8 +4606,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-009.html [ ImageOnlyFailure ] # Requires prophoto-rgb support
webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-010.html [ ImageOnlyFailure ] # Requires prophoto-rgb support
-webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-011.html [ ImageOnlyFailure ] # Requires rec2020 support
-webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-012.html [ ImageOnlyFailure ] # Requires rec2020 support
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
Deleted: trunk/LayoutTests/fast/css/parsing-a98rgb-colors-expected.txt (272122 => 272123)
--- trunk/LayoutTests/fast/css/parsing-a98rgb-colors-expected.txt 2021-01-30 23:35:46 UTC (rev 272122)
+++ trunk/LayoutTests/fast/css/parsing-a98rgb-colors-expected.txt 2021-01-31 07:52:56 UTC (rev 272123)
@@ -1,37 +0,0 @@
-Test the parsing of lab, lch and gray colors.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-PASS computedStyle("background-color", "color(a98-rgb 0% 0% 0%)") is "color(a98-rgb 0 0 0)"
-PASS computedStyle("background-color", "color(a98-rgb 10% 10% 10%)") is "color(a98-rgb 0.1 0.1 0.1)"
-PASS computedStyle("background-color", "color(a98-rgb .2 .2 25%)") is "color(a98-rgb 0.2 0.2 0.25)"
-PASS computedStyle("background-color", "color(a98-rgb 0 0 0 / 1)") is "color(a98-rgb 0 0 0)"
-PASS computedStyle("background-color", "color(a98-rgb 0% 0 0 / 0.5)") is "color(a98-rgb 0 0 0 / 0.5)"
-PASS computedStyle("background-color", "color(a98-rgb 20% 0 10/0.5)") is "color(a98-rgb 0.2 0 1 / 0.5)"
-PASS computedStyle("background-color", "color(a98-rgb 20% 0 10/50%)") is "color(a98-rgb 0.2 0 1 / 0.5)"
-PASS computedStyle("background-color", "color(a98-rgb 400% 0 10/50%)") is "color(a98-rgb 1 0 1 / 0.5)"
-PASS computedStyle("background-color", "color(a98-rgb 50% -160 160)") is "color(a98-rgb 0.5 0 1)"
-PASS computedStyle("background-color", "color(a98-rgb 50% -200 200)") is "color(a98-rgb 0.5 0 1)"
-PASS computedStyle("background-color", "color(a98-rgb 0 0 0 / -10%)") is "color(a98-rgb 0 0 0 / 0)"
-PASS computedStyle("background-color", "color(a98-rgb 0 0 0 / 110%)") is "color(a98-rgb 0 0 0)"
-PASS computedStyle("background-color", "color(a98-rgb 0 0 0 / 300%)") is "color(a98-rgb 0 0 0)"
-PASS computedStyle("background-color", "color(a98-rgb 50% -200)") is "color(a98-rgb 0.5 0 0)"
-PASS computedStyle("background-color", "color(a98-rgb 50%)") is "color(a98-rgb 0.5 0 0)"
-PASS computedStyle("background-color", "color(a98-rgb)") is "color(a98-rgb 0 0 0)"
-PASS computedStyle("background-color", "color(a98-rgb 50% -200 / 0.5)") is "color(a98-rgb 0.5 0 0 / 0.5)"
-PASS computedStyle("background-color", "color(a98-rgb 50% / 0.5)") is "color(a98-rgb 0.5 0 0 / 0.5)"
-PASS computedStyle("background-color", "color(a98-rgb / 0.5)") is "color(a98-rgb 0 0 0 / 0.5)"
-
-Test invalid values
-PASS computedStyle("background-color", "color(a98-rgb 0 0 0 0)") is "rgba(0, 0, 0, 0)"
-PASS computedStyle("background-color", "color(a98-rgb 0deg 0% 0)") is "rgba(0, 0, 0, 0)"
-PASS computedStyle("background-color", "color(a98-rgb 0% 0 0 1)") is "rgba(0, 0, 0, 0)"
-PASS computedStyle("background-color", "color(a98-rgb 0% 0 0 10%)") is "rgba(0, 0, 0, 0)"
-PASS computedStyle("background-color", "color(a98-rgb 0% 0 0deg)") is "rgba(0, 0, 0, 0)"
-PASS computedStyle("background-color", "color(a98-rgb 0% 0% 0deg)") is "rgba(0, 0, 0, 0)"
-PASS computedStyle("background-color", "color(a98-rgb 40% 0 0deg)") is "rgba(0, 0, 0, 0)"
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
Deleted: trunk/LayoutTests/fast/css/parsing-a98rgb-colors.html (272122 => 272123)
--- trunk/LayoutTests/fast/css/parsing-a98rgb-colors.html 2021-01-30 23:35:46 UTC (rev 272122)
+++ trunk/LayoutTests/fast/css/parsing-a98rgb-colors.html 2021-01-31 07:52:56 UTC (rev 272123)
@@ -1,71 +0,0 @@
-<html>
- <script src=""
-</head>
-<body>
-<script>
- description("Test the parsing of lab, lch and gray colors.");
-
- function computedStyle(property, value)
- {
- var div = document.createElement("div");
- document.body.appendChild(div);
- div.style.setProperty(property, value);
- var computedValue = getComputedStyle(div).getPropertyValue(property);
- document.body.removeChild(div);
- return computedValue;
- }
-
- function innerStyle(property, value)
- {
- var div = document.createElement("div");
- div.style.setProperty(property, value);
- return div.style.getPropertyValue(property);
- }
-
- function testComputed(property, value, expected)
- {
- shouldBeEqualToString('computedStyle("' + property + '", "' + value + '")', expected);
- }
-
- function testInner(property, value, expected)
- {
- if (expected === null)
- expected = "";
- shouldBeEqualToString('innerStyle("' + property + '", "' + value + '")', expected);
- }
-
- testComputed("background-color", "color(a98-rgb 0% 0% 0%)", "color(a98-rgb 0 0 0)");
- testComputed("background-color", "color(a98-rgb 10% 10% 10%)", "color(a98-rgb 0.1 0.1 0.1)");
- testComputed("background-color", "color(a98-rgb .2 .2 25%)", "color(a98-rgb 0.2 0.2 0.25)");
- testComputed("background-color", "color(a98-rgb 0 0 0 / 1)", "color(a98-rgb 0 0 0)");
- testComputed("background-color", "color(a98-rgb 0% 0 0 / 0.5)", "color(a98-rgb 0 0 0 / 0.5)");
- testComputed("background-color", "color(a98-rgb 20% 0 10/0.5)", "color(a98-rgb 0.2 0 1 / 0.5)");
- testComputed("background-color", "color(a98-rgb 20% 0 10/50%)", "color(a98-rgb 0.2 0 1 / 0.5)");
- testComputed("background-color", "color(a98-rgb 400% 0 10/50%)", "color(a98-rgb 1 0 1 / 0.5)");
- testComputed("background-color", "color(a98-rgb 50% -160 160)", "color(a98-rgb 0.5 0 1)");
- testComputed("background-color", "color(a98-rgb 50% -200 200)", "color(a98-rgb 0.5 0 1)");
- testComputed("background-color", "color(a98-rgb 0 0 0 / -10%)", "color(a98-rgb 0 0 0 / 0)");
- testComputed("background-color", "color(a98-rgb 0 0 0 / 110%)", "color(a98-rgb 0 0 0)");
- testComputed("background-color", "color(a98-rgb 0 0 0 / 300%)", "color(a98-rgb 0 0 0)");
- testComputed("background-color", "color(a98-rgb 50% -200)", "color(a98-rgb 0.5 0 0)");
- testComputed("background-color", "color(a98-rgb 50%)", "color(a98-rgb 0.5 0 0)");
- testComputed("background-color", "color(a98-rgb)", "color(a98-rgb 0 0 0)");
- testComputed("background-color", "color(a98-rgb 50% -200 / 0.5)", "color(a98-rgb 0.5 0 0 / 0.5)");
- testComputed("background-color", "color(a98-rgb 50% / 0.5)", "color(a98-rgb 0.5 0 0 / 0.5)");
- testComputed("background-color", "color(a98-rgb / 0.5)", "color(a98-rgb 0 0 0 / 0.5)");
-
- debug('');
- debug('Test invalid values');
- testComputed("background-color", "color(a98-rgb 0 0 0 0)", "rgba(0, 0, 0, 0)");
- testComputed("background-color", "color(a98-rgb 0deg 0% 0)", "rgba(0, 0, 0, 0)");
- testComputed("background-color", "color(a98-rgb 0% 0 0 1)", "rgba(0, 0, 0, 0)");
- testComputed("background-color", "color(a98-rgb 0% 0 0 10%)", "rgba(0, 0, 0, 0)");
- testComputed("background-color", "color(a98-rgb 0% 0 0deg)", "rgba(0, 0, 0, 0)");
- testComputed("background-color", "color(a98-rgb 0% 0% 0deg)", "rgba(0, 0, 0, 0)");
- testComputed("background-color", "color(a98-rgb 40% 0 0deg)", "rgba(0, 0, 0, 0)");
-
-</script>
-
-<script src=""
-</body>
-</html>
Added: trunk/LayoutTests/fast/css/parsing-color-function-expected.txt (0 => 272123)
--- trunk/LayoutTests/fast/css/parsing-color-function-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css/parsing-color-function-expected.txt 2021-01-31 07:52:56 UTC (rev 272123)
@@ -0,0 +1,99 @@
+Test the parsing of color() function colors.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+Testing color(srgb ...)
+PASS computedStyle("background-color", "color(srgb 0% 0% 0%)") is "color(srgb 0 0 0)"
+PASS computedStyle("background-color", "color(srgb 10% 10% 10%)") is "color(srgb 0.1 0.1 0.1)"
+PASS computedStyle("background-color", "color(srgb .2 .2 25%)") is "color(srgb 0.2 0.2 0.25)"
+PASS computedStyle("background-color", "color(srgb 0 0 0 / 1)") is "color(srgb 0 0 0)"
+PASS computedStyle("background-color", "color(srgb 0% 0 0 / 0.5)") is "color(srgb 0 0 0 / 0.5)"
+PASS computedStyle("background-color", "color(srgb 20% 0 10/0.5)") is "color(srgb 0.2 0 1 / 0.5)"
+PASS computedStyle("background-color", "color(srgb 20% 0 10/50%)") is "color(srgb 0.2 0 1 / 0.5)"
+PASS computedStyle("background-color", "color(srgb 400% 0 10/50%)") is "color(srgb 1 0 1 / 0.5)"
+PASS computedStyle("background-color", "color(srgb 50% -160 160)") is "color(srgb 0.5 0 1)"
+PASS computedStyle("background-color", "color(srgb 50% -200 200)") is "color(srgb 0.5 0 1)"
+PASS computedStyle("background-color", "color(srgb 0 0 0 / -10%)") is "color(srgb 0 0 0 / 0)"
+PASS computedStyle("background-color", "color(srgb 0 0 0 / 110%)") is "color(srgb 0 0 0)"
+PASS computedStyle("background-color", "color(srgb 0 0 0 / 300%)") is "color(srgb 0 0 0)"
+PASS computedStyle("background-color", "color(srgb 50% -200)") is "color(srgb 0.5 0 0)"
+PASS computedStyle("background-color", "color(srgb 50%)") is "color(srgb 0.5 0 0)"
+PASS computedStyle("background-color", "color(srgb)") is "color(srgb 0 0 0)"
+PASS computedStyle("background-color", "color(srgb 50% -200 / 0.5)") is "color(srgb 0.5 0 0 / 0.5)"
+PASS computedStyle("background-color", "color(srgb 50% / 0.5)") is "color(srgb 0.5 0 0 / 0.5)"
+PASS computedStyle("background-color", "color(srgb / 0.5)") is "color(srgb 0 0 0 / 0.5)"
+
+Test invalid values
+PASS computedStyle("background-color", "color(srgb 0 0 0 0)") is "rgba(0, 0, 0, 0)"
+PASS computedStyle("background-color", "color(srgb 0deg 0% 0)") is "rgba(0, 0, 0, 0)"
+PASS computedStyle("background-color", "color(srgb 0% 0 0 1)") is "rgba(0, 0, 0, 0)"
+PASS computedStyle("background-color", "color(srgb 0% 0 0 10%)") is "rgba(0, 0, 0, 0)"
+PASS computedStyle("background-color", "color(srgb 0% 0 0deg)") is "rgba(0, 0, 0, 0)"
+PASS computedStyle("background-color", "color(srgb 0% 0% 0deg)") is "rgba(0, 0, 0, 0)"
+PASS computedStyle("background-color", "color(srgb 40% 0 0deg)") is "rgba(0, 0, 0, 0)"
+
+Testing color(a98-rgb ...)
+PASS computedStyle("background-color", "color(a98-rgb 0% 0% 0%)") is "color(a98-rgb 0 0 0)"
+PASS computedStyle("background-color", "color(a98-rgb 10% 10% 10%)") is "color(a98-rgb 0.1 0.1 0.1)"
+PASS computedStyle("background-color", "color(a98-rgb .2 .2 25%)") is "color(a98-rgb 0.2 0.2 0.25)"
+PASS computedStyle("background-color", "color(a98-rgb 0 0 0 / 1)") is "color(a98-rgb 0 0 0)"
+PASS computedStyle("background-color", "color(a98-rgb 0% 0 0 / 0.5)") is "color(a98-rgb 0 0 0 / 0.5)"
+PASS computedStyle("background-color", "color(a98-rgb 20% 0 10/0.5)") is "color(a98-rgb 0.2 0 1 / 0.5)"
+PASS computedStyle("background-color", "color(a98-rgb 20% 0 10/50%)") is "color(a98-rgb 0.2 0 1 / 0.5)"
+PASS computedStyle("background-color", "color(a98-rgb 400% 0 10/50%)") is "color(a98-rgb 1 0 1 / 0.5)"
+PASS computedStyle("background-color", "color(a98-rgb 50% -160 160)") is "color(a98-rgb 0.5 0 1)"
+PASS computedStyle("background-color", "color(a98-rgb 50% -200 200)") is "color(a98-rgb 0.5 0 1)"
+PASS computedStyle("background-color", "color(a98-rgb 0 0 0 / -10%)") is "color(a98-rgb 0 0 0 / 0)"
+PASS computedStyle("background-color", "color(a98-rgb 0 0 0 / 110%)") is "color(a98-rgb 0 0 0)"
+PASS computedStyle("background-color", "color(a98-rgb 0 0 0 / 300%)") is "color(a98-rgb 0 0 0)"
+PASS computedStyle("background-color", "color(a98-rgb 50% -200)") is "color(a98-rgb 0.5 0 0)"
+PASS computedStyle("background-color", "color(a98-rgb 50%)") is "color(a98-rgb 0.5 0 0)"
+PASS computedStyle("background-color", "color(a98-rgb)") is "color(a98-rgb 0 0 0)"
+PASS computedStyle("background-color", "color(a98-rgb 50% -200 / 0.5)") is "color(a98-rgb 0.5 0 0 / 0.5)"
+PASS computedStyle("background-color", "color(a98-rgb 50% / 0.5)") is "color(a98-rgb 0.5 0 0 / 0.5)"
+PASS computedStyle("background-color", "color(a98-rgb / 0.5)") is "color(a98-rgb 0 0 0 / 0.5)"
+
+Test invalid values
+PASS computedStyle("background-color", "color(a98-rgb 0 0 0 0)") is "rgba(0, 0, 0, 0)"
+PASS computedStyle("background-color", "color(a98-rgb 0deg 0% 0)") is "rgba(0, 0, 0, 0)"
+PASS computedStyle("background-color", "color(a98-rgb 0% 0 0 1)") is "rgba(0, 0, 0, 0)"
+PASS computedStyle("background-color", "color(a98-rgb 0% 0 0 10%)") is "rgba(0, 0, 0, 0)"
+PASS computedStyle("background-color", "color(a98-rgb 0% 0 0deg)") is "rgba(0, 0, 0, 0)"
+PASS computedStyle("background-color", "color(a98-rgb 0% 0% 0deg)") is "rgba(0, 0, 0, 0)"
+PASS computedStyle("background-color", "color(a98-rgb 40% 0 0deg)") is "rgba(0, 0, 0, 0)"
+
+Testing color(rec2020 ...)
+PASS computedStyle("background-color", "color(rec2020 0% 0% 0%)") is "color(rec2020 0 0 0)"
+PASS computedStyle("background-color", "color(rec2020 10% 10% 10%)") is "color(rec2020 0.1 0.1 0.1)"
+PASS computedStyle("background-color", "color(rec2020 .2 .2 25%)") is "color(rec2020 0.2 0.2 0.25)"
+PASS computedStyle("background-color", "color(rec2020 0 0 0 / 1)") is "color(rec2020 0 0 0)"
+PASS computedStyle("background-color", "color(rec2020 0% 0 0 / 0.5)") is "color(rec2020 0 0 0 / 0.5)"
+PASS computedStyle("background-color", "color(rec2020 20% 0 10/0.5)") is "color(rec2020 0.2 0 1 / 0.5)"
+PASS computedStyle("background-color", "color(rec2020 20% 0 10/50%)") is "color(rec2020 0.2 0 1 / 0.5)"
+PASS computedStyle("background-color", "color(rec2020 400% 0 10/50%)") is "color(rec2020 1 0 1 / 0.5)"
+PASS computedStyle("background-color", "color(rec2020 50% -160 160)") is "color(rec2020 0.5 0 1)"
+PASS computedStyle("background-color", "color(rec2020 50% -200 200)") is "color(rec2020 0.5 0 1)"
+PASS computedStyle("background-color", "color(rec2020 0 0 0 / -10%)") is "color(rec2020 0 0 0 / 0)"
+PASS computedStyle("background-color", "color(rec2020 0 0 0 / 110%)") is "color(rec2020 0 0 0)"
+PASS computedStyle("background-color", "color(rec2020 0 0 0 / 300%)") is "color(rec2020 0 0 0)"
+PASS computedStyle("background-color", "color(rec2020 50% -200)") is "color(rec2020 0.5 0 0)"
+PASS computedStyle("background-color", "color(rec2020 50%)") is "color(rec2020 0.5 0 0)"
+PASS computedStyle("background-color", "color(rec2020)") is "color(rec2020 0 0 0)"
+PASS computedStyle("background-color", "color(rec2020 50% -200 / 0.5)") is "color(rec2020 0.5 0 0 / 0.5)"
+PASS computedStyle("background-color", "color(rec2020 50% / 0.5)") is "color(rec2020 0.5 0 0 / 0.5)"
+PASS computedStyle("background-color", "color(rec2020 / 0.5)") is "color(rec2020 0 0 0 / 0.5)"
+
+Test invalid values
+PASS computedStyle("background-color", "color(rec2020 0 0 0 0)") is "rgba(0, 0, 0, 0)"
+PASS computedStyle("background-color", "color(rec2020 0deg 0% 0)") is "rgba(0, 0, 0, 0)"
+PASS computedStyle("background-color", "color(rec2020 0% 0 0 1)") is "rgba(0, 0, 0, 0)"
+PASS computedStyle("background-color", "color(rec2020 0% 0 0 10%)") is "rgba(0, 0, 0, 0)"
+PASS computedStyle("background-color", "color(rec2020 0% 0 0deg)") is "rgba(0, 0, 0, 0)"
+PASS computedStyle("background-color", "color(rec2020 0% 0% 0deg)") is "rgba(0, 0, 0, 0)"
+PASS computedStyle("background-color", "color(rec2020 40% 0 0deg)") is "rgba(0, 0, 0, 0)"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/css/parsing-color-function.html (0 => 272123)
--- trunk/LayoutTests/fast/css/parsing-color-function.html (rev 0)
+++ trunk/LayoutTests/fast/css/parsing-color-function.html 2021-01-31 07:52:56 UTC (rev 272123)
@@ -0,0 +1,75 @@
+<html>
+ <script src=""
+</head>
+<body>
+<script>
+ description("Test the parsing of color() function colors.");
+
+ function computedStyle(property, value)
+ {
+ var div = document.createElement("div");
+ document.body.appendChild(div);
+ div.style.setProperty(property, value);
+ var computedValue = getComputedStyle(div).getPropertyValue(property);
+ document.body.removeChild(div);
+ return computedValue;
+ }
+
+ function innerStyle(property, value)
+ {
+ var div = document.createElement("div");
+ div.style.setProperty(property, value);
+ return div.style.getPropertyValue(property);
+ }
+
+ function testComputed(property, value, expected)
+ {
+ shouldBeEqualToString('computedStyle("' + property + '", "' + value + '")', expected);
+ }
+
+ function testInner(property, value, expected)
+ {
+ if (expected === null)
+ expected = "";
+ shouldBeEqualToString('innerStyle("' + property + '", "' + value + '")', expected);
+ }
+
+ for (const color of [ "srgb", "a98-rgb", "rec2020" ]) {
+ debug('');
+ debug(`Testing color(${color} ...)`);
+
+ testComputed("background-color", `color(${color} 0% 0% 0%)`, `color(${color} 0 0 0)`);
+ testComputed("background-color", `color(${color} 10% 10% 10%)`, `color(${color} 0.1 0.1 0.1)`);
+ testComputed("background-color", `color(${color} .2 .2 25%)`, `color(${color} 0.2 0.2 0.25)`);
+ testComputed("background-color", `color(${color} 0 0 0 / 1)`, `color(${color} 0 0 0)`);
+ testComputed("background-color", `color(${color} 0% 0 0 / 0.5)`, `color(${color} 0 0 0 / 0.5)`);
+ testComputed("background-color", `color(${color} 20% 0 10/0.5)`, `color(${color} 0.2 0 1 / 0.5)`);
+ testComputed("background-color", `color(${color} 20% 0 10/50%)`, `color(${color} 0.2 0 1 / 0.5)`);
+ testComputed("background-color", `color(${color} 400% 0 10/50%)`, `color(${color} 1 0 1 / 0.5)`);
+ testComputed("background-color", `color(${color} 50% -160 160)`, `color(${color} 0.5 0 1)`);
+ testComputed("background-color", `color(${color} 50% -200 200)`, `color(${color} 0.5 0 1)`);
+ testComputed("background-color", `color(${color} 0 0 0 / -10%)`, `color(${color} 0 0 0 / 0)`);
+ testComputed("background-color", `color(${color} 0 0 0 / 110%)`, `color(${color} 0 0 0)`);
+ testComputed("background-color", `color(${color} 0 0 0 / 300%)`, `color(${color} 0 0 0)`);
+ testComputed("background-color", `color(${color} 50% -200)`, `color(${color} 0.5 0 0)`);
+ testComputed("background-color", `color(${color} 50%)`, `color(${color} 0.5 0 0)`);
+ testComputed("background-color", `color(${color})`, `color(${color} 0 0 0)`);
+ testComputed("background-color", `color(${color} 50% -200 / 0.5)`, `color(${color} 0.5 0 0 / 0.5)`);
+ testComputed("background-color", `color(${color} 50% / 0.5)`, `color(${color} 0.5 0 0 / 0.5)`);
+ testComputed("background-color", `color(${color} / 0.5)`, `color(${color} 0 0 0 / 0.5)`);
+
+ debug('');
+ debug('Test invalid values');
+ testComputed("background-color", `color(${color} 0 0 0 0)`, `rgba(0, 0, 0, 0)`);
+ testComputed("background-color", `color(${color} 0deg 0% 0)`, `rgba(0, 0, 0, 0)`);
+ testComputed("background-color", `color(${color} 0% 0 0 1)`, `rgba(0, 0, 0, 0)`);
+ testComputed("background-color", `color(${color} 0% 0 0 10%)`, `rgba(0, 0, 0, 0)`);
+ testComputed("background-color", `color(${color} 0% 0 0deg)`, `rgba(0, 0, 0, 0)`);
+ 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)`);
+ }
+</script>
+
+<script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (272122 => 272123)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-01-30 23:35:46 UTC (rev 272122)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2021-01-31 07:52:56 UTC (rev 272123)
@@ -1,3 +1,21 @@
+2021-01-30 Sam Weinig <wei...@apple.com>
+
+ Add support for color(rec2020 ...) as part of CSS Color 4
+ https://bugs.webkit.org/show_bug.cgi?id=221114
+
+ Reviewed by Antti Koivisto.
+
+ Add some new WPT tests for color(rec2020 ) that will be upstreamed shortly.
+
+ * web-platform-tests/css/css-color/rec2020-001-expected.html: Added.
+ * web-platform-tests/css/css-color/rec2020-001.html: Added.
+ * web-platform-tests/css/css-color/rec2020-002-expected.html: Added.
+ * web-platform-tests/css/css-color/rec2020-002.html: Added.
+ * web-platform-tests/css/css-color/rec2020-003-expected.html: Added.
+ * web-platform-tests/css/css-color/rec2020-003.html: Added.
+ * web-platform-tests/css/css-color/rec2020-004-expected.html: Added.
+ * web-platform-tests/css/css-color/rec2020-004.html: Added.
+
2021-01-30 Wenson Hsieh <wenson_hs...@apple.com>
[macOS] Remove support for image controls
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/predefined-011.html (272122 => 272123)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/predefined-011.html 2021-01-30 23:35:46 UTC (rev 272122)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/predefined-011.html 2021-01-31 07:52:56 UTC (rev 272123)
@@ -8,7 +8,7 @@
<style>
.test { background-color: red; width: 12em; height: 6em; margin-top:0}
.ref { background-color: #009900; width: 12em; height: 6em; margin-bottom: 0}
- .test {background-color: color(rec2020 0.33033 0.55976 0.14863)}
+ .test {background-color: color(rec2020 0.299218 0.533327 0.120785)}
</style>
<body>
<p>Test passes if you see a green square, and no red.</p>
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/predefined-012.html (272122 => 272123)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/predefined-012.html 2021-01-30 23:35:46 UTC (rev 272122)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/predefined-012.html 2021-01-31 07:52:56 UTC (rev 272123)
@@ -8,7 +8,7 @@
<style>
.test { background-color: red; width: 12em; height: 6em; margin-top:0}
.ref { background-color: #009900; width: 12em; height: 6em; margin-bottom: 0}
- .test {background-color: color(rec2020 33.033% 55.976% 14.863%)}
+ .test {background-color: color(rec2020 29.9218% 53.3327% 12.0785%)}
</style>
<body>
<p>Test passes if you see a green square, and no red.</p>
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/rec2020-001-expected.html (0 => 272123)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/rec2020-001-expected.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/rec2020-001-expected.html 2021-01-31 07:52:56 UTC (rev 272123)
@@ -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/rec2020-001.html (0 => 272123)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/rec2020-001.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/rec2020-001.html 2021-01-31 07:52:56 UTC (rev 272123)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Color 4: rec2020</title>
+<link rel="author" title="Sam Weinig" href=""
+<link rel="help" href=""
+<link rel="match" href=""
+<meta name="assert" content="rec2020 with no alpha">
+<style>
+ .test { background-color: red; width: 12em; height: 12em; }
+ .test { background-color: color(rec2020 0.234171 0.429825 0.084989); } /* green (sRGB #008000) converted to rec2020 */
+</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/rec2020-002-expected.html (0 => 272123)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/rec2020-002-expected.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/rec2020-002-expected.html 2021-01-31 07:52:56 UTC (rev 272123)
@@ -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/rec2020-002.html (0 => 272123)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/rec2020-002.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/rec2020-002.html 2021-01-31 07:52:56 UTC (rev 272123)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Color 4: rec2020</title>
+<link rel="author" title="Sam Weinig" href=""
+<link rel="help" href=""
+<link rel="match" href=""
+<meta name="assert" content="rec2020 with no alpha">
+<style>
+ .test { background-color: red; width: 12em; height: 12em; }
+ .test { background-color: color(rec2020 0 0 0); } /* black (sRGB #000000) converted to rec2020 */
+</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/rec2020-003-expected.html (0 => 272123)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/rec2020-003-expected.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/rec2020-003-expected.html 2021-01-31 07:52:56 UTC (rev 272123)
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Color 4: CSS Color 4: rec2020</title>
+<style>
+ body { background-color: grey; }
+ .test { background-color: rgb(99.993% 100% 100%); width: 12em; height: 12em; } /* color(rec2020 1 1 1) converted to sRGB */
+</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/rec2020-003.html (0 => 272123)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/rec2020-003.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/rec2020-003.html 2021-01-31 07:52:56 UTC (rev 272123)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Color 4: rec2020</title>
+<link rel="author" title="Sam Weinig" href=""
+<link rel="help" href=""
+<link rel="match" href=""
+<meta name="assert" content="rec2020 with no alpha">
+<style>
+ body { background-color: grey; }
+ .test { background-color: red; width: 12em; height: 6em; margin-top: 0; }
+ .ref { background-color: rgb(99.993% 100% 100%); width: 12em; height: 6em; margin-bottom: 0; } /* color(rec2020 1 1 1) converted to sRGB */
+ .test { background-color: color(rec2020 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/rec2020-004-expected.html (0 => 272123)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/rec2020-004-expected.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/rec2020-004-expected.html 2021-01-31 07:52:56 UTC (rev 272123)
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Color 4: CSS Color 4: rec2020</title>
+<style>
+ .test { background-color: lab(85.7729% -160.7259 109.2319); width: 12em; height: 12em; } /* color(rec2020 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/rec2020-004.html (0 => 272123)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/rec2020-004.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color/rec2020-004.html 2021-01-31 07:52:56 UTC (rev 272123)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Color 4: rec2020</title>
+<link rel="author" title="Sam Weinig" href=""
+<link rel="help" href=""
+<link rel="match" href=""
+<meta name="assert" content="rec2020 with no alpha">
+<style>
+ .test { background-color: red; width: 12em; height: 6em; margin-top: 0; }
+ .ref { background-color: lab(85.7729% -160.7259 109.2319); width: 12em; height: 6em; margin-bottom: 0; } /* color(rec2020 0 1 0) converted to Lab */
+ .test { background-color: color(rec2020 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>
Modified: trunk/Source/WebCore/ChangeLog (272122 => 272123)
--- trunk/Source/WebCore/ChangeLog 2021-01-30 23:35:46 UTC (rev 272122)
+++ trunk/Source/WebCore/ChangeLog 2021-01-31 07:52:56 UTC (rev 272123)
@@ -1,3 +1,68 @@
+2021-01-30 Sam Weinig <wei...@apple.com>
+
+ Add support for color(rec2020 ...) as part of CSS Color 4
+ https://bugs.webkit.org/show_bug.cgi?id=221114
+
+ Reviewed by Antti Koivisto.
+
+ * css/CSSValueKeywords.in:
+ Add comment to indicate rec2020 is support color function type.
+
+ * css/parser/CSSPropertyParserHelpers.cpp:
+ (WebCore::CSSPropertyParserHelpers::parseColorFunctionForRGBTypes):
+ (WebCore::CSSPropertyParserHelpers::parseColorFunctionParameters):
+ Parse color(rec2020 ) using the existing generic rgb type color function
+ parsing function.
+
+ * platform/graphics/Color.h:
+ Remove overly specific comment that listed all the color types that Color
+ could hold, replacing it with a more generic statement about the functionaly
+ of ExtendedColor. This avoids needing to update this not very useful comment
+ everytime we add a new supported color type.
+
+ * platform/graphics/ColorConversion.cpp:
+ (WebCore::toLinearRec2020):
+ (WebCore::toRec2020):
+ (WebCore::toXYZA):
+ * platform/graphics/ColorConversion.h:
+ (WebCore::toLinearRec2020):
+ (WebCore::toRec2020):
+ (WebCore::toLinearDisplayP3):
+ (WebCore::callWithColorType):
+ Add conversion support for Rec2020, utilizing the Rec2020TransferFunction
+ for gamma correction. Fix incorrect sorting of toLinearDisplayP3.
+
+ * platform/graphics/ColorSerialization.cpp:
+ (WebCore::serialization):
+ (WebCore::serializationForCSS):
+ (WebCore::serializationForHTML):
+ (WebCore::serializationForRenderTreeAsText):
+ * platform/graphics/ColorSerialization.h:
+ Add serialization support, matching other rgb color() function
+ types.
+
+ * platform/graphics/ColorSpace.cpp:
+ (WebCore::operator<<):
+ * platform/graphics/ColorSpace.h:
+ Add Rec2020 as a new ColorSpace.
+
+ * platform/graphics/ColorTransferFunctions.h:
+ (WebCore::Rec2020TransferFunction::toGammaEncoded):
+ (WebCore::Rec2020TransferFunction::toLinear):
+ Add transfer function for Rec2020. Both clamped and unclamped
+ are implemented, though for now, only the clamped variant is
+ being used.
+
+ * platform/graphics/ColorTypes.h:
+ Add Rec2020 and LinearRec2020 types.
+
+ * platform/graphics/cg/ColorSpaceCG.cpp:
+ (WebCore::rec2020ColorSpaceRef):
+ * platform/graphics/cg/ColorSpaceCG.h:
+ (WebCore::cachedCGColorSpace):
+ Add support for the rec2020 as a CoreGraphics color space, where
+ it is known as kCGColorSpaceITUR_2020.
+
2021-01-29 Darin Adler <da...@apple.com>
Check activeDocumentLoader() for null consistently everywhere
Modified: trunk/Source/WebCore/css/CSSValueKeywords.in (272122 => 272123)
--- trunk/Source/WebCore/css/CSSValueKeywords.in 2021-01-30 23:35:46 UTC (rev 272122)
+++ trunk/Source/WebCore/css/CSSValueKeywords.in 2021-01-31 07:52:56 UTC (rev 272123)
@@ -1406,6 +1406,7 @@
a98-rgb
display-p3
// lab
+// rec2020
// sRGB
// prefers-default-appearance
Modified: trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp (272122 => 272123)
--- trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp 2021-01-30 23:35:46 UTC (rev 272122)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp 2021-01-31 07:52:56 UTC (rev 272123)
@@ -894,7 +894,7 @@
template<typename ColorType>
static Color parseColorFunctionForRGBTypes(CSSParserTokenRange& args)
{
- ASSERT(args.peek().id() == CSSValueA98Rgb || args.peek().id() == CSSValueDisplayP3 || args.peek().id() == CSSValueSRGB);
+ ASSERT(args.peek().id() == CSSValueA98Rgb || args.peek().id() == CSSValueDisplayP3 || args.peek().id() == CSSValueRec2020 || args.peek().id() == CSSValueSRGB);
consumeIdentRaw(args);
double channels[3] = { 0, 0, 0 };
@@ -958,6 +958,9 @@
case CSSValueLab:
color = parseColorFunctionForLabParameters(args);
break;
+ case CSSValueRec2020:
+ color = parseColorFunctionForRGBTypes<Rec2020<float>>(args);
+ break;
case CSSValueSRGB:
color = parseColorFunctionForRGBTypes<SRGBA<float>>(args);
break;
Modified: trunk/Source/WebCore/platform/graphics/Color.h (272122 => 272123)
--- trunk/Source/WebCore/platform/graphics/Color.h 2021-01-30 23:35:46 UTC (rev 272122)
+++ trunk/Source/WebCore/platform/graphics/Color.h 2021-01-31 07:52:56 UTC (rev 272123)
@@ -55,10 +55,7 @@
// Able to represent:
// - Special "invalid color" state, treated as transparent black but distinguishable
// - 4x 8-bit (0-255) sRGBA, stored inline, no allocation
-// - 4x float (0-1) sRGBA, stored in a reference counted sub-object
-// - 4x float (0-1) Linear sRGBA, stored in a reference counted sub-object
-// - 4x float (0-1) DisplayP3, stored in a reference counted sub-object
-// - 4x float (0-1) Lab, stored in a reference counted sub-object
+// - 4x float color components + color space, stored in a reference counted sub-object
//
// Additionally, the inline 8-bit sRGBA can have an optional "semantic" bit set on it,
// which indicates the color originated from a CSS semantic color name.
Modified: trunk/Source/WebCore/platform/graphics/ColorConversion.cpp (272122 => 272123)
--- trunk/Source/WebCore/platform/graphics/ColorConversion.cpp 2021-01-30 23:35:46 UTC (rev 272122)
+++ trunk/Source/WebCore/platform/graphics/ColorConversion.cpp 2021-01-31 07:52:56 UTC (rev 272123)
@@ -65,6 +65,22 @@
0.0f, 0.0451133818589026f, 1.043944368900976f
};
+// Rec2020 Matrices.
+
+// https://drafts.csswg.org/css-color/#color-conversion-code
+static constexpr ColorMatrix<3, 3> xyzToLinearRec2020Matrix {
+ 1.7166511879712674f, -0.35567078377639233f, -0.25336628137365974f,
+ -0.6666843518324892f, 1.6164812366349395f, 0.01576854581391113f,
+ 0.017639857445310783f, -0.042770613257808524f, 0.9421031212354738f
+};
+
+// https://drafts.csswg.org/css-color/#color-conversion-code
+static constexpr ColorMatrix<3, 3> linearRec2020ToXYZMatrix {
+ 0.6369580483012914f, 0.14461690358620832f, 0.1688809751641721f,
+ 0.2627002120112671f, 0.6779980715188708f, 0.05930171646986196f,
+ 0.000000000000000f, 0.028072693049087428f, 1.060985057710791f
+};
+
// sRGB Matrices.
// https://en.wikipedia.org/wiki/SRGB
@@ -149,6 +165,18 @@
return toGammaEncoded<SRGBTransferFunction<float, TransferFunctionMode::Unclamped>>(color);
}
+// Rec2020 <-> LinearRec2020 conversions.
+
+LinearRec2020<float> toLinearRec2020(const Rec2020<float>& color)
+{
+ return toLinear<Rec2020TransferFunction<float, TransferFunctionMode::Clamped>>(color);
+}
+
+Rec2020<float> toRec2020(const LinearRec2020<float>& color)
+{
+ return toGammaEncoded<Rec2020TransferFunction<float, TransferFunctionMode::Clamped>>(color);
+}
+
// SRGBA <-> LinearSRGBA conversions.
LinearSRGBA<float> toLinearSRGBA(const SRGBA<float>& color)
@@ -199,6 +227,18 @@
return makeFromComponentsClampingExceptAlpha<XYZA<float>>(linearSRGBToXYZMatrix.transformedColorComponents(asColorComponents(color)));
}
+// - LinearRec2020 matrix conversions.
+
+LinearRec2020<float> toLinearRec2020(const XYZA<float>& color)
+{
+ return makeFromComponentsClampingExceptAlpha<LinearRec2020<float>>(xyzToLinearRec2020Matrix.transformedColorComponents(asColorComponents(color)));
+}
+
+XYZA<float> toXYZA(const LinearRec2020<float>& color)
+{
+ return makeFromComponentsClampingExceptAlpha<XYZA<float>>(linearRec2020ToXYZMatrix.transformedColorComponents(asColorComponents(color)));
+}
+
// - LinearSRGBA matrix conversions.
LinearSRGBA<float> toLinearSRGBA(const XYZA<float>& color)
@@ -468,6 +508,18 @@
return toLCHA(toLab(color));
}
+// - Rec2020 combination functions.
+
+XYZA<float> toXYZA(const Rec2020<float>& color)
+{
+ return toXYZA(toLinearRec2020(color));
+}
+
+Rec2020<float> toRec2020(const XYZA<float>& color)
+{
+ return toRec2020(toLinearRec2020(color));
+}
+
// - SRGB combination functions.
XYZA<float> toXYZA(const SRGBA<float>& color)
Modified: trunk/Source/WebCore/platform/graphics/ColorConversion.h (272122 => 272123)
--- trunk/Source/WebCore/platform/graphics/ColorConversion.h 2021-01-30 23:35:46 UTC (rev 272122)
+++ trunk/Source/WebCore/platform/graphics/ColorConversion.h 2021-01-31 07:52:56 UTC (rev 272123)
@@ -91,6 +91,12 @@
// Additions
WEBCORE_EXPORT ExtendedSRGBA<float> toExtendedSRGBA(const LinearExtendedSRGBA<float>&);
+// LinearRec2020
+WEBCORE_EXPORT XYZA<float> toXYZA(const LinearRec2020<float>&);
+WEBCORE_EXPORT LinearRec2020<float> toLinearRec2020(const XYZA<float>&);
+// Additions
+WEBCORE_EXPORT Rec2020<float> toRec2020(const LinearRec2020<float>&);
+
// LinearSRGBA
WEBCORE_EXPORT XYZA<float> toXYZA(const LinearSRGBA<float>&);
WEBCORE_EXPORT LinearSRGBA<float> toLinearSRGBA(const XYZA<float>&);
@@ -97,6 +103,12 @@
// Additions
WEBCORE_EXPORT SRGBA<float> toSRGBA(const LinearSRGBA<float>&);
+// Rec2020
+WEBCORE_EXPORT XYZA<float> toXYZA(const Rec2020<float>&);
+WEBCORE_EXPORT Rec2020<float> toRec2020(const XYZA<float>&);
+// Additions
+WEBCORE_EXPORT LinearRec2020<float> toLinearRec2020(const Rec2020<float>&);
+
// SRGBA
WEBCORE_EXPORT XYZA<float> toXYZA(const SRGBA<float>&);
WEBCORE_EXPORT SRGBA<float> toSRGBA(const XYZA<float>&);
@@ -116,7 +128,9 @@
constexpr LinearA98RGB<float> toLinearA98RGB(const LinearA98RGB<float>& color) { return color; }
constexpr LinearDisplayP3<float> toLinearDisplayP3(const LinearDisplayP3<float>& color) { return color; }
constexpr LinearExtendedSRGBA<float> toLinearExtendedSRGBA(const LinearExtendedSRGBA<float>& color) { return color; }
+constexpr LinearRec2020<float> toLinearRec2020(const LinearRec2020<float>& color) { return color; }
constexpr LinearSRGBA<float> toLinearSRGBA(const LinearSRGBA<float>& color) { return color; }
+constexpr Rec2020<float> toRec2020(const Rec2020<float>& color) { return color; }
constexpr SRGBA<float> toSRGBA(const SRGBA<float>& color) { return color; }
constexpr XYZA<float> toXYZA(const XYZA<float>& color) { return color; }
@@ -161,14 +175,19 @@
return toLinearA98RGB(toXYZA(color));
}
+template<typename T> LinearDisplayP3<float> toLinearDisplayP3(const T& color)
+{
+ return toLinearDisplayP3(toXYZA(color));
+}
+
template<typename T> LinearExtendedSRGBA<float> toLinearExtendedSRGBA(const T& color)
{
return toLinearExtendedSRGBA(toXYZA(color));
}
-template<typename T> LinearDisplayP3<float> toLinearDisplayP3(const T& color)
+template<typename T> LinearRec2020<float> toLinearRec2020(const T& color)
{
- return toLinearDisplayP3(toXYZA(color));
+ return toLinearRec2020(toXYZA(color));
}
template<typename T> LinearSRGBA<float> toLinearSRGBA(const T& color)
@@ -176,6 +195,11 @@
return toLinearSRGBA(toXYZA(color));
}
+template<typename T> Rec2020<float> toRec2020(const T& color)
+{
+ return toRec2020(toXYZA(color));
+}
+
template<typename T> SRGBA<float> toSRGBA(const T& color)
{
return toSRGBA(toXYZA(color));
@@ -193,6 +217,8 @@
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::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));
}
Modified: trunk/Source/WebCore/platform/graphics/ColorSerialization.cpp (272122 => 272123)
--- trunk/Source/WebCore/platform/graphics/ColorSerialization.cpp 2021-01-30 23:35:46 UTC (rev 272122)
+++ trunk/Source/WebCore/platform/graphics/ColorSerialization.cpp 2021-01-31 07:52:56 UTC (rev 272123)
@@ -68,6 +68,8 @@
return "lab"_s;
case ColorSpace::LinearRGB:
return "linear-srgb"_s;
+ case ColorSpace::Rec2020:
+ return "rec2020"_s;
case ColorSpace::SRGB:
return "srgb"_s;
}
@@ -157,6 +159,23 @@
return serialization(color);
}
+// MARK: Rec2020<float> overloads
+
+String serializationForCSS(const Rec2020<float>& color)
+{
+ return serialization(color);
+}
+
+String serializationForHTML(const Rec2020<float>& color)
+{
+ return serialization(color);
+}
+
+String serializationForRenderTreeAsText(const Rec2020<float>& color)
+{
+ return serialization(color);
+}
+
// MARK: SRGBA<float> overloads
String serializationForCSS(const SRGBA<float>& color)
Modified: trunk/Source/WebCore/platform/graphics/ColorSerialization.h (272122 => 272123)
--- trunk/Source/WebCore/platform/graphics/ColorSerialization.h 2021-01-30 23:35:46 UTC (rev 272122)
+++ trunk/Source/WebCore/platform/graphics/ColorSerialization.h 2021-01-31 07:52:56 UTC (rev 272123)
@@ -35,6 +35,7 @@
template<typename> struct DisplayP3;
template<typename> struct Lab;
template<typename> struct LinearSRGBA;
+template<typename> struct Rec2020;
template<typename> struct SRGBA;
// serializationForHTML returns the color serialized according to HTML5 <https://html.spec.whatwg.org/multipage/scripting.html#fill-and-stroke-styles> (10 September 2015)
@@ -63,6 +64,10 @@
WEBCORE_EXPORT String serializationForHTML(const LinearSRGBA<float>&);
WEBCORE_EXPORT String serializationForRenderTreeAsText(const LinearSRGBA<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>&);
Modified: trunk/Source/WebCore/platform/graphics/ColorSpace.cpp (272122 => 272123)
--- trunk/Source/WebCore/platform/graphics/ColorSpace.cpp 2021-01-30 23:35:46 UTC (rev 272122)
+++ trunk/Source/WebCore/platform/graphics/ColorSpace.cpp 2021-01-31 07:52:56 UTC (rev 272123)
@@ -45,6 +45,9 @@
case ColorSpace::LinearRGB:
ts << "LinearRGB";
break;
+ case ColorSpace::Rec2020:
+ ts << "Rec2020";
+ break;
case ColorSpace::SRGB:
ts << "sRGB";
break;
Modified: trunk/Source/WebCore/platform/graphics/ColorSpace.h (272122 => 272123)
--- trunk/Source/WebCore/platform/graphics/ColorSpace.h 2021-01-30 23:35:46 UTC (rev 272122)
+++ trunk/Source/WebCore/platform/graphics/ColorSpace.h 2021-01-31 07:52:56 UTC (rev 272123)
@@ -36,6 +36,7 @@
DisplayP3,
Lab,
LinearRGB,
+ Rec2020,
SRGB,
};
Modified: trunk/Source/WebCore/platform/graphics/ColorTransferFunctions.h (272122 => 272123)
--- trunk/Source/WebCore/platform/graphics/ColorTransferFunctions.h 2021-01-30 23:35:46 UTC (rev 272122)
+++ trunk/Source/WebCore/platform/graphics/ColorTransferFunctions.h 2021-01-31 07:52:56 UTC (rev 272123)
@@ -43,11 +43,23 @@
};
template<typename T, TransferFunctionMode mode>
+struct Rec2020TransferFunction {
+ static constexpr T alpha = 1.09929682680944;
+ static constexpr T beta = 0.018053968510807;
+ static constexpr T gamma = 0.45;
+
+ static T toGammaEncoded(T);
+ static T toLinear(T);
+};
+
+template<typename T, TransferFunctionMode mode>
struct SRGBTransferFunction {
static T toGammaEncoded(T);
static T toLinear(T);
};
+// MARK: A98RGBTransferFunction.
+
template<typename T, TransferFunctionMode mode> T A98RGBTransferFunction<T, mode>::toGammaEncoded(T c)
{
auto sign = std::signbit(c) ? -1.0f : 1.0f;
@@ -66,6 +78,41 @@
return result;
}
+// MARK: Rec2020TransferFunction.
+
+template<typename T, TransferFunctionMode mode> T Rec2020TransferFunction<T, mode>::toGammaEncoded(T c)
+{
+ if constexpr (mode == TransferFunctionMode::Clamped) {
+ if (c <= beta)
+ return 4.5f * c;
+
+ return clampTo<T>(alpha * std::pow(c, gamma) - (alpha - 1.0f), 0, 1);
+ } else {
+ if (std::abs(c) <= beta)
+ return 4.5f * c;
+
+ float sign = std::signbit(c) ? -1.0 : 1.0;
+ return sign * alpha * std::pow(c, gamma) - (alpha - 1.0);
+ }
+}
+
+template<typename T, TransferFunctionMode mode> T Rec2020TransferFunction<T, mode>::toLinear(T c)
+{
+ if constexpr (mode == TransferFunctionMode::Clamped) {
+ if (c < beta * 4.5f)
+ return c / 4.5f;
+ return clampTo<T>(std::pow((c + alpha - 1.0) / alpha, 1.0 / gamma), 0, 1);
+ } else {
+ if (std::abs(c) < beta * 4.5f)
+ return c / 4.5f;
+
+ float sign = std::signbit(c) ? -1.0 : 1.0;
+ return std::pow((c + alpha - 1.0) / alpha, 1.0 / gamma) * sign;
+ }
+}
+
+// MARK: SRGBTransferFunction.
+
template<typename T, TransferFunctionMode mode> T SRGBTransferFunction<T, mode>::toGammaEncoded(T c)
{
if constexpr (mode == TransferFunctionMode::Clamped) {
Modified: trunk/Source/WebCore/platform/graphics/ColorTypes.h (272122 => 272123)
--- trunk/Source/WebCore/platform/graphics/ColorTypes.h 2021-01-30 23:35:46 UTC (rev 272122)
+++ trunk/Source/WebCore/platform/graphics/ColorTypes.h 2021-01-31 07:52:56 UTC (rev 272123)
@@ -40,7 +40,9 @@
template<typename> struct LinearA98RGB;
template<typename> struct LinearDisplayP3;
template<typename> struct LinearExtendedSRGBA;
+template<typename> struct LinearRec2020;
template<typename> struct LinearSRGBA;
+template<typename> struct Rec2020;
template<typename> struct SRGBA;
template<typename> struct XYZ;
@@ -256,6 +258,12 @@
};
template<typename T> LinearExtendedSRGBA(T, T, T, T) -> LinearExtendedSRGBA<T>;
+template<typename T> struct LinearRec2020 : RGBAType<LinearRec2020, T, RGBModel<T>> {
+ using RGBAType<LinearRec2020, T, RGBModel<T>>::RGBAType;
+ using GammaEncodedCounterpart = Rec2020<T>;
+};
+template<typename T> LinearRec2020(T, T, T, T) -> LinearRec2020<T>;
+
template<typename T> struct LinearSRGBA : RGBAType<LinearSRGBA, T, RGBModel<T>> {
using RGBAType<LinearSRGBA, T, RGBModel<T>>::RGBAType;
using GammaEncodedCounterpart = SRGBA<T>;
@@ -263,6 +271,13 @@
};
template<typename T> LinearSRGBA(T, T, T, T) -> LinearSRGBA<T>;
+template<typename T> struct Rec2020 : RGBAType<Rec2020, T, RGBModel<T>> {
+ using RGBAType<Rec2020, T, RGBModel<T>>::RGBAType;
+ using LinearCounterpart = LinearRec2020<T>;
+ static constexpr auto colorSpace { ColorSpace::Rec2020 };
+};
+template<typename T> Rec2020(T, T, T, T) -> Rec2020<T>;
+
template<typename T> struct SRGBA : RGBAType<SRGBA, T, RGBModel<T>> {
using RGBAType<SRGBA, T, RGBModel<T>>::RGBAType;
using LinearCounterpart = LinearSRGBA<T>;
Modified: trunk/Source/WebCore/platform/graphics/cg/ColorSpaceCG.cpp (272122 => 272123)
--- trunk/Source/WebCore/platform/graphics/cg/ColorSpaceCG.cpp 2021-01-30 23:35:46 UTC (rev 272122)
+++ trunk/Source/WebCore/platform/graphics/cg/ColorSpaceCG.cpp 2021-01-31 07:52:56 UTC (rev 272123)
@@ -100,6 +100,20 @@
return linearRGBColorSpace;
}
+CGColorSpaceRef rec2020ColorSpaceRef()
+{
+ static CGColorSpaceRef rec2020ColorSpace;
+ static std::once_flag onceFlag;
+ std::call_once(onceFlag, [] {
+#if PLATFORM(COCOA)
+ rec2020ColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceITUR_2020);
+#else
+ rec2020ColorSpace = sRGBColorSpaceRef();
+#endif
+ });
+ return rec2020ColorSpace;
+}
+
CGColorSpaceRef sRGBColorSpaceRef()
{
static CGColorSpaceRef sRGBColorSpace;
Modified: trunk/Source/WebCore/platform/graphics/cg/ColorSpaceCG.h (272122 => 272123)
--- trunk/Source/WebCore/platform/graphics/cg/ColorSpaceCG.h 2021-01-30 23:35:46 UTC (rev 272122)
+++ trunk/Source/WebCore/platform/graphics/cg/ColorSpaceCG.h 2021-01-31 07:52:56 UTC (rev 272123)
@@ -50,6 +50,8 @@
return labColorSpaceRef();
case ColorSpace::LinearRGB:
return linearRGBColorSpaceRef();
+ case ColorSpace::Rec2020:
+ return rec2020ColorSpaceRef();
case ColorSpace::SRGB:
return sRGBColorSpaceRef();
}