Changeset 282806 in webkit


Ignore:
Timestamp:
Sep 21, 2021 1:24:36 AM (10 months ago)
Author:
mmaxfield@apple.com
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):

Location:
trunk
Files:
7 added
28 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r282804 r282806  
     12021-09-21  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        Parsing support for font-palette-values
     4        https://bugs.webkit.org/show_bug.cgi?id=230337
     5
     6        Reviewed by Antti Koivisto.
     7
     8        These are being upstreamed at https://github.com/web-platform-tests/wpt/pull/30840.
     9
     10        * web-platform-tests/css/css-fonts/idlharness-expected.txt:
     11        * web-platform-tests/css/css-fonts/parsing/font-palette-values-invalid-expected.txt: Added.
     12        * web-platform-tests/css/css-fonts/parsing/font-palette-values-invalid.html: Added.
     13        * web-platform-tests/css/css-fonts/parsing/font-palette-values-valid-expected.txt: Added.
     14        * web-platform-tests/css/css-fonts/parsing/font-palette-values-valid.html: Added.
     15
    1162021-09-21  Ziran Sun  <zsun@igalia.com>
    217
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/idlharness-expected.txt

    r267650 r282806  
    1717PASS CSSFontFaceRule interface: cssFontFaceRule must inherit property "style" with the proper type
    1818FAIL 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
    19 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
     19FAIL CSSRule interface: cssFontFaceRule must inherit property "FONT_PALETTE_VALUES_RULE" with the proper type assert_equals: expected 15 but got 19
    2020FAIL CSSFontFeatureValuesRule interface: existence and properties of interface object assert_own_property: self does not have own property "CSSFontFeatureValuesRule" expected property "CSSFontFeatureValuesRule" missing
    2121FAIL CSSFontFeatureValuesRule interface object length assert_own_property: self does not have own property "CSSFontFeatureValuesRule" expected property "CSSFontFeatureValuesRule" missing
     
    3838FAIL 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
    3939FAIL 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
    40 FAIL CSSFontPaletteValuesRule interface: existence and properties of interface object assert_own_property: self does not have own property "CSSFontPaletteValuesRule" expected property "CSSFontPaletteValuesRule" missing
    41 FAIL CSSFontPaletteValuesRule interface object length assert_own_property: self does not have own property "CSSFontPaletteValuesRule" expected property "CSSFontPaletteValuesRule" missing
    42 FAIL CSSFontPaletteValuesRule interface object name assert_own_property: self does not have own property "CSSFontPaletteValuesRule" expected property "CSSFontPaletteValuesRule" missing
    43 FAIL CSSFontPaletteValuesRule interface: existence and properties of interface prototype object assert_own_property: self does not have own property "CSSFontPaletteValuesRule" expected property "CSSFontPaletteValuesRule" missing
    44 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
    45 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
    46 FAIL CSSFontPaletteValuesRule interface: attribute fontFamily assert_own_property: self does not have own property "CSSFontPaletteValuesRule" expected property "CSSFontPaletteValuesRule" missing
    47 FAIL CSSFontPaletteValuesRule interface: attribute basePalette assert_own_property: self does not have own property "CSSFontPaletteValuesRule" expected property "CSSFontPaletteValuesRule" missing
     40PASS CSSFontPaletteValuesRule interface: existence and properties of interface object
     41PASS CSSFontPaletteValuesRule interface object length
     42PASS CSSFontPaletteValuesRule interface object name
     43PASS CSSFontPaletteValuesRule interface: existence and properties of interface prototype object
     44PASS CSSFontPaletteValuesRule interface: existence and properties of interface prototype object's "constructor" property
     45PASS CSSFontPaletteValuesRule interface: existence and properties of interface prototype object's @@unscopables property
     46FAIL CSSFontPaletteValuesRule interface: attribute fontFamily assert_equals: setter must be function for PutForwards, Replaceable, or non-readonly attributes expected "function" but got "undefined"
     47FAIL CSSFontPaletteValuesRule interface: attribute basePalette assert_equals: setter must be function for PutForwards, Replaceable, or non-readonly attributes expected "function" but got "undefined"
    4848FAIL CSSRule interface: constant FONT_FEATURE_VALUES_RULE on interface object assert_own_property: expected property "FONT_FEATURE_VALUES_RULE" missing
    4949FAIL CSSRule interface: constant FONT_FEATURE_VALUES_RULE on interface prototype object assert_own_property: expected property "FONT_FEATURE_VALUES_RULE" missing
    50 FAIL CSSRule interface: constant FONT_PALETTE_VALUES_RULE on interface object assert_own_property: expected property "FONT_PALETTE_VALUES_RULE" missing
    51 FAIL CSSRule interface: constant FONT_PALETTE_VALUES_RULE on interface prototype object assert_own_property: expected property "FONT_PALETTE_VALUES_RULE" missing
     50FAIL CSSRule interface: constant FONT_PALETTE_VALUES_RULE on interface object assert_equals: property has wrong value expected 15 but got 19
     51FAIL CSSRule interface: constant FONT_PALETTE_VALUES_RULE on interface prototype object assert_equals: property has wrong value expected 15 but got 19
    5252FAIL 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
    53 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
     53FAIL CSSRule interface: cssRule must inherit property "FONT_PALETTE_VALUES_RULE" with the proper type assert_equals: expected 15 but got 19
    5454
  • trunk/Source/WebCore/CMakeLists.txt

    r282702 r282806  
    706706    css/CSSCounterStyleRule.idl
    707707    css/CSSFontFaceRule.idl
     708    css/CSSFontPaletteValuesRule.idl
    708709    css/CSSGroupingRule.idl
    709710    css/CSSImportRule.idl
  • trunk/Source/WebCore/ChangeLog

    r282805 r282806  
     12021-09-21  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        Parsing support for font-palette-values
     4        https://bugs.webkit.org/show_bug.cgi?id=230337
     5
     6        Reviewed by Antti Koivisto.
     7
     8        There's nothing particularly interesting here - it's just support for another at-rule.
     9        I've implemented what's in the spec right now:
     10        https://drafts.csswg.org/css-fonts-4/#font-palette-values
     11
     12        There are 2 new descriptors: base-palette and override-color. I've added a new CSSValue subclass
     13        for each of the items in the override-color list - these items are just tuples of two
     14        CSSPrimitiveValues. I could have done this with a CSSValueList which always just happens to have
     15        a length of 2, but I thought that was less elegant (and has an extra pointer indirection) than
     16        making a class to hold the two CSSPrimitiveValues.
     17
     18        The only difference with what's in the spec is that I've given a different value to
     19        FONT_PALETTE_VALUES_RULE, because its current value conflicts with VIEWPORT_RULE. This is being
     20        tracked at https://github.com/w3c/csswg-drafts/issues/6623.
     21
     22        I created a new datatype and file in platform/graphics/FontPaletteValues.h because this data will
     23        eventually be passed to preparePlatformFont(), which is in platform/, so this data needs to be
     24        accessible from platform/ too.
     25
     26        Tests: imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-invalid.html
     27               imported/w3c/web-platform-tests/css/css-fonts/parsing/font-palette-values-valid.html
     28
     29        * CMakeLists.txt:
     30        * DerivedSources-input.xcfilelist:
     31        * DerivedSources-output.xcfilelist:
     32        * DerivedSources.make:
     33        * Headers.cmake:
     34        * Sources.txt:
     35        * WebCore.xcodeproj/project.pbxproj:
     36        * bindings/js/JSCSSRuleCustom.cpp:
     37        (WebCore::toJSNewlyCreated):
     38        * css/CSSComputedStyleDeclaration.cpp:
     39        (WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
     40        * css/CSSFontPaletteValuesOverrideColorValue.cpp: Copied from Source/WebCore/css/StyleRuleType.h.
     41        (WebCore::CSSFontPaletteValuesOverrideColorValue::customCSSText const):
     42        (WebCore::CSSFontPaletteValuesOverrideColorValue::equals const):
     43        * css/CSSFontPaletteValuesOverrideColorValue.h: Copied from Source/WebCore/css/StyleRuleType.h.
     44        * css/CSSFontPaletteValuesRule.cpp: Added.
     45        (WebCore::CSSFontPaletteValuesRule::CSSFontPaletteValuesRule):
     46        (WebCore::CSSFontPaletteValuesRule::~CSSFontPaletteValuesRule):
     47        (WebCore::parseString):
     48        (WebCore::CSSFontPaletteValuesRule::fontFamily const):
     49        (WebCore::CSSFontPaletteValuesRule::basePalette const):
     50        (WebCore::CSSFontPaletteValuesRule::setFontFamily):
     51        (WebCore::CSSFontPaletteValuesRule::setBasePalette):
     52        (WebCore::CSSFontPaletteValuesRule::initializeMapLike):
     53        (WebCore::CSSFontPaletteValuesRule::setFromMapLike):
     54        (WebCore::CSSFontPaletteValuesRule::clear):
     55        (WebCore::CSSFontPaletteValuesRule::remove):
     56        (WebCore::CSSFontPaletteValuesRule::cssText const):
     57        (WebCore::CSSFontPaletteValuesRule::reattach):
     58        * css/CSSFontPaletteValuesRule.h: Copied from Source/WebCore/css/StyleRuleType.h.
     59        * css/CSSFontPaletteValuesRule.idl: Added.
     60        * css/CSSProperties.json:
     61        * css/CSSRule.cpp:
     62        * css/CSSRule.h:
     63        * css/CSSRule.idl:
     64        * css/CSSValue.cpp:
     65        (WebCore::CSSValue::equals const):
     66        (WebCore::CSSValue::cssText const):
     67        (WebCore::CSSValue::destroy):
     68        * css/CSSValue.h:
     69        (WebCore::CSSValue::isFontPaletteValuesOverrideColorValue const):
     70        * css/StyleRule.cpp:
     71        (WebCore::StyleRuleBase::destroy):
     72        (WebCore::StyleRuleBase::copy const):
     73        (WebCore::StyleRuleBase::createCSSOMWrapper const):
     74        (WebCore::StyleRuleFontPaletteValues::StyleRuleFontPaletteValues):
     75        * css/StyleRule.h:
     76        (WebCore::StyleRuleBase::isFontPaletteValuesRule const):
     77        (isType):
     78        * css/StyleRuleType.h:
     79        * css/StyleSheetContents.cpp:
     80        (WebCore::traverseRulesInVector):
     81        (WebCore::StyleSheetContents::traverseSubresources const):
     82        * css/parser/CSSAtRuleID.cpp:
     83        (WebCore::cssAtRuleID):
     84        * css/parser/CSSAtRuleID.h:
     85        * css/parser/CSSParserImpl.cpp:
     86        (WebCore::CSSParserImpl::consumeAtRule):
     87        (WebCore::CSSParserImpl::consumeFontPaletteValuesRule):
     88        (WebCore::CSSParserImpl::consumeDeclaration):
     89        * css/parser/CSSParserImpl.h:
     90        * css/parser/CSSPropertyParser.cpp:
     91        (WebCore::CSSPropertyParser::parseValue):
     92        (WebCore::consumeBasePaletteDescriptor):
     93        (WebCore::consumeOverrideColorDescriptor):
     94        (WebCore::CSSPropertyParser::parseFontPaletteValuesDescriptor):
     95        * css/parser/CSSPropertyParser.h:
     96        * platform/graphics/FontPaletteValues.h: Added.
     97        (WebCore::FontPaletteValues::FontPaletteValues):
     98        (WebCore::FontPaletteValues::basePalette const):
     99        (WebCore::FontPaletteValues::setBasePalette):
     100        (WebCore::FontPaletteValues::overrideColor const):
     101        (WebCore::FontPaletteValues::appendOverrideColor):
     102        (WebCore::FontPaletteValues::clearOverrideColor):
     103        (WebCore::FontPaletteValues::remove):
     104
    11052021-09-21  Myles C. Maxfield  <mmaxfield@apple.com>
    2106
  • trunk/Source/WebCore/DerivedSources-input.xcfilelist

    r282702 r282806  
    683683$(PROJECT_DIR)/css/CSSCounterStyleRule.idl
    684684$(PROJECT_DIR)/css/CSSFontFaceRule.idl
     685$(PROJECT_DIR)/css/CSSFontPaletteValuesRule.idl
    685686$(PROJECT_DIR)/css/CSSGroupingRule.idl
    686687$(PROJECT_DIR)/css/CSSImportRule.idl
  • trunk/Source/WebCore/DerivedSources-output.xcfilelist

    r282710 r282806  
    301301$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSFontFaceRule.cpp
    302302$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSFontFaceRule.h
     303$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSFontPaletteValuesRule.cpp
     304$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSFontPaletteValuesRule.h
    303305$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSGroupingRule.cpp
    304306$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSGroupingRule.h
  • trunk/Source/WebCore/DerivedSources.make

    r282702 r282806  
    1 # Copyright (C) 2006-2020 Apple Inc. All rights reserved.
     1# Copyright (C) 2006-2021 Apple Inc. All rights reserved.
    22# Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
    33# Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
     
    576576    $(WebCore)/css/CSSCounterStyleRule.idl \
    577577    $(WebCore)/css/CSSFontFaceRule.idl \
     578    $(WebCore)/css/CSSFontPaletteValuesRule.idl \
    578579    $(WebCore)/css/CSSGroupingRule.idl \
    579580    $(WebCore)/css/CSSImportRule.idl \
  • trunk/Source/WebCore/Headers.cmake

    r282798 r282806  
    367367    css/CSSCustomPropertyValue.h
    368368    css/CSSFontFaceRule.h
     369    css/CSSFontPaletteValuesRule.h
    369370    css/CSSFontFamily.h
    370371    css/CSSGridIntegerRepeatValue.h
     
    12601261    platform/graphics/FontGenericFamilies.h
    12611262    platform/graphics/FontMetrics.h
     1263    platform/graphics/FontPaletteValues.h
    12621264    platform/graphics/FontPlatformData.h
    12631265    platform/graphics/FontRanges.h
  • trunk/Source/WebCore/Sources.txt

    r282798 r282806  
    1 // Copyright (C) 2017-2020 Apple Inc. All rights reserved.
     1// Copyright (C) 2017-2021 Apple Inc. All rights reserved.
    22//
    33// Redistribution and use in source and binary forms, with or without
     
    659659css/CSSFontFaceSrcValue.cpp
    660660css/CSSFontFeatureValue.cpp
     661css/CSSFontPaletteValuesOverrideColorValue.cpp
     662css/CSSFontPaletteValuesRule.cpp
    661663css/CSSFontSelector.cpp
    662664css/CSSFontStyleRangeValue.cpp
     
    28252827JSCSSCounterStyleRule.cpp
    28262828JSCSSFontFaceRule.cpp
     2829JSCSSFontPaletteValuesRule.cpp
    28272830JSCSSGroupingRule.cpp
    28282831JSCSSImportRule.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r282798 r282806  
    654654                1C43DE6B22AB4B8A001527D9 /* LocalCurrentTraitCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C43DE6822AB4B8A001527D9 /* LocalCurrentTraitCollection.h */; settings = {ATTRIBUTES = (Private, ); }; };
    655655                1C4D0DD324D9F10D003D7498 /* GlyphBufferMembers.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C4D0DD124D9F0DB003D7498 /* GlyphBufferMembers.h */; settings = {ATTRIBUTES = (Private, ); }; };
     656                1C5E1DA826F94B9000E07AF1 /* FontPaletteValues.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C5E1DA626F949B900E07AF1 /* FontPaletteValues.h */; };
    656657                1C6626111C6E7CA600AB527C /* FontFace.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C66260F1C6E7CA600AB527C /* FontFace.h */; };
    657658                1C73A7132185757E004CCEA5 /* TextUnderlineOffset.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CB6B4FB217B83940093B9CD /* TextUnderlineOffset.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    668669                1CE8D12726185C0E00FC3AEF /* DisplayListItemBufferIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CE8D12526185BD800FC3AEF /* DisplayListItemBufferIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
    669670                1CE8D12E261861C400FC3AEF /* DisplayListIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CE8D12C2618616400FC3AEF /* DisplayListIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
     671                1CEAA53226F336FC00868507 /* CSSFontPaletteValuesOverrideColorValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CEAA53126F331C100868507 /* CSSFontPaletteValuesOverrideColorValue.h */; };
    670672                1CFAE3230A6D6A3F0032593D /* libobjc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1CFAE3220A6D6A3F0032593D /* libobjc.dylib */; };
    671673                1D0026A42374D62400CA6CDF /* JSPictureInPictureWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 1D0026A22374D62300CA6CDF /* JSPictureInPictureWindow.h */; };
     
    70527054                1C4D0DD124D9F0DB003D7498 /* GlyphBufferMembers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GlyphBufferMembers.h; sourceTree = "<group>"; };
    70537055                1C50C49522C84F2400A6E4BE /* WHLSLStandardLibraryFunctionMap.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLStandardLibraryFunctionMap.cpp; sourceTree = "<group>"; };
     7056                1C5E1DA626F949B900E07AF1 /* FontPaletteValues.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontPaletteValues.h; sourceTree = "<group>"; };
    70547057                1C66260E1C6E7CA600AB527C /* FontFace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontFace.cpp; sourceTree = "<group>"; };
    70557058                1C66260F1C6E7CA600AB527C /* FontFace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontFace.h; sourceTree = "<group>"; };
     
    70847087                1CE8D12B2618616400FC3AEF /* DisplayListIterator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayListIterator.cpp; sourceTree = "<group>"; };
    70857088                1CE8D12C2618616400FC3AEF /* DisplayListIterator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayListIterator.h; sourceTree = "<group>"; };
     7089                1CEAA52C26F31A3C00868507 /* CSSFontPaletteValuesRule.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CSSFontPaletteValuesRule.cpp; sourceTree = "<group>"; };
     7090                1CEAA52D26F31A3C00868507 /* CSSFontPaletteValuesRule.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSSFontPaletteValuesRule.h; sourceTree = "<group>"; };
     7091                1CEAA52F26F31AF800868507 /* CSSFontPaletteValuesRule.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = CSSFontPaletteValuesRule.idl; sourceTree = "<group>"; };
     7092                1CEAA53026F331C100868507 /* CSSFontPaletteValuesOverrideColorValue.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CSSFontPaletteValuesOverrideColorValue.cpp; sourceTree = "<group>"; };
     7093                1CEAA53126F331C100868507 /* CSSFontPaletteValuesOverrideColorValue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSSFontPaletteValuesOverrideColorValue.h; sourceTree = "<group>"; };
    70867094                1CF0BFD42298706800ED2074 /* TextSizeAdjustment.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TextSizeAdjustment.cpp; sourceTree = "<group>"; };
    70877095                1CF18F3C26BB5AF2004B1722 /* LogInitialization.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LogInitialization.cpp; sourceTree = "<group>"; };
     
    2701127019                                E44EE3A717576E5500EEE8CF /* FontGenericFamilies.h */,
    2701227020                                0845680712B90DA600960A9F /* FontMetrics.h */,
     27021                                1C5E1DA626F949B900E07AF1 /* FontPaletteValues.h */,
    2701327022                                84B62684133138F90095A489 /* FontPlatformData.cpp */,
    2701427023                                B5320D69122A24E9002D1440 /* FontPlatformData.h */,
     
    2959429603                                4A6E9FC113C17D1D0046A7F8 /* CSSFontFeatureValue.cpp */,
    2959529604                                4A6E9FC213C17D1D0046A7F8 /* CSSFontFeatureValue.h */,
     29605                                1CEAA53026F331C100868507 /* CSSFontPaletteValuesOverrideColorValue.cpp */,
     29606                                1CEAA53126F331C100868507 /* CSSFontPaletteValuesOverrideColorValue.h */,
     29607                                1CEAA52C26F31A3C00868507 /* CSSFontPaletteValuesRule.cpp */,
     29608                                1CEAA52D26F31A3C00868507 /* CSSFontPaletteValuesRule.h */,
     29609                                1CEAA52F26F31AF800868507 /* CSSFontPaletteValuesRule.idl */,
    2959629610                                BC64B4D30CB4298A005F2B62 /* CSSFontSelector.cpp */,
    2959729611                                BC64B4D40CB4298A005F2B62 /* CSSFontSelector.h */,
     
    3196831982                                83520C7E1A71BFCC006BD2AA /* CSSFontFamily.h in Headers */,
    3196931983                                4A6E9FC413C17D1D0046A7F8 /* CSSFontFeatureValue.h in Headers */,
     31984                                1CEAA53226F336FC00868507 /* CSSFontPaletteValuesOverrideColorValue.h in Headers */,
    3197031985                                BC64B4DC0CB4298A005F2B62 /* CSSFontSelector.h in Headers */,
    3197131986                                C2E38F021E84573500CA3ADF /* CSSFontStyleRangeValue.h in Headers */,
     
    3250532520                                BC4A532F256057CD0028C592 /* FontLoadTimingOverride.h in Headers */,
    3250632521                                0845680812B90DA600960A9F /* FontMetrics.h in Headers */,
     32522                                1C5E1DA826F94B9000E07AF1 /* FontPaletteValues.h in Headers */,
    3250732523                                B5320D6B122A24E9002D1440 /* FontPlatformData.h in Headers */,
    3250832524                                371F4FFC0D25E7F300ECE0D5 /* FontRanges.h in Headers */,
  • trunk/Source/WebCore/bindings/js/JSCSSRuleCustom.cpp

    r276152 r282806  
    2929#include "CSSCounterStyleRule.h"
    3030#include "CSSFontFaceRule.h"
     31#include "CSSFontPaletteValuesRule.h"
    3132#include "CSSImportRule.h"
    3233#include "CSSKeyframeRule.h"
     
    3940#include "JSCSSCounterStyleRule.h"
    4041#include "JSCSSFontFaceRule.h"
     42#include "JSCSSFontPaletteValuesRule.h"
    4143#include "JSCSSImportRule.h"
    4244#include "JSCSSKeyframeRule.h"
     
    7173    case CSSRule::FONT_FACE_RULE:
    7274        return createWrapper<CSSFontFaceRule>(globalObject, WTFMove(rule));
     75    case CSSRule::FONT_PALETTE_VALUES_RULE:
     76        return createWrapper<CSSFontPaletteValuesRule>(globalObject, WTFMove(rule));
    7377    case CSSRule::PAGE_RULE:
    7478        return createWrapper<CSSPageRule>(globalObject, WTFMove(rule));
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r282768 r282806  
    11/*
    22 * Copyright (C) 2004 Zack Rusin <zack@kde.org>
    3  * Copyright (C) 2004-2019 Apple Inc. All rights reserved.
     3 * Copyright (C) 2004-2021 Apple Inc. All rights reserved.
    44 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
    55 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
     
    40534053            break;
    40544054
     4055        // Unimplemented @font-palette-values properties
     4056        case CSSPropertyBasePalette:
     4057        case CSSPropertyOverrideColor:
     4058            break;
     4059
    40554060        /* Other unimplemented properties */
    40564061        case CSSPropertyPage: // for @page
  • trunk/Source/WebCore/css/CSSFontPaletteValuesOverrideColorValue.cpp

    r282805 r282806  
    11/*
    2  * Copyright (C) 2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #pragma once
     26#include "config.h"
     27#include "CSSFontPaletteValuesOverrideColorValue.h"
    2728
    2829namespace WebCore {
    2930
    30 enum class StyleRuleType : uint8_t {
    31     Unknown, // Not used.
    32     Style,
    33     Charset, // Not used. These are internally strings owned by the style sheet.
    34     Import,
    35     Media,
    36     FontFace,
    37     Page,
    38     Keyframes,
    39     Keyframe, // Not used. These are internally non-rule StyleRuleKeyframe objects.
    40     Namespace = 10,
    41     CounterStyle = 11,
    42     Supports = 12,
    43     Layer = 13,
    44 };
     31String CSSFontPaletteValuesOverrideColorValue::customCSSText() const
     32{
     33    return makeString(m_key->cssText(), " ", m_color->cssText());
     34}
    4535
    46 } // namespace WebCore
     36bool CSSFontPaletteValuesOverrideColorValue::equals(const CSSFontPaletteValuesOverrideColorValue& other) const
     37{
     38    return m_key->equals(other.key()) && m_color->equals(other.color());
     39}
     40
     41}
  • trunk/Source/WebCore/css/CSSFontPaletteValuesOverrideColorValue.h

    r282805 r282806  
    11/*
    2  * Copyright (C) 2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#pragma once
    2727
     28#include "CSSValue.h"
     29#include "CachedResourceHandle.h"
     30#include "ResourceLoaderOptions.h"
     31#include <wtf/Function.h>
     32#include <wtf/text/WTFString.h>
     33
    2834namespace WebCore {
    2935
    30 enum class StyleRuleType : uint8_t {
    31     Unknown, // Not used.
    32     Style,
    33     Charset, // Not used. These are internally strings owned by the style sheet.
    34     Import,
    35     Media,
    36     FontFace,
    37     Page,
    38     Keyframes,
    39     Keyframe, // Not used. These are internally non-rule StyleRuleKeyframe objects.
    40     Namespace = 10,
    41     CounterStyle = 11,
    42     Supports = 12,
    43     Layer = 13,
     36class CachedFont;
     37class FontLoadRequest;
     38class SVGFontFaceElement;
     39class ScriptExecutionContext;
     40
     41class CSSFontPaletteValuesOverrideColorValue final : public CSSValue {
     42public:
     43    static Ref<CSSFontPaletteValuesOverrideColorValue> create(Ref<CSSPrimitiveValue>&& key, Ref<CSSPrimitiveValue>&& color)
     44    {
     45        return adoptRef(*new CSSFontPaletteValuesOverrideColorValue(WTFMove(key), WTFMove(color)));
     46    }
     47
     48    const CSSPrimitiveValue& key() const
     49    {
     50        return m_key.get();
     51    }
     52
     53    const CSSPrimitiveValue& color() const
     54    {
     55        return m_color.get();
     56    }
     57
     58    String customCSSText() const;
     59
     60    bool equals(const CSSFontPaletteValuesOverrideColorValue&) const;
     61
     62private:
     63    CSSFontPaletteValuesOverrideColorValue(Ref<CSSPrimitiveValue>&& key, Ref<CSSPrimitiveValue>&& color)
     64        : CSSValue(FontPaletteValuesOverrideColorClass)
     65        , m_key(WTFMove(key))
     66        , m_color(WTFMove(color))
     67    {
     68    }
     69
     70    Ref<CSSPrimitiveValue> m_key;
     71    Ref<CSSPrimitiveValue> m_color;
    4472};
    4573
    4674} // namespace WebCore
     75
     76SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSFontPaletteValuesOverrideColorValue, isFontPaletteValuesOverrideColorValue())
  • trunk/Source/WebCore/css/CSSFontPaletteValuesRule.h

    r282805 r282806  
    11/*
    2  * Copyright (C) 2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#pragma once
    2727
     28#include "CSSRule.h"
     29
    2830namespace WebCore {
    2931
    30 enum class StyleRuleType : uint8_t {
    31     Unknown, // Not used.
    32     Style,
    33     Charset, // Not used. These are internally strings owned by the style sheet.
    34     Import,
    35     Media,
    36     FontFace,
    37     Page,
    38     Keyframes,
    39     Keyframe, // Not used. These are internally non-rule StyleRuleKeyframe objects.
    40     Namespace = 10,
    41     CounterStyle = 11,
    42     Supports = 12,
    43     Layer = 13,
     32class CSSStyleDeclaration;
     33class DOMMapAdapter;
     34class StyleRuleFontFace;
     35class StyleRuleCSSStyleDeclaration;
     36
     37class CSSFontPaletteValuesRule final : public CSSRule {
     38public:
     39    static Ref<CSSFontPaletteValuesRule> create(StyleRuleFontPaletteValues& rule, CSSStyleSheet* sheet) { return adoptRef(*new CSSFontPaletteValuesRule(rule, sheet)); }
     40
     41    virtual ~CSSFontPaletteValuesRule();
     42
     43    String fontFamily() const;
     44    String basePalette() const;
     45
     46    void initializeMapLike(DOMMapAdapter&);
     47
     48private:
     49    CSSFontPaletteValuesRule(StyleRuleFontPaletteValues&, CSSStyleSheet* parent);
     50
     51    CSSRule::Type type() const final { return FONT_PALETTE_VALUES_RULE; }
     52    String cssText() const final;
     53    void reattach(StyleRuleBase&) final;
     54
     55    Ref<StyleRuleFontPaletteValues> m_fontPaletteValuesRule;
    4456};
    4557
    4658} // namespace WebCore
     59
     60SPECIALIZE_TYPE_TRAITS_CSS_RULE(CSSFontPaletteValuesRule, CSSRule::FONT_PALETTE_VALUES_RULE)
  • trunk/Source/WebCore/css/CSSProperties.json

    r282750 r282806  
    40864086            }
    40874087        },
     4088        "base-palette": {
     4089            "codegen-properties": {
     4090                "skip-builder": true,
     4091                "descriptor-only": true
     4092            },
     4093            "specification": {
     4094                "category": "css-fonts",
     4095                "url": "https://drafts.csswg.org/css-fonts-4/#base-palette-desc"
     4096            }
     4097        },
     4098        "override-color": {
     4099            "codegen-properties": {
     4100                "skip-builder": true,
     4101                "descriptor-only": true
     4102            },
     4103            "specification": {
     4104                "category": "css-fonts",
     4105                "url": "https://drafts.csswg.org/css-fonts-4/#override-color"
     4106            }
     4107        },
    40884108        "stop-color": {
    40894109            "codegen-properties": {
  • trunk/Source/WebCore/css/CSSRule.cpp

    r276152 r282806  
    22 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
    33 * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
    4  * Copyright (C) 2002, 2005, 2006, 2007, 2012 Apple Inc. All rights reserved.
     4 * Copyright (C) 2002-2021 Apple Inc. All rights reserved.
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    4949COMPILE_ASSERT(StyleRuleType::CounterStyle == static_cast<StyleRuleType>(CSSRule::Type::COUNTER_STYLE_RULE), enums_should_match);
    5050COMPILE_ASSERT(StyleRuleType::Supports == static_cast<StyleRuleType>(CSSRule::Type::SUPPORTS_RULE), enums_should_match);
     51COMPILE_ASSERT(StyleRuleType::FontPaletteValues == static_cast<StyleRuleType>(CSSRule::Type::FONT_PALETTE_VALUES_RULE), enums_should_match);
    5152
    5253ExceptionOr<void> CSSRule::setCssText(const String&)
  • trunk/Source/WebCore/css/CSSRule.h

    r276152 r282806  
    22 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
    33 * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
    4  * Copyright (C) 2002-2020 Apple Inc. All rights reserved.
     4 * Copyright (C) 2002-2021 Apple Inc. All rights reserved.
    55 * Copyright (C) 2011 Andreas Kling (kling@webkit.org)
    66 *
     
    3939    // WebIDL enum
    4040    enum Type {
    41         UNKNOWN_RULE,
    42         STYLE_RULE,
    43         CHARSET_RULE,
    44         IMPORT_RULE,
    45         MEDIA_RULE,
    46         FONT_FACE_RULE,
    47         PAGE_RULE,
    48         KEYFRAMES_RULE,
    49         KEYFRAME_RULE,
    50         MARGIN_RULE,
    51         NAMESPACE_RULE,
    52         COUNTER_STYLE_RULE,
    53         SUPPORTS_RULE
     41        UNKNOWN_RULE = 0,
     42        STYLE_RULE = 1,
     43        CHARSET_RULE = 2,
     44        IMPORT_RULE = 3,
     45        MEDIA_RULE = 4,
     46        FONT_FACE_RULE = 5,
     47        PAGE_RULE = 6,
     48        KEYFRAMES_RULE = 7,
     49        KEYFRAME_RULE = 8,
     50        MARGIN_RULE = 9,
     51        NAMESPACE_RULE = 10,
     52        COUNTER_STYLE_RULE = 11,
     53        SUPPORTS_RULE = 12,
     54        FONT_PALETTE_VALUES_RULE = 19 // https://github.com/w3c/csswg-drafts/issues/6623
    5455    };
    5556
  • trunk/Source/WebCore/css/CSSRule.idl

    r276152 r282806  
    11/*
    2  * Copyright (C) 2006-2020 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006-2021 Apple Inc. All rights reserved.
    33 * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
    44 *
     
    4545    [EnabledBySetting=CSSCounterStyleAtRules] const unsigned short COUNTER_STYLE_RULE = 11;
    4646    const unsigned short SUPPORTS_RULE = 12;
     47    const unsigned short FONT_PALETTE_VALUES_RULE = 19; /* https://github.com/w3c/csswg-drafts/issues/6623 */
    4748
    4849    // Legacy synonyms for the above, kept to avoid breaking existing content.
  • trunk/Source/WebCore/css/CSSValue.cpp

    r280599 r282806  
    22 * Copyright (C) 2011 Andreas Kling (kling@webkit.org)
    33 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
     4 * Copyright (C) 2021 Apple Inc. All rights reserved.
    45 *
    56 * Redistribution and use in source and binary forms, with or without
     
    4041#include "CSSFontFaceSrcValue.h"
    4142#include "CSSFontFeatureValue.h"
     43#include "CSSFontPaletteValuesOverrideColorValue.h"
    4244#include "CSSFontStyleRangeValue.h"
    4345#include "CSSFontStyleValue.h"
     
    165167        case FontFaceSrcClass:
    166168            return compareCSSValues<CSSFontFaceSrcValue>(*this, other);
     169        case FontPaletteValuesOverrideColorClass:
     170            return compareCSSValues<CSSFontPaletteValuesOverrideColorValue>(*this, other);
    167171        case FontFeatureClass:
    168172            return compareCSSValues<CSSFontFeatureValue>(*this, other);
     
    265269    case FontFaceSrcClass:
    266270        return downcast<CSSFontFaceSrcValue>(*this).customCSSText();
     271    case FontPaletteValuesOverrideColorClass:
     272        return downcast<CSSFontPaletteValuesOverrideColorValue>(*this).customCSSText();
    267273    case FontFeatureClass:
    268274        return downcast<CSSFontFeatureValue>(*this).customCSSText();
     
    378384        delete downcast<CSSFontFaceSrcValue>(this);
    379385        return;
     386    case FontPaletteValuesOverrideColorClass:
     387        delete downcast<CSSFontPaletteValuesOverrideColorValue>(this);
     388        return;
    380389    case FontFeatureClass:
    381390        delete downcast<CSSFontFeatureValue>(this);
  • trunk/Source/WebCore/css/CSSValue.h

    r280689 r282806  
    11/*
    22 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
    3  * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
     3 * Copyright (C) 2004-2021 Apple Inc. All rights reserved.
    44 *
    55 * This library is free software; you can redistribute it and/or
     
    9898    bool isFontVariationValue() const { return m_classType == FontVariationClass; }
    9999    bool isFontFaceSrcValue() const { return m_classType == FontFaceSrcClass; }
     100    bool isFontPaletteValuesOverrideColorValue() const { return m_classType == FontPaletteValuesOverrideColorClass; }
    100101    bool isFontValue() const { return m_classType == FontClass; }
    101102    bool isFontStyleValue() const { return m_classType == FontStyleClass; }
     
    188189        FontStyleRangeClass,
    189190        FontFaceSrcClass,
     191        FontPaletteValuesOverrideColorClass,
    190192        FunctionClass,
    191193
  • trunk/Source/WebCore/css/StyleRule.cpp

    r281701 r282806  
    22 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
    33 * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
    4  * Copyright (C) 2002-2020 Apple Inc. All rights reserved.
     4 * Copyright (C) 2002-2021 Apple Inc. All rights reserved.
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    2626#include "CSSDeferredParser.h"
    2727#include "CSSFontFaceRule.h"
     28#include "CSSFontPaletteValuesRule.h"
    2829#include "CSSImportRule.h"
    2930#include "CSSKeyframeRule.h"
     
    7172        delete downcast<StyleRuleFontFace>(this);
    7273        return;
     74    case StyleRuleType::FontPaletteValues:
     75        delete downcast<StyleRuleFontPaletteValues>(this);
     76        return;
    7377    case StyleRuleType::Media:
    7478        delete downcast<StyleRuleMedia>(this);
     
    114118    case StyleRuleType::FontFace:
    115119        return downcast<StyleRuleFontFace>(*this).copy();
     120    case StyleRuleType::FontPaletteValues:
     121        return downcast<StyleRuleFontPaletteValues>(*this).copy();
    116122    case StyleRuleType::Media:
    117123        return downcast<StyleRuleMedia>(*this).copy();
     
    150156        rule = CSSFontFaceRule::create(downcast<StyleRuleFontFace>(self), parentSheet);
    151157        break;
     158    case StyleRuleType::FontPaletteValues:
     159        rule = CSSFontPaletteValuesRule::create(downcast<StyleRuleFontPaletteValues>(self), parentSheet);
     160        break;
    152161    case StyleRuleType::Media:
    153162        rule = CSSMediaRule::create(downcast<StyleRuleMedia>(self), parentSheet);
     
    320329}
    321330
     331StyleRuleFontPaletteValues::StyleRuleFontPaletteValues(const AtomString& name, const AtomString& fontFamily, const FontPaletteValues::PaletteIndex& basePalette, Vector<FontPaletteValues::OverriddenColor>&& overrideColor)
     332    : StyleRuleBase(StyleRuleType::FontPaletteValues)
     333    , m_name(name)
     334    , m_fontFamily(fontFamily)
     335    , m_fontPaletteValues(basePalette, WTFMove(overrideColor))
     336{
     337}
     338
     339StyleRuleFontPaletteValues::StyleRuleFontPaletteValues(const StyleRuleFontPaletteValues& o)
     340    : StyleRuleBase(o)
     341    , m_name(o.name())
     342    , m_fontFamily(o.fontFamily())
     343    , m_fontPaletteValues(o.m_fontPaletteValues)
     344{
     345}
     346
     347StyleRuleFontPaletteValues::~StyleRuleFontPaletteValues() = default;
     348
    322349DeferredStyleGroupRuleList::DeferredStyleGroupRuleList(const CSSParserTokenRange& range, CSSDeferredParser& parser)
    323350    : m_parser(parser)
  • trunk/Source/WebCore/css/StyleRule.h

    r281701 r282806  
    22 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
    33 * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
    4  * Copyright (C) 2002-2020 Apple Inc. All rights reserved.
     4 * Copyright (C) 2002-2021 Apple Inc. All rights reserved.
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    2424#include "CSSSelectorList.h"
    2525#include "CompiledSelector.h"
     26#include "FontPaletteValues.h"
    2627#include "StyleProperties.h"
    2728#include "StyleRuleType.h"
     
    5354    bool isCounterStyleRule() const { return type() == StyleRuleType::CounterStyle; }
    5455    bool isFontFaceRule() const { return type() == StyleRuleType::FontFace; }
     56    bool isFontPaletteValuesRule() const { return type() == StyleRuleType::FontPaletteValues; }
    5557    bool isKeyframesRule() const { return type() == StyleRuleType::Keyframes; }
    5658    bool isKeyframeRule() const { return type() == StyleRuleType::Keyframe; }
     
    156158};
    157159
     160class StyleRuleFontPaletteValues final : public StyleRuleBase {
     161public:
     162    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))); }
     163   
     164    ~StyleRuleFontPaletteValues();
     165
     166    const AtomString& name() const
     167    {
     168        return m_name;
     169    }
     170
     171    const AtomString& fontFamily() const
     172    {
     173        return m_fontFamily;
     174    }
     175
     176    const FontPaletteValues& fontPaletteValues() const
     177    {
     178        return m_fontPaletteValues;
     179    }
     180
     181    const FontPaletteValues::PaletteIndex& basePalette() const
     182    {
     183        return m_fontPaletteValues.basePalette();
     184    }
     185
     186    const Vector<FontPaletteValues::OverriddenColor>& overrideColor() const
     187    {
     188        return m_fontPaletteValues.overrideColor();
     189    }
     190
     191    Ref<StyleRuleFontPaletteValues> copy() const { return adoptRef(*new StyleRuleFontPaletteValues(*this)); }
     192
     193private:
     194    StyleRuleFontPaletteValues(const AtomString& name, const AtomString& fontFamily, const FontPaletteValues::PaletteIndex& basePalette, Vector<FontPaletteValues::OverriddenColor>&& overrideColor);
     195    StyleRuleFontPaletteValues(const StyleRuleFontPaletteValues&);
     196
     197    AtomString m_name;
     198    AtomString m_fontFamily;
     199    FontPaletteValues m_fontPaletteValues;
     200};
     201
    158202class StyleRulePage final : public StyleRuleBase {
    159203public:
     
    358402SPECIALIZE_TYPE_TRAITS_END()
    359403
     404SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::StyleRuleFontPaletteValues)
     405    static bool isType(const WebCore::StyleRuleBase& rule) { return rule.isFontPaletteValuesRule(); }
     406SPECIALIZE_TYPE_TRAITS_END()
     407
    360408SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::StyleRuleMedia)
    361409    static bool isType(const WebCore::StyleRuleBase& rule) { return rule.isMediaRule(); }
  • trunk/Source/WebCore/css/StyleRuleType.h

    r281701 r282806  
    11/*
    2  * Copyright (C) 2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019-2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2929
    3030enum class StyleRuleType : uint8_t {
    31     Unknown, // Not used.
    32     Style,
    33     Charset, // Not used. These are internally strings owned by the style sheet.
    34     Import,
    35     Media,
    36     FontFace,
    37     Page,
    38     Keyframes,
    39     Keyframe, // Not used. These are internally non-rule StyleRuleKeyframe objects.
     31    Unknown = 0, // Not used.
     32    Style = 1,
     33    Charset = 2, // Not used. These are internally strings owned by the style sheet.
     34    Import = 3,
     35    Media = 4,
     36    FontFace = 5,
     37    Page = 6,
     38    Keyframes = 7,
     39    Keyframe = 8, // Not used. These are internally non-rule StyleRuleKeyframe objects.
     40    // Margin = 9, FIXME: Why is this missing?
    4041    Namespace = 10,
    4142    CounterStyle = 11,
    4243    Supports = 12,
    43     Layer = 13,
     44    FontPaletteValues = 19, // https://github.com/w3c/csswg-drafts/issues/6623
     45    Layer = 20
    4446};
    4547
  • trunk/Source/WebCore/css/StyleSheetContents.cpp

    r281701 r282806  
    11/*
    22 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
    3  * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
     3 * Copyright (C) 2004-2021 Apple Inc. All rights reserved.
    44 *
    55 * This library is free software; you can redistribute it and/or
     
    437437        case StyleRuleType::Style:
    438438        case StyleRuleType::FontFace:
     439        case StyleRuleType::FontPaletteValues:
    439440        case StyleRuleType::Page:
    440441        case StyleRuleType::Keyframes:
     
    487488        case StyleRuleType::Supports:
    488489        case StyleRuleType::Layer:
     490        case StyleRuleType::FontPaletteValues:
    489491            return false;
    490492        };
  • trunk/Source/WebCore/css/parser/CSSAtRuleID.cpp

    r281701 r282806  
    11// Copyright 2015 The Chromium Authors. All rights reserved.
    2 // Copyright (C) 2016 Apple Inc. All rights reserved.
     2// Copyright (C) 2016-2021 Apple Inc. All rights reserved.
    33//
    44// Redistribution and use in source and binary forms, with or without
     
    3939    if (equalIgnoringASCIICase(name, "font-face"))
    4040        return CSSAtRuleFontFace;
     41    if (equalIgnoringASCIICase(name, "font-palette-values"))
     42        return CSSAtRuleFontPaletteValues;
    4143    if (equalIgnoringASCIICase(name, "import"))
    4244        return CSSAtRuleImport;
  • trunk/Source/WebCore/css/parser/CSSAtRuleID.h

    r281701 r282806  
    11// Copyright 2015 The Chromium Authors. All rights reserved.
    2 // Copyright (C) 2016 Apple Inc. All rights reserved.
     2// Copyright (C) 2016-2021 Apple Inc. All rights reserved.
    33//
    44// Redistribution and use in source and binary forms, with or without
     
    5050    CSSAtRuleCounterStyle = 12,
    5151    CSSAtRuleLayer = 13,
     52
     53    CSSAtRuleFontPaletteValues = 14,
    5254};
    5355
  • trunk/Source/WebCore/css/parser/CSSParserImpl.cpp

    r281928 r282806  
    11// Copyright 2014 The Chromium Authors. All rights reserved.
    2 // Copyright (C) 2016-2020 Apple Inc. All rights reserved.
     2// Copyright (C) 2016-2021 Apple Inc. All rights reserved.
    33//
    44// Redistribution and use in source and binary forms, with or without
     
    3535#include "CSSCustomPropertyValue.h"
    3636#include "CSSDeferredParser.h"
     37#include "CSSFontPaletteValuesOverrideColorValue.h"
    3738#include "CSSKeyframeRule.h"
    3839#include "CSSKeyframesRule.h"
     
    4849#include "Document.h"
    4950#include "Element.h"
     51#include "FontPaletteValues.h"
    5052#include "MediaList.h"
    5153#include "MediaQueryParser.h"
     
    446448    case CSSAtRuleFontFace:
    447449        return consumeFontFaceRule(prelude, block);
     450    case CSSAtRuleFontPaletteValues:
     451        return consumeFontPaletteValuesRule(prelude, block);
    448452    case CSSAtRuleWebkitKeyframes:
    449453        return consumeKeyframesRule(true, prelude, block);
     
    651655    consumeDeclarationList(block, StyleRuleType::FontFace);
    652656    return StyleRuleFontFace::create(createStyleProperties(m_parsedProperties, m_context.mode));
     657}
     658
     659RefPtr<StyleRuleFontPaletteValues> CSSParserImpl::consumeFontPaletteValuesRule(CSSParserTokenRange prelude, CSSParserTokenRange block)
     660{
     661    auto name = CSSPropertyParserHelpers::consumeCustomIdent(prelude);
     662    if (!name || !prelude.atEnd())
     663        return nullptr; // Parse error; expected custom ident in @font-palette-values header
     664
     665    if (m_observerWrapper) {
     666        unsigned endOffset = m_observerWrapper->endOffset(prelude);
     667        m_observerWrapper->observer().startRuleHeader(StyleRuleType::FontPaletteValues, m_observerWrapper->startOffset(prelude));
     668        m_observerWrapper->observer().endRuleHeader(endOffset);
     669        m_observerWrapper->observer().startRuleBody(endOffset);
     670        m_observerWrapper->observer().endRuleBody(endOffset);
     671    }
     672
     673    consumeDeclarationList(block, StyleRuleType::FontPaletteValues);
     674    auto properties = createStyleProperties(m_parsedProperties, m_context.mode);
     675
     676    AtomString fontFamily;
     677    if (auto fontFamilyValue = properties->getPropertyCSSValue(CSSPropertyFontFamily))
     678        fontFamily = downcast<CSSPrimitiveValue>(*fontFamilyValue).fontFamily().familyName;
     679
     680    FontPaletteValues::PaletteIndex basePalette(nullAtom());
     681    if (auto basePaletteValue = properties->getPropertyCSSValue(CSSPropertyBasePalette)) {
     682        const auto& primitiveValue = downcast<CSSPrimitiveValue>(*basePaletteValue);
     683        if (primitiveValue.isString())
     684            basePalette = primitiveValue.stringValue();
     685        else if (primitiveValue.isNumber())
     686            basePalette = primitiveValue.value<int64_t>();
     687    }
     688
     689    Vector<FontPaletteValues::OverriddenColor> overrideColor;
     690    if (auto overrideColorValue = properties->getPropertyCSSValue(CSSPropertyOverrideColor)) {
     691        const auto& list = downcast<CSSValueList>(*overrideColorValue);
     692        for (const auto& item : list) {
     693            FontPaletteValues::PaletteColorIndex key(nullAtom());
     694            const auto& pair = downcast<CSSFontPaletteValuesOverrideColorValue>(item.get());
     695            if (pair.key().isString())
     696                key = pair.key().stringValue();
     697            else if (pair.key().isNumber())
     698                key = pair.key().value<int64_t>();
     699            else
     700                continue;
     701            overrideColor.append(std::make_pair(key, pair.color().color()));
     702        }
     703    }
     704
     705    return StyleRuleFontPaletteValues::create(name->stringValue(), fontFamily, basePalette, WTFMove(overrideColor));
    653706}
    654707
     
    9621015    }
    9631016
    964     if (important && (ruleType == StyleRuleType::FontFace || ruleType == StyleRuleType::Keyframe || ruleType == StyleRuleType::CounterStyle))
     1017    if (important && (ruleType == StyleRuleType::FontFace || ruleType == StyleRuleType::Keyframe || ruleType == StyleRuleType::CounterStyle || ruleType == StyleRuleType::FontPaletteValues))
    9651018        return;
    9661019
  • trunk/Source/WebCore/css/parser/CSSParserImpl.h

    r281701 r282806  
    11// Copyright 2014 The Chromium Authors. All rights reserved.
    2 // Copyright (C) 2016-2020 Apple Inc. All rights reserved.
     2// Copyright (C) 2016-2021 Apple Inc. All rights reserved.
    33//
    44// Redistribution and use in source and binary forms, with or without
     
    5252class StyleRuleCharset;
    5353class StyleRuleFontFace;
     54class StyleRuleFontPaletteValues;
    5455class StyleRuleImport;
    5556class StyleRuleKeyframes;
     
    134135    RefPtr<StyleRuleViewport> consumeViewportRule(CSSParserTokenRange prelude, CSSParserTokenRange block);
    135136    RefPtr<StyleRuleFontFace> consumeFontFaceRule(CSSParserTokenRange prelude, CSSParserTokenRange block);
     137    RefPtr<StyleRuleFontPaletteValues> consumeFontPaletteValuesRule(CSSParserTokenRange prelude, CSSParserTokenRange block);
    136138    RefPtr<StyleRuleKeyframes> consumeKeyframesRule(bool webkitPrefixed, CSSParserTokenRange prelude, CSSParserTokenRange block);
    137139    RefPtr<StyleRulePage> consumePageRule(CSSParserTokenRange prelude, CSSParserTokenRange block);
  • trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp

    r282723 r282806  
    3939#include "CSSFontFaceSrcValue.h"
    4040#include "CSSFontFeatureValue.h"
     41#include "CSSFontPaletteValuesOverrideColorValue.h"
    4142#if ENABLE(VARIATION_FONTS)
    4243#include "CSSFontVariationValue.h"
     
    234235    if (ruleType == StyleRuleType::FontFace)
    235236        parseSuccess = parser.parseFontFaceDescriptor(propertyID);
     237    else if (ruleType == StyleRuleType::FontPaletteValues)
     238        parseSuccess = parser.parseFontPaletteValuesDescriptor(propertyID);
    236239    else if (ruleType == StyleRuleType::CounterStyle)
    237240        parseSuccess = parser.parseCounterStyleDescriptor(propertyID, context);
     
    48354838}
    48364839
     4840static RefPtr<CSSPrimitiveValue> consumeBasePaletteDescriptor(CSSParserTokenRange& range)
     4841{
     4842    if (range.peek().type() == StringToken)
     4843        return consumeString(range);
     4844    return consumeInteger(range);
     4845}
     4846
     4847static RefPtr<CSSValueList> consumeOverrideColorDescriptor(CSSParserTokenRange& range, const CSSParserContext& context)
     4848{
     4849    RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
     4850    do {
     4851        RefPtr<CSSPrimitiveValue> key;
     4852        if (range.peek().type() == StringToken)
     4853            key = consumeString(range);
     4854        else
     4855            key = consumeInteger(range);
     4856        if (!key)
     4857            return nullptr;
     4858
     4859        auto color = consumeColor(range, context);
     4860        if (!color)
     4861            return nullptr;
     4862
     4863        RefPtr<CSSValue> value = CSSFontPaletteValuesOverrideColorValue::create(key.releaseNonNull(), color.releaseNonNull());
     4864        list->append(value.releaseNonNull());
     4865    } while (consumeCommaIncludingWhitespace(range));
     4866   
     4867    if (!range.atEnd() || !list->length())
     4868        return nullptr;
     4869
     4870    return list;
     4871}
     4872
     4873bool CSSPropertyParser::parseFontPaletteValuesDescriptor(CSSPropertyID propId)
     4874{
     4875    RefPtr<CSSValue> parsedValue;
     4876    switch (propId) {
     4877    case CSSPropertyFontFamily:
     4878        parsedValue = consumeFamilyName(m_range);
     4879        break;
     4880    case CSSPropertyBasePalette:
     4881        parsedValue = consumeBasePaletteDescriptor(m_range);
     4882        break;
     4883    case CSSPropertyOverrideColor:
     4884        parsedValue = consumeOverrideColorDescriptor(m_range, m_context);
     4885        break;
     4886    default:
     4887        break;
     4888    }
     4889
     4890    if (!parsedValue || !m_range.atEnd())
     4891        return false;
     4892
     4893    addProperty(propId, CSSPropertyInvalid, *parsedValue, false);
     4894    return true;
     4895}
     4896
    48374897bool CSSPropertyParser::consumeSystemFont(bool important)
    48384898{
  • trunk/Source/WebCore/css/parser/CSSPropertyParser.h

    r282397 r282806  
    11/*
    22 * Copyright (C) 2003 Lars Knoll (knoll@kde.org)
    3  * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010, 2016 Apple Inc. All rights reserved.
     3 * Copyright (C) 2004 - 2021 Apple Inc. All rights reserved.
    44 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
    55 * Copyright (C) 2009 - 2010  Torch Mobile (Beijing) Co. Ltd. All rights reserved.
     
    7474    bool parseViewportDescriptor(CSSPropertyID propId, bool important);
    7575    bool parseFontFaceDescriptor(CSSPropertyID);
     76    bool parseFontPaletteValuesDescriptor(CSSPropertyID);
    7677    bool parseCounterStyleDescriptor(CSSPropertyID, const CSSParserContext&);
    7778
Note: See TracChangeset for help on using the changeset viewer.