Title: [282806] trunk
Revision
282806
Author
[email protected]
Date
2021-09-21 01:24:36 -0700 (Tue, 21 Sep 2021)

Log Message

Parsing support for font-palette-values
https://bugs.webkit.org/show_bug.cgi?id=230337

Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

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

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

Source/WebCore:

There's nothing particularly interesting here - it's just support for another at-rule.
I've implemented what's in the spec right now:
https://drafts.csswg.org/css-fonts-4/#font-palette-values

There are 2 new descriptors: base-palette and override-color. I've added a new CSSValue subclass
for each of the items in the override-color list - these items are just tuples of two
CSSPrimitiveValues. I could have done this with a CSSValueList which always just happens to have
a length of 2, but I thought that was less elegant (and has an extra pointer indirection) than
making a class to hold the two CSSPrimitiveValues.

The only difference with what's in the spec is that I've given a different value to
FONT_PALETTE_VALUES_RULE, because its current value conflicts with VIEWPORT_RULE. This is being
tracked at https://github.com/w3c/csswg-drafts/issues/6623.

I created a new datatype and file in platform/graphics/FontPaletteValues.h because this data will
eventually be passed to preparePlatformFont(), which is in platform/, so this data needs to be
accessible from platform/ too.

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

* CMakeLists.txt:
* DerivedSources-input.xcfilelist:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* Headers.cmake:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSCSSRuleCustom.cpp:
(WebCore::toJSNewlyCreated):
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
* css/CSSFontPaletteValuesOverrideColorValue.cpp: Copied from Source/WebCore/css/StyleRuleType.h.
(WebCore::CSSFontPaletteValuesOverrideColorValue::customCSSText const):
(WebCore::CSSFontPaletteValuesOverrideColorValue::equals const):
* css/CSSFontPaletteValuesOverrideColorValue.h: Copied from Source/WebCore/css/StyleRuleType.h.
* css/CSSFontPaletteValuesRule.cpp: Added.
(WebCore::CSSFontPaletteValuesRule::CSSFontPaletteValuesRule):
(WebCore::CSSFontPaletteValuesRule::~CSSFontPaletteValuesRule):
(WebCore::parseString):
(WebCore::CSSFontPaletteValuesRule::fontFamily const):
(WebCore::CSSFontPaletteValuesRule::basePalette const):
(WebCore::CSSFontPaletteValuesRule::setFontFamily):
(WebCore::CSSFontPaletteValuesRule::setBasePalette):
(WebCore::CSSFontPaletteValuesRule::initializeMapLike):
(WebCore::CSSFontPaletteValuesRule::setFromMapLike):
(WebCore::CSSFontPaletteValuesRule::clear):
(WebCore::CSSFontPaletteValuesRule::remove):
(WebCore::CSSFontPaletteValuesRule::cssText const):
(WebCore::CSSFontPaletteValuesRule::reattach):
* css/CSSFontPaletteValuesRule.h: Copied from Source/WebCore/css/StyleRuleType.h.
* css/CSSFontPaletteValuesRule.idl: Added.
* css/CSSProperties.json:
* css/CSSRule.cpp:
* css/CSSRule.h:
* css/CSSRule.idl:
* css/CSSValue.cpp:
(WebCore::CSSValue::equals const):
(WebCore::CSSValue::cssText const):
(WebCore::CSSValue::destroy):
* css/CSSValue.h:
(WebCore::CSSValue::isFontPaletteValuesOverrideColorValue const):
* css/StyleRule.cpp:
(WebCore::StyleRuleBase::destroy):
(WebCore::StyleRuleBase::copy const):
(WebCore::StyleRuleBase::createCSSOMWrapper const):
(WebCore::StyleRuleFontPaletteValues::StyleRuleFontPaletteValues):
* css/StyleRule.h:
(WebCore::StyleRuleBase::isFontPaletteValuesRule const):
(isType):
* css/StyleRuleType.h:
* css/StyleSheetContents.cpp:
(WebCore::traverseRulesInVector):
(WebCore::StyleSheetContents::traverseSubresources const):
* css/parser/CSSAtRuleID.cpp:
(WebCore::cssAtRuleID):
* css/parser/CSSAtRuleID.h:
* css/parser/CSSParserImpl.cpp:
(WebCore::CSSParserImpl::consumeAtRule):
(WebCore::CSSParserImpl::consumeFontPaletteValuesRule):
(WebCore::CSSParserImpl::consumeDeclaration):
* css/parser/CSSParserImpl.h:
* css/parser/CSSPropertyParser.cpp:
(WebCore::CSSPropertyParser::parseValue):
(WebCore::consumeBasePaletteDescriptor):
(WebCore::consumeOverrideColorDescriptor):
(WebCore::CSSPropertyParser::parseFontPaletteValuesDescriptor):
* css/parser/CSSPropertyParser.h:
* platform/graphics/FontPaletteValues.h: Added.
(WebCore::FontPaletteValues::FontPaletteValues):
(WebCore::FontPaletteValues::basePalette const):
(WebCore::FontPaletteValues::setBasePalette):
(WebCore::FontPaletteValues::overrideColor const):
(WebCore::FontPaletteValues::appendOverrideColor):
(WebCore::FontPaletteValues::clearOverrideColor):
(WebCore::FontPaletteValues::remove):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (282805 => 282806)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-09-21 07:48:22 UTC (rev 282805)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-09-21 08:24:36 UTC (rev 282806)
@@ -1,3 +1,18 @@
+2021-09-21  Myles C. Maxfield  <[email protected]>
+
+        Parsing support for font-palette-values
+        https://bugs.webkit.org/show_bug.cgi?id=230337
+
+        Reviewed by Antti Koivisto.
+
+        These are being upstreamed at https://github.com/web-platform-tests/wpt/pull/30840.
+
+        * web-platform-tests/css/css-fonts/idlharness-expected.txt:
+        * web-platform-tests/css/css-fonts/parsing/font-palette-values-invalid-expected.txt: Added.
+        * web-platform-tests/css/css-fonts/parsing/font-palette-values-invalid.html: Added.
+        * web-platform-tests/css/css-fonts/parsing/font-palette-values-valid-expected.txt: Added.
+        * web-platform-tests/css/css-fonts/parsing/font-palette-values-valid.html: Added.
+
 2021-09-21  Ziran Sun  <[email protected]>
 
         [css-grid] When the max is less than the min in minmax(), the max will be floored by the min

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/idlharness-expected.txt (282805 => 282806)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/idlharness-expected.txt	2021-09-21 07:48:22 UTC (rev 282805)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/idlharness-expected.txt	2021-09-21 08:24:36 UTC (rev 282806)
@@ -16,7 +16,7 @@
 PASS Stringification of cssFontFaceRule
 PASS CSSFontFaceRule interface: cssFontFaceRule must inherit property "style" with the proper type
 FAIL CSSRule interface: cssFontFaceRule must inherit property "FONT_FEATURE_VALUES_RULE" with the proper type assert_inherits: property "FONT_FEATURE_VALUES_RULE" not found in prototype chain
-FAIL CSSRule interface: cssFontFaceRule must inherit property "FONT_PALETTE_VALUES_RULE" with the proper type assert_inherits: property "FONT_PALETTE_VALUES_RULE" not found in prototype chain
+FAIL CSSRule interface: cssFontFaceRule must inherit property "FONT_PALETTE_VALUES_RULE" with the proper type assert_equals: expected 15 but got 19
 FAIL CSSFontFeatureValuesRule interface: existence and properties of interface object assert_own_property: self does not have own property "CSSFontFeatureValuesRule" expected property "CSSFontFeatureValuesRule" missing
 FAIL CSSFontFeatureValuesRule interface object length assert_own_property: self does not have own property "CSSFontFeatureValuesRule" expected property "CSSFontFeatureValuesRule" missing
 FAIL CSSFontFeatureValuesRule interface object name assert_own_property: self does not have own property "CSSFontFeatureValuesRule" expected property "CSSFontFeatureValuesRule" missing
@@ -37,18 +37,18 @@
 FAIL CSSFontFeatureValuesMap interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "CSSFontFeatureValuesMap" expected property "CSSFontFeatureValuesMap" missing
 FAIL CSSFontFeatureValuesMap interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "CSSFontFeatureValuesMap" expected property "CSSFontFeatureValuesMap" missing
 FAIL CSSFontFeatureValuesMap interface: operation set(CSSOMString, (unsigned long or sequence<unsigned long>)) assert_own_property: self does not have own property "CSSFontFeatureValuesMap" expected property "CSSFontFeatureValuesMap" missing
-FAIL CSSFontPaletteValuesRule interface: existence and properties of interface object assert_own_property: self does not have own property "CSSFontPaletteValuesRule" expected property "CSSFontPaletteValuesRule" missing
-FAIL CSSFontPaletteValuesRule interface object length assert_own_property: self does not have own property "CSSFontPaletteValuesRule" expected property "CSSFontPaletteValuesRule" missing
-FAIL CSSFontPaletteValuesRule interface object name assert_own_property: self does not have own property "CSSFontPaletteValuesRule" expected property "CSSFontPaletteValuesRule" missing
-FAIL CSSFontPaletteValuesRule interface: existence and properties of interface prototype object assert_own_property: self does not have own property "CSSFontPaletteValuesRule" expected property "CSSFontPaletteValuesRule" missing
-FAIL CSSFontPaletteValuesRule interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "CSSFontPaletteValuesRule" expected property "CSSFontPaletteValuesRule" missing
-FAIL CSSFontPaletteValuesRule interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "CSSFontPaletteValuesRule" expected property "CSSFontPaletteValuesRule" missing
-FAIL CSSFontPaletteValuesRule interface: attribute fontFamily assert_own_property: self does not have own property "CSSFontPaletteValuesRule" expected property "CSSFontPaletteValuesRule" missing
-FAIL CSSFontPaletteValuesRule interface: attribute basePalette assert_own_property: self does not have own property "CSSFontPaletteValuesRule" expected property "CSSFontPaletteValuesRule" missing
+PASS CSSFontPaletteValuesRule interface: existence and properties of interface object
+PASS CSSFontPaletteValuesRule interface object length
+PASS CSSFontPaletteValuesRule interface object name
+PASS CSSFontPaletteValuesRule interface: existence and properties of interface prototype object
+PASS CSSFontPaletteValuesRule interface: existence and properties of interface prototype object's "constructor" property
+PASS CSSFontPaletteValuesRule interface: existence and properties of interface prototype object's @@unscopables property
+FAIL CSSFontPaletteValuesRule interface: attribute fontFamily assert_equals: setter must be function for PutForwards, Replaceable, or non-readonly attributes expected "function" but got "undefined"
+FAIL CSSFontPaletteValuesRule interface: attribute basePalette assert_equals: setter must be function for PutForwards, Replaceable, or non-readonly attributes expected "function" but got "undefined"
 FAIL CSSRule interface: constant FONT_FEATURE_VALUES_RULE on interface object assert_own_property: expected property "FONT_FEATURE_VALUES_RULE" missing
 FAIL CSSRule interface: constant FONT_FEATURE_VALUES_RULE on interface prototype object assert_own_property: expected property "FONT_FEATURE_VALUES_RULE" missing
-FAIL CSSRule interface: constant FONT_PALETTE_VALUES_RULE on interface object assert_own_property: expected property "FONT_PALETTE_VALUES_RULE" missing
-FAIL CSSRule interface: constant FONT_PALETTE_VALUES_RULE on interface prototype object assert_own_property: expected property "FONT_PALETTE_VALUES_RULE" missing
+FAIL CSSRule interface: constant FONT_PALETTE_VALUES_RULE on interface object assert_equals: property has wrong value expected 15 but got 19
+FAIL CSSRule interface: constant FONT_PALETTE_VALUES_RULE on interface prototype object assert_equals: property has wrong value expected 15 but got 19
 FAIL CSSRule interface: cssRule must inherit property "FONT_FEATURE_VALUES_RULE" with the proper type assert_inherits: property "FONT_FEATURE_VALUES_RULE" not found in prototype chain
-FAIL CSSRule interface: cssRule must inherit property "FONT_PALETTE_VALUES_RULE" with the proper type assert_inherits: property "FONT_PALETTE_VALUES_RULE" not found in prototype chain
+FAIL CSSRule interface: cssRule must inherit property "FONT_PALETTE_VALUES_RULE" with the proper type assert_equals: expected 15 but got 19
 

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-invalid-expected.txt (0 => 282806)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-invalid-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-invalid-expected.txt	2021-09-21 08:24:36 UTC (rev 282806)
@@ -0,0 +1,16 @@
+
+PASS CSS Fonts Module Level 4: parsing @font-palette-values
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 1
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 2
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 3
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 4
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 5
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 6
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 7
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 8
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 9
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 10
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 11
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 12
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 13
+
Property changes on: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-invalid-expected.txt
___________________________________________________________________

Added: svn:eol-style

+native \ No newline at end of property

Added: svn:keywords

+Author Date Id Rev URL \ No newline at end of property

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-invalid.html (0 => 282806)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-invalid.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-invalid.html	2021-09-21 08:24:36 UTC (rev 282806)
@@ -0,0 +1,182 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS Fonts Module Level 4: parsing @font-palette-values</title>
+<link rel="help" href=""
+<meta name="assert" content="@font-palette-values is parsed correctly.">
+<script src=""
+<script src=""
+<style id="style">
+@font-palette-values {
+}
+
+@font-palette-values A B {
+}
+
+/* 0 */
+@font-palette-values A {
+    font-family: a, b;
+}
+
+/* 1 */
+@font-palette-values A {
+    font-family: 1;
+}
+
+/* 2 */
+@font-palette-values A {
+    font: 12px a;
+}
+
+/* 3 */
+@font-palette-values A {
+    base-palette: 1 2;
+}
+
+/* 4 */
+@font-palette-values A {
+    base-palette: ident;
+}
+
+/* 5 */
+@font-palette-values A {
+    base-palette: "a" "b";
+}
+
+/* 6 */
+@font-palette-values A {
+    base-palette: ;
+}
+
+/* 7 */
+@font-palette-values A {
+    override-color: ident #123;
+}
+
+/* 8 */
+@font-palette-values A {
+    override-color: 0 "red";
+}
+
+/* 9 */
+@font-palette-values A {
+    override-color: 0 #123, 1;
+}
+
+/* 10 */
+@font-palette-values A {
+    override-color: ;
+}
+
+/* 11 */
+@font-palette-values A {
+    override-color: 0 #123 1;
+}
+
+/* 12 */
+@font-palette-values A {
+    override-color: 0;
+}
+</style>
+</head>
+<body>
+<script>
+let rules = document.getElementById("style").sheet.cssRules;
+test(function() {
+    assert_equals(rules.length, 13);
+});
+
+test(function() {
+    let text = rules[0].cssText;
+    let rule = rules[0];
+    assert_equals(text.indexOf("font-family"), -1);
+    assert_equals(rule.fontFamily, "");
+});
+
+test(function() {
+    let text = rules[1].cssText;
+    let rule = rules[1];
+    assert_equals(text.indexOf("font-family"), -1);
+    assert_equals(rule.fontFamily, "");
+});
+
+test(function() {
+    let text = rules[2].cssText;
+    let rule = rules[2];
+    assert_equals(text.indexOf("font:"), -1);
+    assert_equals(rule.fontFamily, "");
+});
+
+test(function() {
+    let text = rules[3].cssText;
+    let rule = rules[3];
+    assert_equals(text.indexOf("base-palette"), -1);
+    assert_equals(rule.basePalette, "");
+});
+
+test(function() {
+    let text = rules[4].cssText;
+    let rule = rules[4];
+    assert_equals(text.indexOf("base-palette"), -1);
+    assert_equals(rule.basePalette, "");
+});
+
+test(function() {
+    let text = rules[5].cssText;
+    let rule = rules[5];
+    assert_equals(text.indexOf("base-palette"), -1);
+    assert_equals(rule.basePalette, "");
+});
+
+test(function() {
+    let text = rules[6].cssText;
+    let rule = rules[6];
+    assert_equals(text.indexOf("base-palette"), -1);
+    assert_equals(rule.basePalette, "");
+});
+
+test(function() {
+    let text = rules[7].cssText;
+    let rule = rules[7];
+    assert_equals(text.indexOf("override-color"), -1);
+    assert_equals(rule.size, 0);
+});
+
+test(function() {
+    let text = rules[8].cssText;
+    let rule = rules[8];
+    assert_equals(text.indexOf("override-color"), -1);
+    assert_equals(rule.size, 0);
+});
+
+test(function() {
+    let text = rules[9].cssText;
+    let rule = rules[9];
+    assert_equals(text.indexOf("override-color"), -1);
+    assert_equals(rule.size, 0);
+});
+
+test(function() {
+    let text = rules[10].cssText;
+    let rule = rules[10];
+    assert_equals(text.indexOf("override-color"), -1);
+    assert_equals(rule.size, 0);
+});
+
+test(function() {
+    let text = rules[11].cssText;
+    let rule = rules[11];
+    assert_equals(text.indexOf("override-color"), -1);
+    assert_equals(rule.size, 0);
+});
+
+test(function() {
+    let text = rules[12].cssText;
+    let rule = rules[12];
+    assert_equals(text.indexOf("override-color"), -1);
+    assert_equals(rule.size, 0);
+});
+</script>
+</body>
+</html>

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


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-valid-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-valid-expected.txt	2021-09-21 08:24:36 UTC (rev 282806)
@@ -0,0 +1,22 @@
+
+PASS CSS Fonts Module Level 4: parsing @font-palette-values
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 1
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 2
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 3
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 4
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 5
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 6
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 7
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 8
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 9
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 10
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 11
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 12
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 13
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 14
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 15
+PASS CSS Fonts Module Level 4: parsing @font-palette-values 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
+
Property changes on: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-valid-expected.txt
___________________________________________________________________

Added: svn:eol-style

+native \ No newline at end of property

Added: svn:keywords

+Author Date Id Rev URL \ No newline at end of property

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-valid.html (0 => 282806)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-valid.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-valid.html	2021-09-21 08:24:36 UTC (rev 282806)
@@ -0,0 +1,233 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS Fonts Module Level 4: parsing @font-palette-values</title>
+<link rel="help" href=""
+<meta name="assert" content="@font-palette-values is parsed correctly.">
+<script src=""
+<script src=""
+<style id="style">
+/* 0 */
+@font-palette-values A {
+}
+
+/* 1 */
+@font-palette-values B {
+    font-weight: 400;
+}
+
+/* 2 */
+@font-palette-values C {
+    font-family: foo;
+    font-family: bar;
+    base-palette: 1;
+    base-palette: "baz";
+    base-palette: 2;
+    override-color: "a" #123;
+    override-color: 3 #123;
+    override-color: "b" #123;
+}
+
+/* 3 */
+@font-palette-values D {
+    base-palette: "foo";
+    base-palette: 1;
+    base-palette: "bar";
+    override-color: 3 #123;
+    override-color: "baz" #123;
+    override-color: 4 #123;
+}
+
+/* 4 */
+@font-palette-values E {
+    override-color: 3 rgb(17, 34, 51);
+    override-color: 3 rgb(68, 85, 102);
+}
+
+/* 5 */
+@font-palette-values F {
+    font-family: "foo";
+}
+
+/* 6 */
+@font-palette-values G {
+    override-color: 3 rgb(17, 34, 51), 4 rgb(68, 85, 102);
+}
+
+/* 7 */
+@font-palette-values H {
+    override-color: 3 rgb(17, 34, 51), 3 rgb(68, 85, 102);
+}
+
+/* 8 */
+@font-palette-values I {
+    base-palette: -3;
+}
+
+/* 9 */
+@font-palette-values J {
+    override-color: -3 rgb(17, 34, 51);
+}
+</style>
+</head>
+<body>
+<script>
+let rules = document.getElementById("style").sheet.cssRules;
+test(function() {
+    let text = rules[0].cssText;
+    assert_not_equals(text.indexOf("@font-palette-values "), -1);
+    assert_not_equals(text.indexOf(" A "), -1);
+    assert_not_equals(text.indexOf("{"), -1);
+    assert_not_equals(text.indexOf("}"), -1);
+    assert_equals(text.indexOf("font-family"), -1);
+    assert_equals(text.indexOf("base-palette"), -1);
+    assert_equals(text.indexOf("override-color"), -1);
+});
+
+test(function() {
+    let rule = rules[0];
+    assert_equals(rule.type, CSSRule.FONT_PALETTE_VALUES_RULE);
+    assert_equals(rule.constructor.name, "CSSFontPaletteValuesRule");
+    assert_equals(rule.fontFamily, "");
+    assert_equals(rule.basePalette, "");
+    assert_equals(rule.size, 0);
+});
+
+test(function() {
+    let text = rules[1].cssText;
+    assert_equals(text.indexOf("font-weight"), -1);
+});
+
+test(function() {
+    let rule = rules[1];
+    assert_equals(rule.fontFamily, "");
+    assert_equals(rule.basePalette, "");
+    assert_equals(rule.size, 0);
+});
+
+test(function() {
+    let text = rules[2].cssText;
+    assert_equals(text.indexOf("font-family: foo;"), -1);
+    assert_not_equals(text.indexOf("font-family: bar;"), -1);
+    assert_equals(text.indexOf("base-palette: 1;"), -1);
+    assert_equals(text.indexOf("base-palette: \"baz\""), -1);
+    assert_not_equals(text.indexOf("base-palette: 2;"), -1);
+    assert_equals(text.indexOf("override-color: \"a\""), -1);
+    assert_equals(text.indexOf("override-color: 3"), -1);
+    assert_not_equals(text.indexOf("override-color: \"b\""), -1);
+});
+
+test(function() {
+    let rule = rules[2];
+    assert_equals(rule.fontFamily, "bar");
+    assert_equals(rule.basePalette, "2");
+    assert_equals(rule.size, 0);
+});
+
+test(function() {
+    let text = rules[3].cssText;
+    assert_equals(text.indexOf("base-palette: \"foo\";"), -1);
+    assert_equals(text.indexOf("base-palette: 1"), -1);
+    assert_not_equals(text.indexOf("base-palette: \"bar\";"), -1);
+    assert_equals(text.indexOf("override-color: 3"), -1);
+    assert_equals(text.indexOf("override-color: \"baz\""), -1);
+    assert_not_equals(text.indexOf("override-color: 4"), -1);
+});
+
+test(function() {
+    let rule = rules[3];
+    assert_equals(rule.fontFamily, "");
+    assert_equals(rule.basePalette, "bar");
+    assert_equals(rule.size, 1);
+    assert_equals(rule.get(7), undefined);
+    assert_not_equals(rule.get(4).indexOf("rgb"), -1);
+});
+
+test(function() {
+    let text = rules[4].cssText;
+    assert_equals(text.indexOf("51"), -1);
+    assert_not_equals(text.indexOf("102"), -1);
+});
+
+test(function() {
+    let rule = rules[4];
+    assert_equals(rule.fontFamily, "");
+    assert_equals(rule.basePalette, "");
+    assert_equals(rule.size, 1);
+    assert_equals(rule.get(7), undefined);
+    assert_not_equals(rule.get(3).indexOf("102"), -1);
+});
+
+test(function() {
+    let text = rules[5].cssText;
+    assert_not_equals(text.indexOf("foo"), -1);
+});
+
+test(function() {
+    let rule = rules[5];
+    assert_equals(rule.fontFamily, "foo");
+    assert_equals(rule.basePalette, "");
+    assert_equals(rule.size, 0);
+});
+
+test(function() {
+    let text = rules[6].cssText;
+    assert_not_equals(text.indexOf("51"), -1);
+    assert_not_equals(text.indexOf("102"), -1);
+});
+
+test(function() {
+    let rule = rules[6];
+    assert_equals(rule.fontFamily, "");
+    assert_equals(rule.basePalette, "");
+    assert_equals(rule.size, 2);
+    assert_equals(rule.get(7), undefined);
+    assert_not_equals(rule.get(3).indexOf("51"), -1);
+    assert_not_equals(rule.get(4).indexOf("102"), -1);
+});
+
+test(function() {
+    let text = rules[7].cssText;
+    assert_not_equals(text.indexOf("51"), -1);
+    assert_not_equals(text.indexOf("102"), -1);
+});
+
+test(function() {
+    let rule = rules[7];
+    assert_equals(rule.fontFamily, "");
+    assert_equals(rule.basePalette, "");
+    assert_equals(rule.size, 1);
+    assert_equals(rule.get(7), undefined);
+    assert_not_equals(rule.get(3).indexOf("102"), -1);
+    assert_equals(rule.get(4), undefined);
+});
+
+test(function() {
+    let text = rules[8].cssText;
+    assert_not_equals(text.indexOf("base-palette"), -1);
+});
+
+test(function() {
+    let rule = rules[8];
+    assert_equals(rule.fontFamily, "");
+    assert_equals(rule.basePalette, "-3");
+    assert_equals(rule.size, 0);
+});
+
+test(function() {
+    let text = rules[9].cssText;
+    assert_not_equals(text.indexOf("override-color"), -1);
+});
+
+test(function() {
+    let rule = rules[9];
+    assert_equals(rule.fontFamily, "");
+    assert_equals(rule.basePalette, "");
+    assert_equals(rule.size, 1);
+    assert_equals(rule.get(7), undefined);
+    assert_equals(rule.get(-3), undefined);
+});
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/CMakeLists.txt (282805 => 282806)


--- trunk/Source/WebCore/CMakeLists.txt	2021-09-21 07:48:22 UTC (rev 282805)
+++ trunk/Source/WebCore/CMakeLists.txt	2021-09-21 08:24:36 UTC (rev 282806)
@@ -705,6 +705,7 @@
     css/CSSConditionRule.idl
     css/CSSCounterStyleRule.idl
     css/CSSFontFaceRule.idl
+    css/CSSFontPaletteValuesRule.idl
     css/CSSGroupingRule.idl
     css/CSSImportRule.idl
     css/CSSKeyframeRule.idl

Modified: trunk/Source/WebCore/ChangeLog (282805 => 282806)


--- trunk/Source/WebCore/ChangeLog	2021-09-21 07:48:22 UTC (rev 282805)
+++ trunk/Source/WebCore/ChangeLog	2021-09-21 08:24:36 UTC (rev 282806)
@@ -1,5 +1,109 @@
 2021-09-21  Myles C. Maxfield  <[email protected]>
 
+        Parsing support for font-palette-values
+        https://bugs.webkit.org/show_bug.cgi?id=230337
+
+        Reviewed by Antti Koivisto.
+
+        There's nothing particularly interesting here - it's just support for another at-rule.
+        I've implemented what's in the spec right now:
+        https://drafts.csswg.org/css-fonts-4/#font-palette-values
+
+        There are 2 new descriptors: base-palette and override-color. I've added a new CSSValue subclass
+        for each of the items in the override-color list - these items are just tuples of two
+        CSSPrimitiveValues. I could have done this with a CSSValueList which always just happens to have
+        a length of 2, but I thought that was less elegant (and has an extra pointer indirection) than
+        making a class to hold the two CSSPrimitiveValues.
+
+        The only difference with what's in the spec is that I've given a different value to
+        FONT_PALETTE_VALUES_RULE, because its current value conflicts with VIEWPORT_RULE. This is being
+        tracked at https://github.com/w3c/csswg-drafts/issues/6623.
+
+        I created a new datatype and file in platform/graphics/FontPaletteValues.h because this data will
+        eventually be passed to preparePlatformFont(), which is in platform/, so this data needs to be
+        accessible from platform/ too.
+
+        Tests: imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-invalid.html
+               imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-valid.html
+
+        * CMakeLists.txt:
+        * DerivedSources-input.xcfilelist:
+        * DerivedSources-output.xcfilelist:
+        * DerivedSources.make:
+        * Headers.cmake:
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSCSSRuleCustom.cpp:
+        (WebCore::toJSNewlyCreated):
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
+        * css/CSSFontPaletteValuesOverrideColorValue.cpp: Copied from Source/WebCore/css/StyleRuleType.h.
+        (WebCore::CSSFontPaletteValuesOverrideColorValue::customCSSText const):
+        (WebCore::CSSFontPaletteValuesOverrideColorValue::equals const):
+        * css/CSSFontPaletteValuesOverrideColorValue.h: Copied from Source/WebCore/css/StyleRuleType.h.
+        * css/CSSFontPaletteValuesRule.cpp: Added.
+        (WebCore::CSSFontPaletteValuesRule::CSSFontPaletteValuesRule):
+        (WebCore::CSSFontPaletteValuesRule::~CSSFontPaletteValuesRule):
+        (WebCore::parseString):
+        (WebCore::CSSFontPaletteValuesRule::fontFamily const):
+        (WebCore::CSSFontPaletteValuesRule::basePalette const):
+        (WebCore::CSSFontPaletteValuesRule::setFontFamily):
+        (WebCore::CSSFontPaletteValuesRule::setBasePalette):
+        (WebCore::CSSFontPaletteValuesRule::initializeMapLike):
+        (WebCore::CSSFontPaletteValuesRule::setFromMapLike):
+        (WebCore::CSSFontPaletteValuesRule::clear):
+        (WebCore::CSSFontPaletteValuesRule::remove):
+        (WebCore::CSSFontPaletteValuesRule::cssText const):
+        (WebCore::CSSFontPaletteValuesRule::reattach):
+        * css/CSSFontPaletteValuesRule.h: Copied from Source/WebCore/css/StyleRuleType.h.
+        * css/CSSFontPaletteValuesRule.idl: Added.
+        * css/CSSProperties.json:
+        * css/CSSRule.cpp:
+        * css/CSSRule.h:
+        * css/CSSRule.idl:
+        * css/CSSValue.cpp:
+        (WebCore::CSSValue::equals const):
+        (WebCore::CSSValue::cssText const):
+        (WebCore::CSSValue::destroy):
+        * css/CSSValue.h:
+        (WebCore::CSSValue::isFontPaletteValuesOverrideColorValue const):
+        * css/StyleRule.cpp:
+        (WebCore::StyleRuleBase::destroy):
+        (WebCore::StyleRuleBase::copy const):
+        (WebCore::StyleRuleBase::createCSSOMWrapper const):
+        (WebCore::StyleRuleFontPaletteValues::StyleRuleFontPaletteValues):
+        * css/StyleRule.h:
+        (WebCore::StyleRuleBase::isFontPaletteValuesRule const):
+        (isType):
+        * css/StyleRuleType.h:
+        * css/StyleSheetContents.cpp:
+        (WebCore::traverseRulesInVector):
+        (WebCore::StyleSheetContents::traverseSubresources const):
+        * css/parser/CSSAtRuleID.cpp:
+        (WebCore::cssAtRuleID):
+        * css/parser/CSSAtRuleID.h:
+        * css/parser/CSSParserImpl.cpp:
+        (WebCore::CSSParserImpl::consumeAtRule):
+        (WebCore::CSSParserImpl::consumeFontPaletteValuesRule):
+        (WebCore::CSSParserImpl::consumeDeclaration):
+        * css/parser/CSSParserImpl.h:
+        * css/parser/CSSPropertyParser.cpp:
+        (WebCore::CSSPropertyParser::parseValue):
+        (WebCore::consumeBasePaletteDescriptor):
+        (WebCore::consumeOverrideColorDescriptor):
+        (WebCore::CSSPropertyParser::parseFontPaletteValuesDescriptor):
+        * css/parser/CSSPropertyParser.h:
+        * platform/graphics/FontPaletteValues.h: Added.
+        (WebCore::FontPaletteValues::FontPaletteValues):
+        (WebCore::FontPaletteValues::basePalette const):
+        (WebCore::FontPaletteValues::setBasePalette):
+        (WebCore::FontPaletteValues::overrideColor const):
+        (WebCore::FontPaletteValues::appendOverrideColor):
+        (WebCore::FontPaletteValues::clearOverrideColor):
+        (WebCore::FontPaletteValues::remove):
+
+2021-09-21  Myles C. Maxfield  <[email protected]>
+
         Maplike infrastructure ASSERT()s if the first operation is a delete of a existing values
         https://bugs.webkit.org/show_bug.cgi?id=230530
 

Modified: trunk/Source/WebCore/DerivedSources-input.xcfilelist (282805 => 282806)


--- trunk/Source/WebCore/DerivedSources-input.xcfilelist	2021-09-21 07:48:22 UTC (rev 282805)
+++ trunk/Source/WebCore/DerivedSources-input.xcfilelist	2021-09-21 08:24:36 UTC (rev 282806)
@@ -682,6 +682,7 @@
 $(PROJECT_DIR)/css/CSSConditionRule.idl
 $(PROJECT_DIR)/css/CSSCounterStyleRule.idl
 $(PROJECT_DIR)/css/CSSFontFaceRule.idl
+$(PROJECT_DIR)/css/CSSFontPaletteValuesRule.idl
 $(PROJECT_DIR)/css/CSSGroupingRule.idl
 $(PROJECT_DIR)/css/CSSImportRule.idl
 $(PROJECT_DIR)/css/CSSKeyframeRule.idl

Modified: trunk/Source/WebCore/DerivedSources-output.xcfilelist (282805 => 282806)


--- trunk/Source/WebCore/DerivedSources-output.xcfilelist	2021-09-21 07:48:22 UTC (rev 282805)
+++ trunk/Source/WebCore/DerivedSources-output.xcfilelist	2021-09-21 08:24:36 UTC (rev 282806)
@@ -300,6 +300,8 @@
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSCounterStyleRule.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSFontFaceRule.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSFontFaceRule.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSFontPaletteValuesRule.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSFontPaletteValuesRule.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSGroupingRule.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSGroupingRule.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSImportRule.cpp

Modified: trunk/Source/WebCore/DerivedSources.make (282805 => 282806)


--- trunk/Source/WebCore/DerivedSources.make	2021-09-21 07:48:22 UTC (rev 282805)
+++ trunk/Source/WebCore/DerivedSources.make	2021-09-21 08:24:36 UTC (rev 282806)
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2020 Apple Inc. All rights reserved.
+# Copyright (C) 2006-2021 Apple Inc. All rights reserved.
 # Copyright (C) 2006 Samuel Weinig <[email protected]>
 # Copyright (C) 2009 Cameron McCormack <[email protected]>
 #
@@ -575,6 +575,7 @@
     $(WebCore)/css/CSSConditionRule.idl \
     $(WebCore)/css/CSSCounterStyleRule.idl \
     $(WebCore)/css/CSSFontFaceRule.idl \
+    $(WebCore)/css/CSSFontPaletteValuesRule.idl \
     $(WebCore)/css/CSSGroupingRule.idl \
     $(WebCore)/css/CSSImportRule.idl \
     $(WebCore)/css/CSSKeyframeRule.idl \

Modified: trunk/Source/WebCore/Headers.cmake (282805 => 282806)


--- trunk/Source/WebCore/Headers.cmake	2021-09-21 07:48:22 UTC (rev 282805)
+++ trunk/Source/WebCore/Headers.cmake	2021-09-21 08:24:36 UTC (rev 282806)
@@ -366,6 +366,7 @@
     css/CSSConditionRule.h
     css/CSSCustomPropertyValue.h
     css/CSSFontFaceRule.h
+    css/CSSFontPaletteValuesRule.h
     css/CSSFontFamily.h
     css/CSSGridIntegerRepeatValue.h
     css/CSSGroupingRule.h
@@ -1259,6 +1260,7 @@
     platform/graphics/FontFamilySpecificationNull.h
     platform/graphics/FontGenericFamilies.h
     platform/graphics/FontMetrics.h
+    platform/graphics/FontPaletteValues.h
     platform/graphics/FontPlatformData.h
     platform/graphics/FontRanges.h
     platform/graphics/FontSelectionAlgorithm.h

Modified: trunk/Source/WebCore/Sources.txt (282805 => 282806)


--- trunk/Source/WebCore/Sources.txt	2021-09-21 07:48:22 UTC (rev 282805)
+++ trunk/Source/WebCore/Sources.txt	2021-09-21 08:24:36 UTC (rev 282806)
@@ -1,4 +1,4 @@
-// Copyright (C) 2017-2020 Apple Inc. All rights reserved.
+// Copyright (C) 2017-2021 Apple Inc. All rights reserved.
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions
@@ -658,6 +658,8 @@
 css/CSSFontFaceSource.cpp
 css/CSSFontFaceSrcValue.cpp
 css/CSSFontFeatureValue.cpp
+css/CSSFontPaletteValuesOverrideColorValue.cpp
+css/CSSFontPaletteValuesRule.cpp
 css/CSSFontSelector.cpp
 css/CSSFontStyleRangeValue.cpp
 css/CSSFontStyleValue.cpp
@@ -2824,6 +2826,7 @@
 JSCSSConditionRule.cpp
 JSCSSCounterStyleRule.cpp
 JSCSSFontFaceRule.cpp
+JSCSSFontPaletteValuesRule.cpp
 JSCSSGroupingRule.cpp
 JSCSSImportRule.cpp
 JSCSSKeyframeRule.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (282805 => 282806)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-09-21 07:48:22 UTC (rev 282805)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-09-21 08:24:36 UTC (rev 282806)
@@ -653,6 +653,7 @@
 		1C24EEA91C72A7B40080F8FC /* JSFontFaceSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C24EEA71C72A7B40080F8FC /* JSFontFaceSet.h */; };
 		1C43DE6B22AB4B8A001527D9 /* LocalCurrentTraitCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C43DE6822AB4B8A001527D9 /* LocalCurrentTraitCollection.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		1C4D0DD324D9F10D003D7498 /* GlyphBufferMembers.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C4D0DD124D9F0DB003D7498 /* GlyphBufferMembers.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		1C5E1DA826F94B9000E07AF1 /* FontPaletteValues.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C5E1DA626F949B900E07AF1 /* FontPaletteValues.h */; };
 		1C6626111C6E7CA600AB527C /* FontFace.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C66260F1C6E7CA600AB527C /* FontFace.h */; };
 		1C73A7132185757E004CCEA5 /* TextUnderlineOffset.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CB6B4FB217B83940093B9CD /* TextUnderlineOffset.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		1C73A71521857587004CCEA5 /* TextDecorationThickness.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CB6B4F8217B83930093B9CD /* TextDecorationThickness.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -667,6 +668,7 @@
 		1CE8864126105BF2000C816C /* InMemoryDisplayList.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CE8863F26105A5F000C816C /* InMemoryDisplayList.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		1CE8D12726185C0E00FC3AEF /* DisplayListItemBufferIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CE8D12526185BD800FC3AEF /* DisplayListItemBufferIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		1CE8D12E261861C400FC3AEF /* DisplayListIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CE8D12C2618616400FC3AEF /* DisplayListIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		1CEAA53226F336FC00868507 /* CSSFontPaletteValuesOverrideColorValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CEAA53126F331C100868507 /* CSSFontPaletteValuesOverrideColorValue.h */; };
 		1CFAE3230A6D6A3F0032593D /* libobjc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1CFAE3220A6D6A3F0032593D /* libobjc.dylib */; };
 		1D0026A42374D62400CA6CDF /* JSPictureInPictureWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 1D0026A22374D62300CA6CDF /* JSPictureInPictureWindow.h */; };
 		1D0026AA2374F9EA00CA6CDF /* JSEnterPictureInPictureEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 1D0026A82374F9D900CA6CDF /* JSEnterPictureInPictureEvent.h */; };
@@ -7051,6 +7053,7 @@
 		1C43DE6A22AB4B8A001527D9 /* LocalCurrentTraitCollection.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalCurrentTraitCollection.mm; sourceTree = "<group>"; };
 		1C4D0DD124D9F0DB003D7498 /* GlyphBufferMembers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GlyphBufferMembers.h; sourceTree = "<group>"; };
 		1C50C49522C84F2400A6E4BE /* WHLSLStandardLibraryFunctionMap.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLStandardLibraryFunctionMap.cpp; sourceTree = "<group>"; };
+		1C5E1DA626F949B900E07AF1 /* FontPaletteValues.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontPaletteValues.h; sourceTree = "<group>"; };
 		1C66260E1C6E7CA600AB527C /* FontFace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontFace.cpp; sourceTree = "<group>"; };
 		1C66260F1C6E7CA600AB527C /* FontFace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontFace.h; sourceTree = "<group>"; };
 		1C6FD8AC250A294D00D6E920 /* FontPlatformDataCoreText.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FontPlatformDataCoreText.cpp; sourceTree = "<group>"; };
@@ -7083,6 +7086,11 @@
 		1CE8D12526185BD800FC3AEF /* DisplayListItemBufferIdentifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayListItemBufferIdentifier.h; sourceTree = "<group>"; };
 		1CE8D12B2618616400FC3AEF /* DisplayListIterator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayListIterator.cpp; sourceTree = "<group>"; };
 		1CE8D12C2618616400FC3AEF /* DisplayListIterator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayListIterator.h; sourceTree = "<group>"; };
+		1CEAA52C26F31A3C00868507 /* CSSFontPaletteValuesRule.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CSSFontPaletteValuesRule.cpp; sourceTree = "<group>"; };
+		1CEAA52D26F31A3C00868507 /* CSSFontPaletteValuesRule.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSSFontPaletteValuesRule.h; sourceTree = "<group>"; };
+		1CEAA52F26F31AF800868507 /* CSSFontPaletteValuesRule.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = CSSFontPaletteValuesRule.idl; sourceTree = "<group>"; };
+		1CEAA53026F331C100868507 /* CSSFontPaletteValuesOverrideColorValue.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CSSFontPaletteValuesOverrideColorValue.cpp; sourceTree = "<group>"; };
+		1CEAA53126F331C100868507 /* CSSFontPaletteValuesOverrideColorValue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSSFontPaletteValuesOverrideColorValue.h; sourceTree = "<group>"; };
 		1CF0BFD42298706800ED2074 /* TextSizeAdjustment.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TextSizeAdjustment.cpp; sourceTree = "<group>"; };
 		1CF18F3C26BB5AF2004B1722 /* LogInitialization.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LogInitialization.cpp; sourceTree = "<group>"; };
 		1CFAE3220A6D6A3F0032593D /* libobjc.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libobjc.dylib; path = /usr/lib/libobjc.dylib; sourceTree = "<absolute>"; };
@@ -27010,6 +27018,7 @@
 				E44EE3A617576E5500EEE8CF /* FontGenericFamilies.cpp */,
 				E44EE3A717576E5500EEE8CF /* FontGenericFamilies.h */,
 				0845680712B90DA600960A9F /* FontMetrics.h */,
+				1C5E1DA626F949B900E07AF1 /* FontPaletteValues.h */,
 				84B62684133138F90095A489 /* FontPlatformData.cpp */,
 				B5320D69122A24E9002D1440 /* FontPlatformData.h */,
 				371F4FFB0D25E7F300ECE0D5 /* FontRanges.cpp */,
@@ -29593,6 +29602,11 @@
 				83520C7D1A71BFCC006BD2AA /* CSSFontFamily.h */,
 				4A6E9FC113C17D1D0046A7F8 /* CSSFontFeatureValue.cpp */,
 				4A6E9FC213C17D1D0046A7F8 /* CSSFontFeatureValue.h */,
+				1CEAA53026F331C100868507 /* CSSFontPaletteValuesOverrideColorValue.cpp */,
+				1CEAA53126F331C100868507 /* CSSFontPaletteValuesOverrideColorValue.h */,
+				1CEAA52C26F31A3C00868507 /* CSSFontPaletteValuesRule.cpp */,
+				1CEAA52D26F31A3C00868507 /* CSSFontPaletteValuesRule.h */,
+				1CEAA52F26F31AF800868507 /* CSSFontPaletteValuesRule.idl */,
 				BC64B4D30CB4298A005F2B62 /* CSSFontSelector.cpp */,
 				BC64B4D40CB4298A005F2B62 /* CSSFontSelector.h */,
 				C2E38EFF1E84573500CA3ADF /* CSSFontStyleRangeValue.cpp */,
@@ -31967,6 +31981,7 @@
 				BC64B4DA0CB4298A005F2B62 /* CSSFontFaceSrcValue.h in Headers */,
 				83520C7E1A71BFCC006BD2AA /* CSSFontFamily.h in Headers */,
 				4A6E9FC413C17D1D0046A7F8 /* CSSFontFeatureValue.h in Headers */,
+				1CEAA53226F336FC00868507 /* CSSFontPaletteValuesOverrideColorValue.h in Headers */,
 				BC64B4DC0CB4298A005F2B62 /* CSSFontSelector.h in Headers */,
 				C2E38F021E84573500CA3ADF /* CSSFontStyleRangeValue.h in Headers */,
 				C2E38EFE1E8396FD00CA3ADF /* CSSFontStyleValue.h in Headers */,
@@ -32504,6 +32519,7 @@
 				658436860AE01B7400E53743 /* FontLoadRequest.h in Headers */,
 				BC4A532F256057CD0028C592 /* FontLoadTimingOverride.h in Headers */,
 				0845680812B90DA600960A9F /* FontMetrics.h in Headers */,
+				1C5E1DA826F94B9000E07AF1 /* FontPaletteValues.h in Headers */,
 				B5320D6B122A24E9002D1440 /* FontPlatformData.h in Headers */,
 				371F4FFC0D25E7F300ECE0D5 /* FontRanges.h in Headers */,
 				BC4A5339256063980028C592 /* FontRenderingMode.h in Headers */,

Modified: trunk/Source/WebCore/bindings/js/JSCSSRuleCustom.cpp (282805 => 282806)


--- trunk/Source/WebCore/bindings/js/JSCSSRuleCustom.cpp	2021-09-21 07:48:22 UTC (rev 282805)
+++ trunk/Source/WebCore/bindings/js/JSCSSRuleCustom.cpp	2021-09-21 08:24:36 UTC (rev 282806)
@@ -28,6 +28,7 @@
 
 #include "CSSCounterStyleRule.h"
 #include "CSSFontFaceRule.h"
+#include "CSSFontPaletteValuesRule.h"
 #include "CSSImportRule.h"
 #include "CSSKeyframeRule.h"
 #include "CSSKeyframesRule.h"
@@ -38,6 +39,7 @@
 #include "CSSSupportsRule.h"
 #include "JSCSSCounterStyleRule.h"
 #include "JSCSSFontFaceRule.h"
+#include "JSCSSFontPaletteValuesRule.h"
 #include "JSCSSImportRule.h"
 #include "JSCSSKeyframeRule.h"
 #include "JSCSSKeyframesRule.h"
@@ -70,6 +72,8 @@
         return createWrapper<CSSMediaRule>(globalObject, WTFMove(rule));
     case CSSRule::FONT_FACE_RULE:
         return createWrapper<CSSFontFaceRule>(globalObject, WTFMove(rule));
+    case CSSRule::FONT_PALETTE_VALUES_RULE:
+        return createWrapper<CSSFontPaletteValuesRule>(globalObject, WTFMove(rule));
     case CSSRule::PAGE_RULE:
         return createWrapper<CSSPageRule>(globalObject, WTFMove(rule));
     case CSSRule::IMPORT_RULE:

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (282805 => 282806)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2021-09-21 07:48:22 UTC (rev 282805)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2021-09-21 08:24:36 UTC (rev 282806)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2004 Zack Rusin <[email protected]>
- * Copyright (C) 2004-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2021 Apple Inc. All rights reserved.
  * Copyright (C) 2007 Alexey Proskuryakov <[email protected]>
  * Copyright (C) 2007 Nicholas Shanks <[email protected]>
  * Copyright (C) 2011 Sencha, Inc. All rights reserved.
@@ -4052,6 +4052,11 @@
         case CSSPropertyFontDisplay:
             break;
 
+        // Unimplemented @font-palette-values properties
+        case CSSPropertyBasePalette:
+        case CSSPropertyOverrideColor:
+            break;
+
         /* Other unimplemented properties */
         case CSSPropertyPage: // for @page
         case CSSPropertySize: // for @page

Copied: trunk/Source/WebCore/css/CSSFontPaletteValuesOverrideColorValue.cpp (from rev 282805, trunk/Source/WebCore/css/StyleRuleType.h) (0 => 282806)


--- trunk/Source/WebCore/css/CSSFontPaletteValuesOverrideColorValue.cpp	                        (rev 0)
+++ trunk/Source/WebCore/css/CSSFontPaletteValuesOverrideColorValue.cpp	2021-09-21 08:24:36 UTC (rev 282806)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "CSSFontPaletteValuesOverrideColorValue.h"
+
+namespace WebCore {
+
+String CSSFontPaletteValuesOverrideColorValue::customCSSText() const
+{
+    return makeString(m_key->cssText(), " ", m_color->cssText());
+}
+
+bool CSSFontPaletteValuesOverrideColorValue::equals(const CSSFontPaletteValuesOverrideColorValue& other) const
+{
+    return m_key->equals(other.key()) && m_color->equals(other.color());
+}
+
+}

Copied: trunk/Source/WebCore/css/CSSFontPaletteValuesOverrideColorValue.h (from rev 282805, trunk/Source/WebCore/css/StyleRuleType.h) (0 => 282806)


--- trunk/Source/WebCore/css/CSSFontPaletteValuesOverrideColorValue.h	                        (rev 0)
+++ trunk/Source/WebCore/css/CSSFontPaletteValuesOverrideColorValue.h	2021-09-21 08:24:36 UTC (rev 282806)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "CSSValue.h"
+#include "CachedResourceHandle.h"
+#include "ResourceLoaderOptions.h"
+#include <wtf/Function.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class CachedFont;
+class FontLoadRequest;
+class SVGFontFaceElement;
+class ScriptExecutionContext;
+
+class CSSFontPaletteValuesOverrideColorValue final : public CSSValue {
+public:
+    static Ref<CSSFontPaletteValuesOverrideColorValue> create(Ref<CSSPrimitiveValue>&& key, Ref<CSSPrimitiveValue>&& color)
+    {
+        return adoptRef(*new CSSFontPaletteValuesOverrideColorValue(WTFMove(key), WTFMove(color)));
+    }
+
+    const CSSPrimitiveValue& key() const
+    {
+        return m_key.get();
+    }
+
+    const CSSPrimitiveValue& color() const
+    {
+        return m_color.get();
+    }
+
+    String customCSSText() const;
+
+    bool equals(const CSSFontPaletteValuesOverrideColorValue&) const;
+
+private:
+    CSSFontPaletteValuesOverrideColorValue(Ref<CSSPrimitiveValue>&& key, Ref<CSSPrimitiveValue>&& color)
+        : CSSValue(FontPaletteValuesOverrideColorClass)
+        , m_key(WTFMove(key))
+        , m_color(WTFMove(color))
+    {
+    }
+
+    Ref<CSSPrimitiveValue> m_key;
+    Ref<CSSPrimitiveValue> m_color;
+};
+
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSFontPaletteValuesOverrideColorValue, isFontPaletteValuesOverrideColorValue())

Added: trunk/Source/WebCore/css/CSSFontPaletteValuesRule.cpp (0 => 282806)


--- trunk/Source/WebCore/css/CSSFontPaletteValuesRule.cpp	                        (rev 0)
+++ trunk/Source/WebCore/css/CSSFontPaletteValuesRule.cpp	2021-09-21 08:24:36 UTC (rev 282806)
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "CSSFontPaletteValuesRule.h"
+
+#include "ColorSerialization.h"
+#include "JSDOMMapLike.h"
+#include "PropertySetCSSStyleDeclaration.h"
+#include "StyleProperties.h"
+#include "StyleRule.h"
+#include <wtf/text/StringBuilder.h>
+
+namespace WebCore {
+
+CSSFontPaletteValuesRule::CSSFontPaletteValuesRule(StyleRuleFontPaletteValues& fontPaletteValuesRule, CSSStyleSheet* parent)
+    : CSSRule(parent)
+    , m_fontPaletteValuesRule(fontPaletteValuesRule)
+{
+}
+
+CSSFontPaletteValuesRule::~CSSFontPaletteValuesRule()
+{
+}
+
+String CSSFontPaletteValuesRule::fontFamily() const
+{
+    return m_fontPaletteValuesRule->fontFamily();
+}
+
+String CSSFontPaletteValuesRule::basePalette() const
+{
+    return WTF::switchOn(m_fontPaletteValuesRule->basePalette(), [&](int64_t index) {
+        return makeString(index);
+    }, [&](const AtomString& basePalette) -> String {
+        if (!basePalette.isNull())
+            return basePalette.string();
+        return StringImpl::empty();
+    });
+}
+
+void CSSFontPaletteValuesRule::initializeMapLike(DOMMapAdapter& map)
+{
+    for (auto& pair : m_fontPaletteValuesRule->overrideColor()) {
+        if (!WTF::holds_alternative<int64_t>(pair.first))
+            continue;
+        map.set<IDLUnsignedLong, IDLUSVString>(WTF::get<int64_t>(pair.first), serializationForCSS(pair.second));
+    }
+}
+
+String CSSFontPaletteValuesRule::cssText() const
+{
+    StringBuilder builder;
+    builder.append("@font-palette-values ", m_fontPaletteValuesRule->name(), " { ");
+    if (!m_fontPaletteValuesRule->fontFamily().isNull())
+        builder.append("font-family: ", m_fontPaletteValuesRule->fontFamily(), "; ");
+    WTF::switchOn(m_fontPaletteValuesRule->basePalette(), [&](int64_t index) {
+        builder.append("base-palette: ", index, "; ");
+    }, [&](const AtomString& basePalette) {
+        if (!basePalette.isNull())
+            builder.append("base-palette: ", serializeString(basePalette.string()), "; ");
+    });
+    if (!m_fontPaletteValuesRule->overrideColor().isEmpty()) {
+        builder.append("override-color:");
+        for (size_t i = 0; i < m_fontPaletteValuesRule->overrideColor().size(); ++i) {
+            if (i)
+                builder.append(',');
+            builder.append(' ');
+            WTF::switchOn(m_fontPaletteValuesRule->overrideColor()[i].first, [&](const AtomString& name) {
+                builder.append(serializeString(name.string()));
+            }, [&](int64_t index) {
+                builder.append(index);
+            });
+            builder.append(' ', serializationForCSS(m_fontPaletteValuesRule->overrideColor()[i].second));
+        }
+        builder.append("; ");
+    }
+    builder.append('}');
+    return builder.toString();
+}
+
+void CSSFontPaletteValuesRule::reattach(StyleRuleBase& rule)
+{
+    m_fontPaletteValuesRule = static_cast<StyleRuleFontPaletteValues&>(rule);
+}
+
+} // namespace WebCore
Property changes on: trunk/Source/WebCore/css/CSSFontPaletteValuesRule.cpp
___________________________________________________________________

Added: svn:eol-style

+native \ No newline at end of property

Copied: trunk/Source/WebCore/css/CSSFontPaletteValuesRule.h (from rev 282805, trunk/Source/WebCore/css/StyleRuleType.h) (0 => 282806)


--- trunk/Source/WebCore/css/CSSFontPaletteValuesRule.h	                        (rev 0)
+++ trunk/Source/WebCore/css/CSSFontPaletteValuesRule.h	2021-09-21 08:24:36 UTC (rev 282806)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "CSSRule.h"
+
+namespace WebCore {
+
+class CSSStyleDeclaration;
+class DOMMapAdapter;
+class StyleRuleFontFace;
+class StyleRuleCSSStyleDeclaration;
+
+class CSSFontPaletteValuesRule final : public CSSRule {
+public:
+    static Ref<CSSFontPaletteValuesRule> create(StyleRuleFontPaletteValues& rule, CSSStyleSheet* sheet) { return adoptRef(*new CSSFontPaletteValuesRule(rule, sheet)); }
+
+    virtual ~CSSFontPaletteValuesRule();
+
+    String fontFamily() const;
+    String basePalette() const;
+
+    void initializeMapLike(DOMMapAdapter&);
+
+private:
+    CSSFontPaletteValuesRule(StyleRuleFontPaletteValues&, CSSStyleSheet* parent);
+
+    CSSRule::Type type() const final { return FONT_PALETTE_VALUES_RULE; }
+    String cssText() const final;
+    void reattach(StyleRuleBase&) final;
+
+    Ref<StyleRuleFontPaletteValues> m_fontPaletteValuesRule;
+};
+
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_CSS_RULE(CSSFontPaletteValuesRule, CSSRule::FONT_PALETTE_VALUES_RULE)

Added: trunk/Source/WebCore/css/CSSFontPaletteValuesRule.idl (0 => 282806)


--- trunk/Source/WebCore/css/CSSFontPaletteValuesRule.idl	                        (rev 0)
+++ trunk/Source/WebCore/css/CSSFontPaletteValuesRule.idl	2021-09-21 08:24:36 UTC (rev 282806)
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+typedef USVString CSSOMString;
+
+[
+    Exposed=Window
+] interface CSSFontPaletteValuesRule : CSSRule {
+    readonly maplike<unsigned long, CSSOMString>;
+    readonly attribute CSSOMString fontFamily;
+    readonly attribute CSSOMString basePalette;
+};
+

Modified: trunk/Source/WebCore/css/CSSProperties.json (282805 => 282806)


--- trunk/Source/WebCore/css/CSSProperties.json	2021-09-21 07:48:22 UTC (rev 282805)
+++ trunk/Source/WebCore/css/CSSProperties.json	2021-09-21 08:24:36 UTC (rev 282806)
@@ -4085,6 +4085,26 @@
                 "url": "https://www.w3.org/TR/css-fonts-3/#src-desc"
             }
         },
+        "base-palette": {
+            "codegen-properties": {
+                "skip-builder": true,
+                "descriptor-only": true
+            },
+            "specification": {
+                "category": "css-fonts",
+                "url": "https://drafts.csswg.org/css-fonts-4/#base-palette-desc"
+            }
+        },
+        "override-color": {
+            "codegen-properties": {
+                "skip-builder": true,
+                "descriptor-only": true
+            },
+            "specification": {
+                "category": "css-fonts",
+                "url": "https://drafts.csswg.org/css-fonts-4/#override-color"
+            }
+        },
         "stop-color": {
             "codegen-properties": {
                 "converter": "SVGColor",

Modified: trunk/Source/WebCore/css/CSSRule.cpp (282805 => 282806)


--- trunk/Source/WebCore/css/CSSRule.cpp	2021-09-21 07:48:22 UTC (rev 282805)
+++ trunk/Source/WebCore/css/CSSRule.cpp	2021-09-21 08:24:36 UTC (rev 282806)
@@ -1,7 +1,7 @@
 /*
  * (C) 1999-2003 Lars Knoll ([email protected])
  * (C) 2002-2003 Dirk Mueller ([email protected])
- * Copyright (C) 2002, 2005, 2006, 2007, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2002-2021 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -48,6 +48,7 @@
 COMPILE_ASSERT(StyleRuleType::Namespace == static_cast<StyleRuleType>(CSSRule::Type::NAMESPACE_RULE), enums_should_match);
 COMPILE_ASSERT(StyleRuleType::CounterStyle == static_cast<StyleRuleType>(CSSRule::Type::COUNTER_STYLE_RULE), enums_should_match);
 COMPILE_ASSERT(StyleRuleType::Supports == static_cast<StyleRuleType>(CSSRule::Type::SUPPORTS_RULE), enums_should_match);
+COMPILE_ASSERT(StyleRuleType::FontPaletteValues == static_cast<StyleRuleType>(CSSRule::Type::FONT_PALETTE_VALUES_RULE), enums_should_match);
 
 ExceptionOr<void> CSSRule::setCssText(const String&)
 {

Modified: trunk/Source/WebCore/css/CSSRule.h (282805 => 282806)


--- trunk/Source/WebCore/css/CSSRule.h	2021-09-21 07:48:22 UTC (rev 282805)
+++ trunk/Source/WebCore/css/CSSRule.h	2021-09-21 08:24:36 UTC (rev 282806)
@@ -1,7 +1,7 @@
 /*
  * (C) 1999-2003 Lars Knoll ([email protected])
  * (C) 2002-2003 Dirk Mueller ([email protected])
- * Copyright (C) 2002-2020 Apple Inc. All rights reserved.
+ * Copyright (C) 2002-2021 Apple Inc. All rights reserved.
  * Copyright (C) 2011 Andreas Kling ([email protected])
  *
  * This library is free software; you can redistribute it and/or
@@ -38,19 +38,20 @@
 
     // WebIDL enum
     enum Type {
-        UNKNOWN_RULE,
-        STYLE_RULE,
-        CHARSET_RULE,
-        IMPORT_RULE,
-        MEDIA_RULE,
-        FONT_FACE_RULE,
-        PAGE_RULE,
-        KEYFRAMES_RULE,
-        KEYFRAME_RULE,
-        MARGIN_RULE,
-        NAMESPACE_RULE,
-        COUNTER_STYLE_RULE,
-        SUPPORTS_RULE
+        UNKNOWN_RULE = 0,
+        STYLE_RULE = 1,
+        CHARSET_RULE = 2,
+        IMPORT_RULE = 3,
+        MEDIA_RULE = 4,
+        FONT_FACE_RULE = 5,
+        PAGE_RULE = 6,
+        KEYFRAMES_RULE = 7,
+        KEYFRAME_RULE = 8,
+        MARGIN_RULE = 9,
+        NAMESPACE_RULE = 10,
+        COUNTER_STYLE_RULE = 11,
+        SUPPORTS_RULE = 12,
+        FONT_PALETTE_VALUES_RULE = 19 // https://github.com/w3c/csswg-drafts/issues/6623
     };
 
     enum DeprecatedType {

Modified: trunk/Source/WebCore/css/CSSRule.idl (282805 => 282806)


--- trunk/Source/WebCore/css/CSSRule.idl	2021-09-21 07:48:22 UTC (rev 282805)
+++ trunk/Source/WebCore/css/CSSRule.idl	2021-09-21 08:24:36 UTC (rev 282806)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2020 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2021 Apple Inc. All rights reserved.
  * Copyright (C) 2006 Samuel Weinig <[email protected]>
  *
  * This library is free software; you can redistribute it and/or
@@ -44,6 +44,7 @@
     const unsigned short NAMESPACE_RULE = 10;
     [EnabledBySetting=CSSCounterStyleAtRules] const unsigned short COUNTER_STYLE_RULE = 11;
     const unsigned short SUPPORTS_RULE = 12;
+    const unsigned short FONT_PALETTE_VALUES_RULE = 19; /* https://github.com/w3c/csswg-drafts/issues/6623 */
 
     // Legacy synonyms for the above, kept to avoid breaking existing content.
     const unsigned short WEBKIT_KEYFRAMES_RULE = 7;

Modified: trunk/Source/WebCore/css/CSSValue.cpp (282805 => 282806)


--- trunk/Source/WebCore/css/CSSValue.cpp	2021-09-21 07:48:22 UTC (rev 282805)
+++ trunk/Source/WebCore/css/CSSValue.cpp	2021-09-21 08:24:36 UTC (rev 282806)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2011 Andreas Kling ([email protected])
  * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -39,6 +40,7 @@
 #include "CSSFilterImageValue.h"
 #include "CSSFontFaceSrcValue.h"
 #include "CSSFontFeatureValue.h"
+#include "CSSFontPaletteValuesOverrideColorValue.h"
 #include "CSSFontStyleRangeValue.h"
 #include "CSSFontStyleValue.h"
 #include "CSSFontValue.h"
@@ -164,6 +166,8 @@
             return compareCSSValues<CSSFontValue>(*this, other);
         case FontFaceSrcClass:
             return compareCSSValues<CSSFontFaceSrcValue>(*this, other);
+        case FontPaletteValuesOverrideColorClass:
+            return compareCSSValues<CSSFontPaletteValuesOverrideColorValue>(*this, other);
         case FontFeatureClass:
             return compareCSSValues<CSSFontFeatureValue>(*this, other);
         case FontVariationClass:
@@ -264,6 +268,8 @@
         return downcast<CSSFontValue>(*this).customCSSText();
     case FontFaceSrcClass:
         return downcast<CSSFontFaceSrcValue>(*this).customCSSText();
+    case FontPaletteValuesOverrideColorClass:
+        return downcast<CSSFontPaletteValuesOverrideColorValue>(*this).customCSSText();
     case FontFeatureClass:
         return downcast<CSSFontFeatureValue>(*this).customCSSText();
     case FontVariationClass:
@@ -377,6 +383,9 @@
     case FontFaceSrcClass:
         delete downcast<CSSFontFaceSrcValue>(this);
         return;
+    case FontPaletteValuesOverrideColorClass:
+        delete downcast<CSSFontPaletteValuesOverrideColorValue>(this);
+        return;
     case FontFeatureClass:
         delete downcast<CSSFontFeatureValue>(this);
         return;

Modified: trunk/Source/WebCore/css/CSSValue.h (282805 => 282806)


--- trunk/Source/WebCore/css/CSSValue.h	2021-09-21 07:48:22 UTC (rev 282805)
+++ trunk/Source/WebCore/css/CSSValue.h	2021-09-21 08:24:36 UTC (rev 282806)
@@ -1,6 +1,6 @@
 /*
  * (C) 1999-2003 Lars Knoll ([email protected])
- * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2021 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -97,6 +97,7 @@
     bool isFontFeatureValue() const { return m_classType == FontFeatureClass; }
     bool isFontVariationValue() const { return m_classType == FontVariationClass; }
     bool isFontFaceSrcValue() const { return m_classType == FontFaceSrcClass; }
+    bool isFontPaletteValuesOverrideColorValue() const { return m_classType == FontPaletteValuesOverrideColorClass; }
     bool isFontValue() const { return m_classType == FontClass; }
     bool isFontStyleValue() const { return m_classType == FontStyleClass; }
     bool isFontStyleRangeValue() const { return m_classType == FontStyleRangeClass; }
@@ -187,6 +188,7 @@
         FontStyleClass,
         FontStyleRangeClass,
         FontFaceSrcClass,
+        FontPaletteValuesOverrideColorClass,
         FunctionClass,
 
         InheritedClass,

Modified: trunk/Source/WebCore/css/StyleRule.cpp (282805 => 282806)


--- trunk/Source/WebCore/css/StyleRule.cpp	2021-09-21 07:48:22 UTC (rev 282805)
+++ trunk/Source/WebCore/css/StyleRule.cpp	2021-09-21 08:24:36 UTC (rev 282806)
@@ -1,7 +1,7 @@
 /*
  * (C) 1999-2003 Lars Knoll ([email protected])
  * (C) 2002-2003 Dirk Mueller ([email protected])
- * Copyright (C) 2002-2020 Apple Inc. All rights reserved.
+ * Copyright (C) 2002-2021 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -25,6 +25,7 @@
 #include "CSSCounterStyleRule.h"
 #include "CSSDeferredParser.h"
 #include "CSSFontFaceRule.h"
+#include "CSSFontPaletteValuesRule.h"
 #include "CSSImportRule.h"
 #include "CSSKeyframeRule.h"
 #include "CSSKeyframesRule.h"
@@ -70,6 +71,9 @@
     case StyleRuleType::FontFace:
         delete downcast<StyleRuleFontFace>(this);
         return;
+    case StyleRuleType::FontPaletteValues:
+        delete downcast<StyleRuleFontPaletteValues>(this);
+        return;
     case StyleRuleType::Media:
         delete downcast<StyleRuleMedia>(this);
         return;
@@ -113,6 +117,8 @@
         return downcast<StyleRulePage>(*this).copy();
     case StyleRuleType::FontFace:
         return downcast<StyleRuleFontFace>(*this).copy();
+    case StyleRuleType::FontPaletteValues:
+        return downcast<StyleRuleFontPaletteValues>(*this).copy();
     case StyleRuleType::Media:
         return downcast<StyleRuleMedia>(*this).copy();
     case StyleRuleType::Supports:
@@ -149,6 +155,9 @@
     case StyleRuleType::FontFace:
         rule = CSSFontFaceRule::create(downcast<StyleRuleFontFace>(self), parentSheet);
         break;
+    case StyleRuleType::FontPaletteValues:
+        rule = CSSFontPaletteValuesRule::create(downcast<StyleRuleFontPaletteValues>(self), parentSheet);
+        break;
     case StyleRuleType::Media:
         rule = CSSMediaRule::create(downcast<StyleRuleMedia>(self), parentSheet);
         break;
@@ -319,6 +328,24 @@
     return downcast<MutableStyleProperties>(m_properties.get());
 }
 
+StyleRuleFontPaletteValues::StyleRuleFontPaletteValues(const AtomString& name, const AtomString& fontFamily, const FontPaletteValues::PaletteIndex& basePalette, Vector<FontPaletteValues::OverriddenColor>&& overrideColor)
+    : StyleRuleBase(StyleRuleType::FontPaletteValues)
+    , m_name(name)
+    , m_fontFamily(fontFamily)
+    , m_fontPaletteValues(basePalette, WTFMove(overrideColor))
+{
+}
+
+StyleRuleFontPaletteValues::StyleRuleFontPaletteValues(const StyleRuleFontPaletteValues& o)
+    : StyleRuleBase(o)
+    , m_name(o.name())
+    , m_fontFamily(o.fontFamily())
+    , m_fontPaletteValues(o.m_fontPaletteValues)
+{
+}
+
+StyleRuleFontPaletteValues::~StyleRuleFontPaletteValues() = default;
+
 DeferredStyleGroupRuleList::DeferredStyleGroupRuleList(const CSSParserTokenRange& range, CSSDeferredParser& parser)
     : m_parser(parser)
 {

Modified: trunk/Source/WebCore/css/StyleRule.h (282805 => 282806)


--- trunk/Source/WebCore/css/StyleRule.h	2021-09-21 07:48:22 UTC (rev 282805)
+++ trunk/Source/WebCore/css/StyleRule.h	2021-09-21 08:24:36 UTC (rev 282806)
@@ -1,7 +1,7 @@
 /*
  * (C) 1999-2003 Lars Knoll ([email protected])
  * (C) 2002-2003 Dirk Mueller ([email protected])
- * Copyright (C) 2002-2020 Apple Inc. All rights reserved.
+ * Copyright (C) 2002-2021 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -23,6 +23,7 @@
 
 #include "CSSSelectorList.h"
 #include "CompiledSelector.h"
+#include "FontPaletteValues.h"
 #include "StyleProperties.h"
 #include "StyleRuleType.h"
 #include <wtf/RefPtr.h>
@@ -52,6 +53,7 @@
     bool isCharsetRule() const { return type() == StyleRuleType::Charset; }
     bool isCounterStyleRule() const { return type() == StyleRuleType::CounterStyle; }
     bool isFontFaceRule() const { return type() == StyleRuleType::FontFace; }
+    bool isFontPaletteValuesRule() const { return type() == StyleRuleType::FontPaletteValues; }
     bool isKeyframesRule() const { return type() == StyleRuleType::Keyframes; }
     bool isKeyframeRule() const { return type() == StyleRuleType::Keyframe; }
     bool isNamespaceRule() const { return type() == StyleRuleType::Namespace; }
@@ -155,6 +157,48 @@
     Ref<StyleProperties> m_properties;
 };
 
+class StyleRuleFontPaletteValues final : public StyleRuleBase {
+public:
+    static Ref<StyleRuleFontPaletteValues> create(const AtomString& name, const AtomString& fontFamily, const FontPaletteValues::PaletteIndex& basePalette, Vector<FontPaletteValues::OverriddenColor>&& overrideColor) { return adoptRef(*new StyleRuleFontPaletteValues(name, fontFamily, basePalette, WTFMove(overrideColor))); }
+    
+    ~StyleRuleFontPaletteValues();
+
+    const AtomString& name() const
+    {
+        return m_name;
+    }
+
+    const AtomString& fontFamily() const
+    {
+        return m_fontFamily;
+    }
+
+    const FontPaletteValues& fontPaletteValues() const
+    {
+        return m_fontPaletteValues;
+    }
+
+    const FontPaletteValues::PaletteIndex& basePalette() const
+    {
+        return m_fontPaletteValues.basePalette();
+    }
+
+    const Vector<FontPaletteValues::OverriddenColor>& overrideColor() const
+    {
+        return m_fontPaletteValues.overrideColor();
+    }
+
+    Ref<StyleRuleFontPaletteValues> copy() const { return adoptRef(*new StyleRuleFontPaletteValues(*this)); }
+
+private:
+    StyleRuleFontPaletteValues(const AtomString& name, const AtomString& fontFamily, const FontPaletteValues::PaletteIndex& basePalette, Vector<FontPaletteValues::OverriddenColor>&& overrideColor);
+    StyleRuleFontPaletteValues(const StyleRuleFontPaletteValues&);
+
+    AtomString m_name;
+    AtomString m_fontFamily;
+    FontPaletteValues m_fontPaletteValues;
+};
+
 class StyleRulePage final : public StyleRuleBase {
 public:
     static Ref<StyleRulePage> create(Ref<StyleProperties>&&, CSSSelectorList&&);
@@ -357,6 +401,10 @@
     static bool isType(const WebCore::StyleRuleBase& rule) { return rule.isFontFaceRule(); }
 SPECIALIZE_TYPE_TRAITS_END()
 
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::StyleRuleFontPaletteValues)
+    static bool isType(const WebCore::StyleRuleBase& rule) { return rule.isFontPaletteValuesRule(); }
+SPECIALIZE_TYPE_TRAITS_END()
+
 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::StyleRuleMedia)
     static bool isType(const WebCore::StyleRuleBase& rule) { return rule.isMediaRule(); }
 SPECIALIZE_TYPE_TRAITS_END()

Modified: trunk/Source/WebCore/css/StyleRuleType.h (282805 => 282806)


--- trunk/Source/WebCore/css/StyleRuleType.h	2021-09-21 07:48:22 UTC (rev 282805)
+++ trunk/Source/WebCore/css/StyleRuleType.h	2021-09-21 08:24:36 UTC (rev 282806)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2019-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -28,19 +28,21 @@
 namespace WebCore {
 
 enum class StyleRuleType : uint8_t {
-    Unknown, // Not used.
-    Style,
-    Charset, // Not used. These are internally strings owned by the style sheet.
-    Import,
-    Media,
-    FontFace,
-    Page,
-    Keyframes,
-    Keyframe, // Not used. These are internally non-rule StyleRuleKeyframe objects.
+    Unknown = 0, // Not used.
+    Style = 1,
+    Charset = 2, // Not used. These are internally strings owned by the style sheet.
+    Import = 3,
+    Media = 4,
+    FontFace = 5,
+    Page = 6,
+    Keyframes = 7,
+    Keyframe = 8, // Not used. These are internally non-rule StyleRuleKeyframe objects.
+    // Margin = 9, FIXME: Why is this missing?
     Namespace = 10,
     CounterStyle = 11,
     Supports = 12,
-    Layer = 13,
+    FontPaletteValues = 19, // https://github.com/w3c/csswg-drafts/issues/6623
+    Layer = 20
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/css/StyleSheetContents.cpp (282805 => 282806)


--- trunk/Source/WebCore/css/StyleSheetContents.cpp	2021-09-21 07:48:22 UTC (rev 282805)
+++ trunk/Source/WebCore/css/StyleSheetContents.cpp	2021-09-21 08:24:36 UTC (rev 282806)
@@ -1,6 +1,6 @@
 /*
  * (C) 1999-2003 Lars Knoll ([email protected])
- * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2021 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -436,6 +436,7 @@
             break;
         case StyleRuleType::Style:
         case StyleRuleType::FontFace:
+        case StyleRuleType::FontPaletteValues:
         case StyleRuleType::Page:
         case StyleRuleType::Keyframes:
         case StyleRuleType::Namespace:
@@ -486,6 +487,7 @@
         case StyleRuleType::Keyframe:
         case StyleRuleType::Supports:
         case StyleRuleType::Layer:
+        case StyleRuleType::FontPaletteValues:
             return false;
         };
         ASSERT_NOT_REACHED();

Modified: trunk/Source/WebCore/css/parser/CSSAtRuleID.cpp (282805 => 282806)


--- trunk/Source/WebCore/css/parser/CSSAtRuleID.cpp	2021-09-21 07:48:22 UTC (rev 282805)
+++ trunk/Source/WebCore/css/parser/CSSAtRuleID.cpp	2021-09-21 08:24:36 UTC (rev 282806)
@@ -1,5 +1,5 @@
 // Copyright 2015 The Chromium Authors. All rights reserved.
-// Copyright (C) 2016 Apple Inc. All rights reserved.
+// Copyright (C) 2016-2021 Apple Inc. All rights reserved.
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
@@ -38,6 +38,8 @@
         return CSSAtRuleCharset;
     if (equalIgnoringASCIICase(name, "font-face"))
         return CSSAtRuleFontFace;
+    if (equalIgnoringASCIICase(name, "font-palette-values"))
+        return CSSAtRuleFontPaletteValues;
     if (equalIgnoringASCIICase(name, "import"))
         return CSSAtRuleImport;
     if (equalIgnoringASCIICase(name, "keyframes"))

Modified: trunk/Source/WebCore/css/parser/CSSAtRuleID.h (282805 => 282806)


--- trunk/Source/WebCore/css/parser/CSSAtRuleID.h	2021-09-21 07:48:22 UTC (rev 282805)
+++ trunk/Source/WebCore/css/parser/CSSAtRuleID.h	2021-09-21 08:24:36 UTC (rev 282806)
@@ -1,5 +1,5 @@
 // Copyright 2015 The Chromium Authors. All rights reserved.
-// Copyright (C) 2016 Apple Inc. All rights reserved.
+// Copyright (C) 2016-2021 Apple Inc. All rights reserved.
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
@@ -49,6 +49,8 @@
     CSSAtRuleApply = 11,
     CSSAtRuleCounterStyle = 12,
     CSSAtRuleLayer = 13,
+
+    CSSAtRuleFontPaletteValues = 14,
 };
 
 CSSAtRuleID cssAtRuleID(StringView name);

Modified: trunk/Source/WebCore/css/parser/CSSParserImpl.cpp (282805 => 282806)


--- trunk/Source/WebCore/css/parser/CSSParserImpl.cpp	2021-09-21 07:48:22 UTC (rev 282805)
+++ trunk/Source/WebCore/css/parser/CSSParserImpl.cpp	2021-09-21 08:24:36 UTC (rev 282806)
@@ -1,5 +1,5 @@
 // Copyright 2014 The Chromium Authors. All rights reserved.
-// Copyright (C) 2016-2020 Apple Inc. All rights reserved.
+// Copyright (C) 2016-2021 Apple Inc. All rights reserved.
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
@@ -34,6 +34,7 @@
 #include "CSSCounterStyleRule.h"
 #include "CSSCustomPropertyValue.h"
 #include "CSSDeferredParser.h"
+#include "CSSFontPaletteValuesOverrideColorValue.h"
 #include "CSSKeyframeRule.h"
 #include "CSSKeyframesRule.h"
 #include "CSSParserObserver.h"
@@ -47,6 +48,7 @@
 #include "CSSVariableParser.h"
 #include "Document.h"
 #include "Element.h"
+#include "FontPaletteValues.h"
 #include "MediaList.h"
 #include "MediaQueryParser.h"
 #include "MediaQueryParserContext.h"
@@ -445,6 +447,8 @@
         return consumeSupportsRule(prelude, block);
     case CSSAtRuleFontFace:
         return consumeFontFaceRule(prelude, block);
+    case CSSAtRuleFontPaletteValues:
+        return consumeFontPaletteValuesRule(prelude, block);
     case CSSAtRuleWebkitKeyframes:
         return consumeKeyframesRule(true, prelude, block);
     case CSSAtRuleKeyframes:
@@ -652,6 +656,55 @@
     return StyleRuleFontFace::create(createStyleProperties(m_parsedProperties, m_context.mode));
 }
 
+RefPtr<StyleRuleFontPaletteValues> CSSParserImpl::consumeFontPaletteValuesRule(CSSParserTokenRange prelude, CSSParserTokenRange block)
+{
+    auto name = CSSPropertyParserHelpers::consumeCustomIdent(prelude);
+    if (!name || !prelude.atEnd())
+        return nullptr; // Parse error; expected custom ident in @font-palette-values header
+
+    if (m_observerWrapper) {
+        unsigned endOffset = m_observerWrapper->endOffset(prelude);
+        m_observerWrapper->observer().startRuleHeader(StyleRuleType::FontPaletteValues, m_observerWrapper->startOffset(prelude));
+        m_observerWrapper->observer().endRuleHeader(endOffset);
+        m_observerWrapper->observer().startRuleBody(endOffset);
+        m_observerWrapper->observer().endRuleBody(endOffset);
+    }
+
+    consumeDeclarationList(block, StyleRuleType::FontPaletteValues);
+    auto properties = createStyleProperties(m_parsedProperties, m_context.mode);
+
+    AtomString fontFamily;
+    if (auto fontFamilyValue = properties->getPropertyCSSValue(CSSPropertyFontFamily))
+        fontFamily = downcast<CSSPrimitiveValue>(*fontFamilyValue).fontFamily().familyName;
+
+    FontPaletteValues::PaletteIndex basePalette(nullAtom());
+    if (auto basePaletteValue = properties->getPropertyCSSValue(CSSPropertyBasePalette)) {
+        const auto& primitiveValue = downcast<CSSPrimitiveValue>(*basePaletteValue);
+        if (primitiveValue.isString())
+            basePalette = primitiveValue.stringValue();
+        else if (primitiveValue.isNumber())
+            basePalette = primitiveValue.value<int64_t>();
+    }
+
+    Vector<FontPaletteValues::OverriddenColor> overrideColor;
+    if (auto overrideColorValue = properties->getPropertyCSSValue(CSSPropertyOverrideColor)) {
+        const auto& list = downcast<CSSValueList>(*overrideColorValue);
+        for (const auto& item : list) {
+            FontPaletteValues::PaletteColorIndex key(nullAtom());
+            const auto& pair = downcast<CSSFontPaletteValuesOverrideColorValue>(item.get());
+            if (pair.key().isString())
+                key = pair.key().stringValue();
+            else if (pair.key().isNumber())
+                key = pair.key().value<int64_t>();
+            else
+                continue;
+            overrideColor.append(std::make_pair(key, pair.color().color()));
+        }
+    }
+
+    return StyleRuleFontPaletteValues::create(name->stringValue(), fontFamily, basePalette, WTFMove(overrideColor));
+}
+
 RefPtr<StyleRuleKeyframes> CSSParserImpl::consumeKeyframesRule(bool webkitPrefixed, CSSParserTokenRange prelude, CSSParserTokenRange block)
 {
     CSSParserTokenRange rangeCopy = prelude; // For inspector callbacks
@@ -961,7 +1014,7 @@
         consumeCustomPropertyValue(range.makeSubRange(&range.peek(), declarationValueEnd), variableName, important);
     }
 
-    if (important && (ruleType == StyleRuleType::FontFace || ruleType == StyleRuleType::Keyframe || ruleType == StyleRuleType::CounterStyle))
+    if (important && (ruleType == StyleRuleType::FontFace || ruleType == StyleRuleType::Keyframe || ruleType == StyleRuleType::CounterStyle || ruleType == StyleRuleType::FontPaletteValues))
         return;
 
     if (propertyID != CSSPropertyInvalid)

Modified: trunk/Source/WebCore/css/parser/CSSParserImpl.h (282805 => 282806)


--- trunk/Source/WebCore/css/parser/CSSParserImpl.h	2021-09-21 07:48:22 UTC (rev 282805)
+++ trunk/Source/WebCore/css/parser/CSSParserImpl.h	2021-09-21 08:24:36 UTC (rev 282806)
@@ -1,5 +1,5 @@
 // Copyright 2014 The Chromium Authors. All rights reserved.
-// Copyright (C) 2016-2020 Apple Inc. All rights reserved.
+// Copyright (C) 2016-2021 Apple Inc. All rights reserved.
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
@@ -51,6 +51,7 @@
 class StyleRuleBase;
 class StyleRuleCharset;
 class StyleRuleFontFace;
+class StyleRuleFontPaletteValues;
 class StyleRuleImport;
 class StyleRuleKeyframes;
 class StyleRuleLayer;
@@ -133,6 +134,7 @@
     RefPtr<StyleRuleSupports> consumeSupportsRule(CSSParserTokenRange prelude, CSSParserTokenRange block);
     RefPtr<StyleRuleViewport> consumeViewportRule(CSSParserTokenRange prelude, CSSParserTokenRange block);
     RefPtr<StyleRuleFontFace> consumeFontFaceRule(CSSParserTokenRange prelude, CSSParserTokenRange block);
+    RefPtr<StyleRuleFontPaletteValues> consumeFontPaletteValuesRule(CSSParserTokenRange prelude, CSSParserTokenRange block);
     RefPtr<StyleRuleKeyframes> consumeKeyframesRule(bool webkitPrefixed, CSSParserTokenRange prelude, CSSParserTokenRange block);
     RefPtr<StyleRulePage> consumePageRule(CSSParserTokenRange prelude, CSSParserTokenRange block);
     RefPtr<StyleRuleCounterStyle> consumeCounterStyleRule(CSSParserTokenRange prelude, CSSParserTokenRange block);

Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (282805 => 282806)


--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2021-09-21 07:48:22 UTC (rev 282805)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2021-09-21 08:24:36 UTC (rev 282806)
@@ -38,6 +38,7 @@
 #include "CSSCustomPropertyValue.h"
 #include "CSSFontFaceSrcValue.h"
 #include "CSSFontFeatureValue.h"
+#include "CSSFontPaletteValuesOverrideColorValue.h"
 #if ENABLE(VARIATION_FONTS)
 #include "CSSFontVariationValue.h"
 #endif
@@ -233,6 +234,8 @@
 
     if (ruleType == StyleRuleType::FontFace)
         parseSuccess = parser.parseFontFaceDescriptor(propertyID);
+    else if (ruleType == StyleRuleType::FontPaletteValues)
+        parseSuccess = parser.parseFontPaletteValuesDescriptor(propertyID);
     else if (ruleType == StyleRuleType::CounterStyle)
         parseSuccess = parser.parseCounterStyleDescriptor(propertyID, context);
     else
@@ -4834,6 +4837,63 @@
     return true;
 }
 
+static RefPtr<CSSPrimitiveValue> consumeBasePaletteDescriptor(CSSParserTokenRange& range)
+{
+    if (range.peek().type() == StringToken)
+        return consumeString(range);
+    return consumeInteger(range);
+}
+
+static RefPtr<CSSValueList> consumeOverrideColorDescriptor(CSSParserTokenRange& range, const CSSParserContext& context)
+{
+    RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
+    do {
+        RefPtr<CSSPrimitiveValue> key;
+        if (range.peek().type() == StringToken)
+            key = consumeString(range);
+        else
+            key = consumeInteger(range);
+        if (!key)
+            return nullptr;
+
+        auto color = consumeColor(range, context);
+        if (!color)
+            return nullptr;
+
+        RefPtr<CSSValue> value = CSSFontPaletteValuesOverrideColorValue::create(key.releaseNonNull(), color.releaseNonNull());
+        list->append(value.releaseNonNull());
+    } while (consumeCommaIncludingWhitespace(range));
+    
+    if (!range.atEnd() || !list->length())
+        return nullptr;
+
+    return list;
+}
+
+bool CSSPropertyParser::parseFontPaletteValuesDescriptor(CSSPropertyID propId)
+{
+    RefPtr<CSSValue> parsedValue;
+    switch (propId) {
+    case CSSPropertyFontFamily:
+        parsedValue = consumeFamilyName(m_range);
+        break;
+    case CSSPropertyBasePalette:
+        parsedValue = consumeBasePaletteDescriptor(m_range);
+        break;
+    case CSSPropertyOverrideColor:
+        parsedValue = consumeOverrideColorDescriptor(m_range, m_context);
+        break;
+    default:
+        break;
+    }
+
+    if (!parsedValue || !m_range.atEnd())
+        return false;
+
+    addProperty(propId, CSSPropertyInvalid, *parsedValue, false);
+    return true;
+}
+
 bool CSSPropertyParser::consumeSystemFont(bool important)
 {
     CSSValueID systemFontID = m_range.consumeIncludingWhitespace().id();

Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.h (282805 => 282806)


--- trunk/Source/WebCore/css/parser/CSSPropertyParser.h	2021-09-21 07:48:22 UTC (rev 282805)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.h	2021-09-21 08:24:36 UTC (rev 282806)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2003 Lars Knoll ([email protected])
- * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2004 - 2021 Apple Inc. All rights reserved.
  * Copyright (C) 2008 Eric Seidel <[email protected]>
  * Copyright (C) 2009 - 2010  Torch Mobile (Beijing) Co. Ltd. All rights reserved.
  *
@@ -73,6 +73,7 @@
 
     bool parseViewportDescriptor(CSSPropertyID propId, bool important);
     bool parseFontFaceDescriptor(CSSPropertyID);
+    bool parseFontPaletteValuesDescriptor(CSSPropertyID);
     bool parseCounterStyleDescriptor(CSSPropertyID, const CSSParserContext&);
 
     void addProperty(CSSPropertyID, CSSPropertyID, Ref<CSSValue>&&, bool important, bool implicit = false);

Added: trunk/Source/WebCore/platform/graphics/FontPaletteValues.h (0 => 282806)


--- trunk/Source/WebCore/platform/graphics/FontPaletteValues.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/FontPaletteValues.h	2021-09-21 08:24:36 UTC (rev 282806)
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "Color.h"
+#include <wtf/Variant.h>
+#include <wtf/Vector.h>
+#include <wtf/text/AtomString.h>
+
+namespace WebCore {
+
+class FontPaletteValues {
+public:
+    using PaletteIndex = Variant<int64_t, AtomString>;
+    using PaletteColorIndex = Variant<AtomString, int64_t>;
+    using OverriddenColor = std::pair<PaletteColorIndex, Color>;
+
+    FontPaletteValues() = default;
+
+    FontPaletteValues(const PaletteIndex& basePalette, Vector<OverriddenColor>&& overrideColor)
+        : m_basePalette(basePalette)
+        , m_overrideColor(WTFMove(overrideColor))
+    {
+    }
+
+    const PaletteIndex& basePalette() const
+    {
+        return m_basePalette;
+    }
+
+    void setBasePalette(const PaletteIndex& basePalette)
+    {
+        m_basePalette = basePalette;
+    }
+
+    const Vector<OverriddenColor>& overrideColor() const
+    {
+        return m_overrideColor;
+    }
+
+    void appendOverrideColor(OverriddenColor&& overriddenColor)
+    {
+        m_overrideColor.append(overriddenColor);
+    }
+
+    void clearOverrideColor()
+    {
+        m_overrideColor.clear();
+    }
+
+    bool remove(unsigned key)
+    {
+        return m_overrideColor.removeAllMatching([key](const OverriddenColor& overriddenColor) -> bool {
+            return WTF::holds_alternative<int64_t>(overriddenColor.first) && WTF::get<int64_t>(overriddenColor.first) == key;
+        });
+    }
+
+private:
+    PaletteIndex m_basePalette;
+    Vector<OverriddenColor> m_overrideColor;
+};
+
+}
Property changes on: trunk/Source/WebCore/platform/graphics/FontPaletteValues.h
___________________________________________________________________

Added: svn:eol-style

+native \ No newline at end of property

Added: svn:keywords

+Author Date Id Rev URL \ No newline at end of property
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to