Skip to content
Permalink
Browse files
[@Property] Support <color> syntax
https://bugs.webkit.org/show_bug.cgi?id=249071
rdar://103211705

Reviewed by Alan Baradlay.

* LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/determine-registration-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/property-cascade-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/register-property-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/register-property-syntax-parsing-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/registered-property-change-style-001-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/registered-property-computation-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/registered-property-cssom-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/registered-property-initial-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/typedom-expected.txt:
* Source/WebCore/css/CSSCustomPropertyValue.cpp:
(WebCore::CSSCustomPropertyValue::equals const):
(WebCore::CSSCustomPropertyValue::customCSSText const):
* Source/WebCore/css/CSSCustomPropertyValue.h:

Add a separate variant for syntax values.

* Source/WebCore/css/parser/CSSPropertyParser.cpp:
(WebCore::CSSPropertyParser::parseCustomPropertyValueWithSyntaxDefinition):

Return the syntax type too.

(WebCore::CSSPropertyParser::canParseTypedCustomPropertyValue):
(WebCore::CSSPropertyParser::collectParsedCustomPropertyValueDependencies):
(WebCore::CSSPropertyParser::parseTypedCustomPropertyValue):

Resolve based on the syntax type instead of the primitive value type.
Use this to resolve colors (which may be color name identifiers).

* Source/WebCore/css/parser/CSSPropertyParser.h:
* Source/WebCore/css/parser/CSSPropertySyntax.cpp:
(WebCore::CSSPropertySyntax::parseComponent):
(WebCore::CSSPropertySyntax::parse):
* Source/WebCore/css/parser/CSSPropertySyntax.h:
(WebCore::CSSPropertySyntax::isUniversal):

Canonical link: https://commits.webkit.org/257698@main
  • Loading branch information
anttijk committed Dec 11, 2022
1 parent 7c2e07e commit b447da998e3c90f628c48b08298167a18e179d1c
Show file tree
Hide file tree
Showing 15 changed files with 164 additions and 134 deletions.
@@ -1,9 +1,9 @@

FAIL @property determines the registration when uncontested assert_equals: expected "1px" but got ""
FAIL CSS.registerProperty wins over @property The given initial value does not parse for the given syntax.
PASS CSS.registerProperty wins over @property
FAIL @property later in document order wins assert_equals: expected "6" but got ""
FAIL @property later in stylesheet wins assert_equals: expected "rgb(255, 0, 0)" but got ""
FAIL CSS.registerProperty determines the registration when uncontested The given initial value does not parse for the given syntax.
PASS CSS.registerProperty determines the registration when uncontested
FAIL @property registrations are cleared when rule removed assert_equals: expected "10px" but got ""
FAIL Computed value becomes token sequence when @property is removed assert_equals: expected " calc(1px + 1px)" but got "calc(1px + 1px)"
FAIL Inherited status is reflected in computed styles when @property is removed assert_equals: expected " 10px" but got "10px"
@@ -1,4 +1,4 @@

FAIL Registering a property does not affect cascade The given initial value does not parse for the given syntax.
FAIL Registering a property does not affect parsing The given initial value does not parse for the given syntax.
PASS Registering a property does not affect cascade
PASS Registering a property does not affect parsing

@@ -4,5 +4,5 @@ PASS registerProperty requires a name matching <custom-property-name>
FAIL registerProperty only allows omitting initialValue if syntax is '*' assert_throws_dom: function "() => CSS.registerProperty({name: '--syntax-test-3', syntax: 'length', inherits: false})" did not throw
PASS registerProperty fails for an already registered property
PASS registerProperty requires inherits
FAIL Registering a property should not cause a transition The given initial value does not parse for the given syntax.
PASS Registering a property should not cause a transition

@@ -4,11 +4,11 @@ PASS syntax:' * ', initialValue:'b' is valid
PASS syntax:'<length>', initialValue:'2px' is valid
PASS syntax:' <number>', initialValue:'5' is valid
PASS syntax:'<percentage> ', initialValue:'10%' is valid
FAIL syntax:'<color>+', initialValue:'red' is valid The given initial value does not parse for the given syntax.
PASS syntax:'<color>+', initialValue:'red' is valid
FAIL syntax:' <length>+ | <percentage>', initialValue:'2px 8px' is valid The given initial value does not parse for the given syntax.
FAIL syntax:' <length>+ | <color>#', initialValue:'red, blue' is valid The given initial value does not parse for the given syntax.
PASS syntax:'<length>|<percentage>|<length-percentage>', initialValue:'2px' is valid
FAIL syntax:'<color> | <image> | <url> | <integer> | <angle>', initialValue:'red' is valid The given initial value does not parse for the given syntax.
PASS syntax:'<color> | <image> | <url> | <integer> | <angle>', initialValue:'red' is valid
PASS syntax:'<time> | <resolution> | <transform-list> | <custom-ident>', initialValue:'red' is valid
PASS syntax:' <color>
| foo', initialValue:'foo' is valid
@@ -53,8 +53,8 @@ FAIL syntax:'<transform-function>|<integer>', initialValue:'scale(2)' is valid T
FAIL syntax:'<transform-function>+', initialValue:'translateX(2px) rotate(42deg)' is valid The given initial value does not parse for the given syntax.
FAIL syntax:'<transform-list>', initialValue:'scale(2)' is valid The given initial value does not parse for the given syntax.
FAIL syntax:'<transform-list>', initialValue:'translateX(2px) rotate(20deg)' is valid The given initial value does not parse for the given syntax.
FAIL syntax:'<color>', initialValue:'rgb(12, 34, 56)' is valid The given initial value does not parse for the given syntax.
FAIL syntax:'<color>', initialValue:'lightgoldenrodyellow' is valid The given initial value does not parse for the given syntax.
PASS syntax:'<color>', initialValue:'rgb(12, 34, 56)' is valid
PASS syntax:'<color>', initialValue:'lightgoldenrodyellow' is valid
FAIL syntax:'<image>', initialValue:'url(a)' is valid The given initial value does not parse for the given syntax.
FAIL syntax:'<image>', initialValue:'linear-gradient(yellow, blue)' is valid The given initial value does not parse for the given syntax.
FAIL syntax:'<url>', initialValue:'url(a)' is valid The given initial value does not parse for the given syntax.
@@ -1,4 +1,4 @@

FAIL New registered property declaration The given initial value does not parse for the given syntax.
FAIL Registered property overrides a previous declaration The given initial value does not parse for the given syntax.
PASS New registered property declaration
PASS Registered property overrides a previous declaration

@@ -16,7 +16,7 @@ PASS <length> values are computed correctly [72pt]
PASS <length> values are computed correctly [10lh]
PASS <length-percentage> values are computed correctly [17em]
PASS <length-percentage> values are computed correctly [18%]
FAIL <length-percentage> values are computed correctly [calc(19em - 2%)] assert_equals: expected "calc(-2% + 190px)" but got "calc(-2% + 19em)"
PASS <length-percentage> values are computed correctly [calc(19em - 2%)]
FAIL <length># values are computed correctly [10px, 3em] assert_equals: expected "10px, 30px" but got "0px"
FAIL <length># values are computed correctly [4em ,9px] assert_equals: expected "40px, 9px" but got "0px"
PASS <length># values are computed correctly [8em]
@@ -37,14 +37,14 @@ PASS <integer> values are computed correctly [calc(2.4)]
PASS <integer> values are computed correctly [calc(2.6)]
PASS <integer> values are computed correctly [calc(2.6 + 3.1)]
FAIL <integer>+ values are computed correctly [15 calc(2.4) calc(2.6)] assert_equals: expected "15 2 3" but got "0"
FAIL <color> values are computed correctly [#ff0000] The given initial value does not parse for the given syntax.
FAIL <color> values are computed correctly [#000f00] The given initial value does not parse for the given syntax.
FAIL <color> values are computed correctly [#00000a] The given initial value does not parse for the given syntax.
FAIL <color> values are computed correctly [#badbee] The given initial value does not parse for the given syntax.
FAIL <color> values are computed correctly [#badbee33] The given initial value does not parse for the given syntax.
FAIL <color> values are computed correctly [tomato] The given initial value does not parse for the given syntax.
FAIL <color> values are computed correctly [plum] The given initial value does not parse for the given syntax.
FAIL <color> values are computed correctly [currentcolor] The given initial value does not parse for the given syntax.
PASS <color> values are computed correctly [#ff0000]
PASS <color> values are computed correctly [#000f00]
PASS <color> values are computed correctly [#00000a]
PASS <color> values are computed correctly [#badbee]
PASS <color> values are computed correctly [#badbee33]
PASS <color> values are computed correctly [tomato]
PASS <color> values are computed correctly [plum]
PASS <color> values are computed correctly [currentcolor]
PASS * values are computed correctly [tomato]
PASS tomato | plum values are computed correctly [plum]
PASS tomato | plum | <color> values are computed correctly [plum]
@@ -1,9 +1,9 @@

FAIL CSSOM setters function as expected for unregistered properties assert_equals: expected " 10px" but got "10px"
FAIL CSS.registerProperty The given initial value does not parse for the given syntax.
PASS CSS.registerProperty
FAIL Formerly valid values are still readable from inline styles but are computed as the unset value assert_equals: expected "5" but got ""
FAIL Values not matching the registered type can still be set assert_equals: expected "hi" but got ""
FAIL Values can be removed from inline styles assert_equals: expected "rgb(255, 0, 0)" but got "red"
PASS Values can be removed from inline styles
FAIL Stylesheets can be modified by CSSOM assert_equals: expected "0px" but got "10px"
FAIL Valid values can be set on inline styles assert_equals: expected "rgb(255, 192, 203)" but got "pink"
FAIL Valid values can be set on inline styles assert_equals: expected "inherit" but got "pink"

@@ -7,18 +7,18 @@ PASS Initial value for <length> correctly computed [6pc]
PASS Initial value for <length> correctly computed [72pt]
PASS Initial value for <percentage> correctly computed [calc(10% + 20%)]
PASS Initial value for <length-percentage> correctly computed [calc(1in + 10% + 4px)]
FAIL Initial value for <color> correctly computed [pink, inherits] The given initial value does not parse for the given syntax.
FAIL Initial value for <color> correctly computed [purple] The given initial value does not parse for the given syntax.
PASS Initial value for <color> correctly computed [pink, inherits]
PASS Initial value for <color> correctly computed [purple]
FAIL Initial value for <transform-function> correctly computed [rotate(42deg)] The given initial value does not parse for the given syntax.
FAIL Initial value for <transform-list> correctly computed [scale(calc(2 + 2))] The given initial value does not parse for the given syntax.
FAIL Initial value for <transform-list> correctly computed [scale(calc(2 + 1)) translateX(calc(3px + 1px))] The given initial value does not parse for the given syntax.
FAIL Initial value for <url> correctly computed [url(a)] The given initial value does not parse for the given syntax.
FAIL Initial value for <url>+ correctly computed [url(a) url(a)] The given initial value does not parse for the given syntax.
FAIL Initial inherited value can be substituted [purple, color] The given initial value does not parse for the given syntax.
FAIL Initial non-inherited value can be substituted [pink, background-color] The given initial value does not parse for the given syntax.
PASS Initial inherited value can be substituted [purple, color]
PASS Initial non-inherited value can be substituted [pink, background-color]
PASS Initial non-inherited value can be substituted [ foo , --x]
PASS Initial non-inherited value can be substituted [ 1turn, --x]
FAIL Initial non-inherited value can be substituted [ pink , --x] The given initial value does not parse for the given syntax.
PASS Initial non-inherited value can be substituted [ pink , --x]
PASS Initial non-inherited value can be substituted [ test, --x]
PASS Initial non-inherited value can be substituted [calc(20 + 20 + 10), --x]
PASS Initial non-inherited value can be substituted [ calc(13% + 37px), --x]
@@ -1,7 +1,7 @@

PASS Computed * is reified as CSSUnparsedValue
FAIL Computed <angle> is reified as CSSUnitValue assert_false: expected false got true
FAIL Computed <color> is reified as CSSStyleValue The given initial value does not parse for the given syntax.
FAIL Computed <color> is reified as CSSStyleValue assert_false: expected false got true
FAIL Computed <custom-ident> is reified as CSSKeywordValue assert_false: expected false got true
FAIL Computed <image> [url] is reified as CSSImageValue The given initial value does not parse for the given syntax.
FAIL Computed <integer> is reified as CSSUnitValue assert_false: expected false got true
@@ -25,8 +25,8 @@ PASS Specified foo is reified as CSSUnparsedValue from get/getAll [attributeStyl
PASS Specified foo is reified as CSSUnparsedValue from get/getAll [styleMap]
PASS Specified <angle> is reified as CSSUnparsedValue from get/getAll [attributeStyleMap]
PASS Specified <angle> is reified as CSSUnparsedValue from get/getAll [styleMap]
FAIL Specified <color> is reified as CSSUnparsedValue from get/getAll [attributeStyleMap] The given initial value does not parse for the given syntax.
FAIL Specified <color> is reified as CSSUnparsedValue from get/getAll [styleMap] The given initial value does not parse for the given syntax.
PASS Specified <color> is reified as CSSUnparsedValue from get/getAll [attributeStyleMap]
PASS Specified <color> is reified as CSSUnparsedValue from get/getAll [styleMap]
PASS Specified <custom-ident> is reified as CSSUnparsedValue from get/getAll [attributeStyleMap]
PASS Specified <custom-ident> is reified as CSSUnparsedValue from get/getAll [styleMap]
FAIL Specified <image> is reified as CSSUnparsedValue from get/getAll [attributeStyleMap] The given initial value does not parse for the given syntax.
@@ -61,8 +61,8 @@ PASS Specified string "foo" accepted by set() for syntax foo [attributeStyleMap]
PASS Specified string "foo" accepted by set() for syntax foo [styleMap]
PASS Specified string "10deg" accepted by set() for syntax <angle> [attributeStyleMap]
PASS Specified string "10deg" accepted by set() for syntax <angle> [styleMap]
FAIL Specified string "green" accepted by set() for syntax <color> [attributeStyleMap] The given initial value does not parse for the given syntax.
FAIL Specified string "green" accepted by set() for syntax <color> [styleMap] The given initial value does not parse for the given syntax.
PASS Specified string "green" accepted by set() for syntax <color> [attributeStyleMap]
PASS Specified string "green" accepted by set() for syntax <color> [styleMap]
PASS Specified string "foo" accepted by set() for syntax <custom-ident> [attributeStyleMap]
PASS Specified string "foo" accepted by set() for syntax <custom-ident> [styleMap]
FAIL Specified string "url("a")" accepted by set() for syntax <image> [attributeStyleMap] The given initial value does not parse for the given syntax.
@@ -95,8 +95,8 @@ PASS Specified string "bar" accepted by set() for syntax foo [attributeStyleMap]
PASS Specified string "bar" accepted by set() for syntax foo [styleMap]
PASS Specified string "10px" accepted by set() for syntax <angle> [attributeStyleMap]
PASS Specified string "10px" accepted by set() for syntax <angle> [styleMap]
FAIL Specified string "10px" accepted by set() for syntax <color> [attributeStyleMap] The given initial value does not parse for the given syntax.
FAIL Specified string "10px" accepted by set() for syntax <color> [styleMap] The given initial value does not parse for the given syntax.
PASS Specified string "10px" accepted by set() for syntax <color> [attributeStyleMap]
PASS Specified string "10px" accepted by set() for syntax <color> [styleMap]
PASS Specified string "10px" accepted by set() for syntax <custom-ident> [attributeStyleMap]
PASS Specified string "10px" accepted by set() for syntax <custom-ident> [styleMap]
FAIL Specified string "a" accepted by set() for syntax <image> [attributeStyleMap] The given initial value does not parse for the given syntax.
@@ -131,8 +131,8 @@ PASS CSSUnparsedValue is accepted via set() for syntax foo [attributeStyleMap]
PASS CSSUnparsedValue is accepted via set() for syntax foo [styleMap]
PASS CSSUnparsedValue is accepted via set() for syntax <angle> [attributeStyleMap]
PASS CSSUnparsedValue is accepted via set() for syntax <angle> [styleMap]
FAIL CSSUnparsedValue is accepted via set() for syntax <color> [attributeStyleMap] The given initial value does not parse for the given syntax.
FAIL CSSUnparsedValue is accepted via set() for syntax <color> [styleMap] The given initial value does not parse for the given syntax.
PASS CSSUnparsedValue is accepted via set() for syntax <color> [attributeStyleMap]
PASS CSSUnparsedValue is accepted via set() for syntax <color> [styleMap]
PASS CSSUnparsedValue is accepted via set() for syntax <custom-ident> [attributeStyleMap]
PASS CSSUnparsedValue is accepted via set() for syntax <custom-ident> [styleMap]
FAIL CSSUnparsedValue is accepted via set() for syntax <image> [attributeStyleMap] The given initial value does not parse for the given syntax.
@@ -197,8 +197,8 @@ FAIL Appending a string to foo+ is not allowed [attributeStyleMap] The given ini
FAIL Appending a string to foo+ is not allowed [styleMap] The given initial value does not parse for the given syntax.
PASS Appending a string to <angle>+ is not allowed [attributeStyleMap]
PASS Appending a string to <angle>+ is not allowed [styleMap]
FAIL Appending a string to <color>+ is not allowed [attributeStyleMap] The given initial value does not parse for the given syntax.
FAIL Appending a string to <color>+ is not allowed [styleMap] The given initial value does not parse for the given syntax.
PASS Appending a string to <color>+ is not allowed [attributeStyleMap]
PASS Appending a string to <color>+ is not allowed [styleMap]
PASS Appending a string to <custom-ident>+ is not allowed [attributeStyleMap]
PASS Appending a string to <custom-ident>+ is not allowed [styleMap]
FAIL Appending a string to <image>+ is not allowed [attributeStyleMap] The given initial value does not parse for the given syntax.
@@ -255,7 +255,7 @@ PASS Appending a CSSUnitValue to <length># is not allowed [attributeStyleMap]
PASS Appending a CSSUnitValue to <length># is not allowed [styleMap]
PASS CSSStyleValue.parse[All] returns CSSUnparsedValue for syntax *
PASS CSSStyleValue.parse[All] returns CSSUnparsedValue for syntax <angle>
FAIL CSSStyleValue.parse[All] returns CSSUnparsedValue for syntax <color> The given initial value does not parse for the given syntax.
PASS CSSStyleValue.parse[All] returns CSSUnparsedValue for syntax <color>
PASS CSSStyleValue.parse[All] returns CSSUnparsedValue for syntax <custom-ident> | <length>
FAIL CSSStyleValue.parse[All] returns CSSUnparsedValue for syntax <image> The given initial value does not parse for the given syntax.
PASS CSSStyleValue.parse[All] returns CSSUnparsedValue for syntax <integer>
@@ -281,8 +281,8 @@ PASS Specified foo is reified CSSUnparsedValue by iterator [attributeStyleMap]
PASS Specified foo is reified CSSUnparsedValue by iterator [styleMap]
PASS Specified <angle> is reified CSSUnparsedValue by iterator [attributeStyleMap]
PASS Specified <angle> is reified CSSUnparsedValue by iterator [styleMap]
FAIL Specified <color> is reified CSSUnparsedValue by iterator [attributeStyleMap] The given initial value does not parse for the given syntax.
FAIL Specified <color> is reified CSSUnparsedValue by iterator [styleMap] The given initial value does not parse for the given syntax.
PASS Specified <color> is reified CSSUnparsedValue by iterator [attributeStyleMap]
PASS Specified <color> is reified CSSUnparsedValue by iterator [styleMap]
PASS Specified <custom-ident> is reified CSSUnparsedValue by iterator [attributeStyleMap]
PASS Specified <custom-ident> is reified CSSUnparsedValue by iterator [styleMap]
FAIL Specified <image> is reified CSSUnparsedValue by iterator [attributeStyleMap] The given initial value does not parse for the given syntax.

0 comments on commit b447da9

Please sign in to comment.