Title: [283053] trunk
Revision
283053
Author
[email protected]
Date
2021-09-24 13:12:18 -0700 (Fri, 24 Sep 2021)

Log Message

Color keywords in override-color cause a crash
https://bugs.webkit.org/show_bug.cgi?id=230605
<rdar://problem/83389290>

Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

Tests are being upstreamed at https://github.com/web-platform-tests/wpt/pull/30941.

* web-platform-tests/css/css-fonts/parsing/font-palette-values-valid-expected.txt:
* web-platform-tests/css/css-fonts/parsing/font-palette-values-valid.html:

Source/WebCore:

I was assuming that consumeColor() would always produce a color. Instead, if the color
was specified as a keyword, consumeColor() would produce the keyword.

This passes in the default context for color resolution, because
https://github.com/w3c/csswg-drafts/issues/6680 isn't resolved yet.

Test: imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-valid.html

* css/parser/CSSParserImpl.cpp:
(WebCore::CSSParserImpl::consumeFontPaletteValuesRule):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (283052 => 283053)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-09-24 18:58:49 UTC (rev 283052)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-09-24 20:12:18 UTC (rev 283053)
@@ -1,3 +1,16 @@
+2021-09-24  Myles C. Maxfield  <[email protected]>
+
+        Color keywords in override-color cause a crash
+        https://bugs.webkit.org/show_bug.cgi?id=230605
+        <rdar://problem/83389290>
+
+        Reviewed by Simon Fraser.
+
+        Tests are being upstreamed at https://github.com/web-platform-tests/wpt/pull/30941.
+
+        * web-platform-tests/css/css-fonts/parsing/font-palette-values-valid-expected.txt:
+        * web-platform-tests/css/css-fonts/parsing/font-palette-values-valid.html:
+
 2021-09-24  Sergio Villar Senin  <[email protected]>
 
         [css-flexbox] Import latest changes from css-flexbox WPT repo

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-valid-expected.txt (283052 => 283053)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-valid-expected.txt	2021-09-24 18:58:49 UTC (rev 283052)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-valid-expected.txt	2021-09-24 20:12:18 UTC (rev 283053)
@@ -19,4 +19,16 @@
 PASS CSS Fonts Module Level 4: parsing @font-palette-values 17
 PASS CSS Fonts Module Level 4: parsing @font-palette-values 18
 PASS CSS Fonts Module Level 4: parsing @font-palette-values 19
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 20
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 21
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 22
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 23
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 24
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 25
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 26
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 27
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 28
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 29
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 30
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 31
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-valid.html (283052 => 283053)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-valid.html	2021-09-24 18:58:49 UTC (rev 283052)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-valid.html	2021-09-24 20:12:18 UTC (rev 283053)
@@ -69,6 +69,36 @@
 @font-palette-values J {
     override-color: -3 rgb(17, 34, 51);
 }
+
+/* 10 */
+@font-palette-values K {
+    override-color: 0 #0000FF;
+}
+
+/* 11 */
+@font-palette-values L {
+    override-color: 0 green;
+}
+
+/* 12 */
+@font-palette-values M {
+    override-color: 0 transparent;
+}
+
+/* 13 */
+@font-palette-values N {
+    override-color: 0 rgba(1 2 3 / 4);
+}
+
+/* 14 */
+@font-palette-values O {
+    override-color: 0 lab(29.2345% 39.3825 20.0664);
+}
+
+/* 15 */
+@font-palette-values P {
+    override-color: 0 color(display-p3 100% 100% 100%);
+}
 </style>
 </head>
 <body>
@@ -228,6 +258,90 @@
     assert_equals(rule.get(7), undefined);
     assert_equals(rule.get(-3), undefined);
 });
+
+test(function() {
+    let text = rules[10].cssText;
+    assert_not_equals(text.indexOf("override-color"), -1);
+    assert_not_equals(text.indexOf("rgb(0, 0, 255)"), -1);
+});
+
+test(function() {
+    let rule = rules[10];
+    assert_equals(rule.fontFamily, "");
+    assert_equals(rule.basePalette, "");
+    assert_equals(rule.size, 1);
+    assert_equals(rule.get(0), "rgb(0, 0, 255)");
+});
+
+test(function() {
+    let text = rules[11].cssText;
+    assert_not_equals(text.indexOf("override-color"), -1);
+    assert_not_equals(text.indexOf("rgb(0, 128, 0)"), -1);
+});
+
+test(function() {
+    let rule = rules[11];
+    assert_equals(rule.fontFamily, "");
+    assert_equals(rule.basePalette, "");
+    assert_equals(rule.size, 1);
+    assert_equals(rule.get(0), "rgb(0, 128, 0)");
+});
+
+test(function() {
+    let text = rules[12].cssText;
+    assert_not_equals(text.indexOf("override-color"), -1);
+    assert_not_equals(text.indexOf("rgba(0, 0, 0, 0)"), -1);
+});
+
+test(function() {
+    let rule = rules[12];
+    assert_equals(rule.fontFamily, "");
+    assert_equals(rule.basePalette, "");
+    assert_equals(rule.size, 1);
+    assert_equals(rule.get(0), "rgba(0, 0, 0, 0)");
+});
+
+test(function() {
+    let text = rules[13].cssText;
+    assert_not_equals(text.indexOf("override-color"), -1);
+    assert_not_equals(text.indexOf("2"), -1);
+});
+
+test(function() {
+    let rule = rules[13];
+    assert_equals(rule.fontFamily, "");
+    assert_equals(rule.basePalette, "");
+    assert_equals(rule.size, 1);
+    assert_not_equals(rule.get(0).indexOf("2"), -1);
+});
+
+test(function() {
+    let text = rules[14].cssText;
+    assert_not_equals(text.indexOf("override-color"), -1);
+    assert_not_equals(text.indexOf("29"), -1);
+});
+
+test(function() {
+    let rule = rules[14];
+    assert_equals(rule.fontFamily, "");
+    assert_equals(rule.basePalette, "");
+    assert_equals(rule.size, 1);
+    assert_not_equals(rule.get(0).indexOf("lab"), -1);
+});
+
+test(function() {
+    let text = rules[15].cssText;
+    assert_not_equals(text.indexOf("override-color"), -1);
+    assert_not_equals(text.indexOf("display-p3"), -1);
+});
+
+test(function() {
+    let rule = rules[15];
+    assert_equals(rule.fontFamily, "");
+    assert_equals(rule.basePalette, "");
+    assert_equals(rule.size, 1);
+    assert_not_equals(rule.get(0).indexOf("display-p3"), -1);
+});
 </script>
 </body>
 </html>

Modified: trunk/Source/WebCore/ChangeLog (283052 => 283053)


--- trunk/Source/WebCore/ChangeLog	2021-09-24 18:58:49 UTC (rev 283052)
+++ trunk/Source/WebCore/ChangeLog	2021-09-24 20:12:18 UTC (rev 283053)
@@ -1,3 +1,22 @@
+2021-09-24  Myles C. Maxfield  <[email protected]>
+
+        Color keywords in override-color cause a crash
+        https://bugs.webkit.org/show_bug.cgi?id=230605
+        <rdar://problem/83389290>
+
+        Reviewed by Simon Fraser.
+
+        I was assuming that consumeColor() would always produce a color. Instead, if the color
+        was specified as a keyword, consumeColor() would produce the keyword.
+
+        This passes in the default context for color resolution, because
+        https://github.com/w3c/csswg-drafts/issues/6680 isn't resolved yet.
+
+        Test: imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-valid.html
+
+        * css/parser/CSSParserImpl.cpp:
+        (WebCore::CSSParserImpl::consumeFontPaletteValuesRule):
+
 2021-09-24  Antoine Quint  <[email protected]>
 
         [Media Controls] RangeButton doesn't show the fill indicator in fullscreen

Modified: trunk/Source/WebCore/css/parser/CSSParserImpl.cpp (283052 => 283053)


--- trunk/Source/WebCore/css/parser/CSSParserImpl.cpp	2021-09-24 18:58:49 UTC (rev 283052)
+++ trunk/Source/WebCore/css/parser/CSSParserImpl.cpp	2021-09-24 20:12:18 UTC (rev 283053)
@@ -698,7 +698,8 @@
                 key = pair.key().value<int64_t>();
             else
                 continue;
-            overrideColor.append(std::make_pair(key, pair.color().color()));
+            Color color = pair.color().isRGBColor() ? pair.color().color() : StyleColor::colorFromKeyword(pair.color().valueID(), { });
+            overrideColor.append(std::make_pair(key, color));
         }
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to