Skip to content

Commit be0b82e

Browse files
committed
[@Property] Initial syntax parsing
https://bugs.webkit.org/show_bug.cgi?id=248871 <rdar://problem/103075062> Reviewed by Darin Adler. Parse <length>, <length-percentage>, <custom-ident> and ident syntax strings. * 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-computation-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: * LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/url-resolution-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/var-reference-registered-properties-expected.txt: * Source/WebCore/Sources.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/css/parser/CSSParserIdioms.h: (WebCore::isCSSSpace): * Source/WebCore/css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::parseCustomPropertyValueWithSyntaxComponents): (WebCore::CSSPropertyParser::canParseTypedCustomPropertyValue): (WebCore::CSSPropertyParser::collectParsedCustomPropertyValueDependencies): (WebCore::CSSPropertyParser::parseTypedCustomPropertyValue): * Source/WebCore/css/parser/CSSPropertyParser.h: * Source/WebCore/css/parser/CSSPropertySyntax.cpp: Added. (WebCore::CSSPropertySyntax::parseComponent): (WebCore::CSSPropertySyntax::parse): * Source/WebCore/css/parser/CSSPropertySyntax.h: Added. Add a helper. Canonical link: https://commits.webkit.org/257525@main
1 parent 5f18c2a commit be0b82e

14 files changed

+427
-178
lines changed

LayoutTests/css-custom-properties-api/inline-expected.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ PASS CSS.registerProperty
66
PASS Formerly valid values are still readable from inline styles but are computed as the unset value
77
PASS Values not matching the registered type can't be set
88
PASS Values can be removed from inline styles
9-
PASS Stylesheets can be modified by CSSOM
10-
PASS Valid values can be set on inline styles
11-
PASS Var values are accepted
12-
PASS Var values are accepted without validation
13-
PASS Var values are accepted without validation, even when it is obvious they will not parse
14-
PASS Var values are accepted without validation, even when it is obvious they will not parse (typed)
9+
FAIL Stylesheets can be modified by CSSOM assert_equals: expected "0px" but got "20px"
10+
FAIL Valid values can be set on inline styles assert_equals: expected "inherit" but got "30em"
11+
FAIL Var values are accepted assert_equals: expected "calc(var(--b) + 10px)" but got "30em"
12+
FAIL Var values are accepted without validation assert_equals: expected "calc(var(--b) + 15px)" but got "30em"
13+
FAIL Var values are accepted without validation, even when it is obvious they will not parse assert_equals: expected "calc(var(--b) 15px)" but got "30em"
14+
FAIL Var values are accepted without validation, even when it is obvious they will not parse (typed) assert_equals: expected "calc(var(--registered) 15px)" but got "30em"
1515

LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/register-property-syntax-parsing-expected.txt

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
PASS syntax:'*', initialValue:'a' is valid
3-
FAIL syntax:' * ', initialValue:'b' is valid The given initial value does not parse for the given syntax.
3+
PASS syntax:' * ', initialValue:'b' is valid
44
PASS syntax:'<length>', initialValue:'2px' is valid
55
FAIL syntax:' <number>', initialValue:'5' is valid The given initial value does not parse for the given syntax.
66
FAIL syntax:'<percentage> ', initialValue:'10%' is valid The given initial value does not parse for the given syntax.
@@ -9,9 +9,9 @@ FAIL syntax:' <length>+ | <percentage>', initialValue:'2px 8px' is valid The giv
99
FAIL syntax:' <length>+ | <color>#', initialValue:'red, blue' is valid The given initial value does not parse for the given syntax.
1010
PASS syntax:'<length>|<percentage>|<length-percentage>', initialValue:'2px' is valid
1111
FAIL syntax:'<color> | <image> | <url> | <integer> | <angle>', initialValue:'red' is valid The given initial value does not parse for the given syntax.
12-
FAIL syntax:'<time> | <resolution> | <transform-list> | <custom-ident>', initialValue:'red' is valid The given initial value does not parse for the given syntax.
13-
FAIL syntax:' <color>
14-
| foo', initialValue:'foo' is valid The given initial value does not parse for the given syntax.
12+
PASS syntax:'<time> | <resolution> | <transform-list> | <custom-ident>', initialValue:'red' is valid
13+
PASS syntax:' <color>
14+
| foo', initialValue:'foo' is valid
1515
PASS syntax:'*', initialValue:':> hello' is valid
1616
PASS syntax:'*', initialValue:'([ brackets ]) { yay (??)}' is valid
1717
PASS syntax:'*', initialValue:'yep 'this is valid too'' is valid
@@ -26,9 +26,9 @@ PASS syntax:'<length>', initialValue:'calc(7in - 12px)' is valid
2626
FAIL syntax:'<length>+', initialValue:'2px 7px calc(8px)' is valid The given initial value does not parse for the given syntax.
2727
FAIL syntax:'<length>#', initialValue:'2px, 7px, calc(8px)' is valid The given initial value does not parse for the given syntax.
2828
FAIL syntax:'<percentage>', initialValue:'-9.3e3%' is valid The given initial value does not parse for the given syntax.
29-
FAIL syntax:'<length-percentage>', initialValue:'-54%' is valid The given initial value does not parse for the given syntax.
29+
PASS syntax:'<length-percentage>', initialValue:'-54%' is valid
3030
PASS syntax:'<length-percentage>', initialValue:'0' is valid
31-
FAIL syntax:'<length-percentage>', initialValue:'calc(-11px + 10.4%)' is valid The given initial value does not parse for the given syntax.
31+
PASS syntax:'<length-percentage>', initialValue:'calc(-11px + 10.4%)' is valid
3232
PASS syntax:'<length>', initialValue:'10vmin' is valid
3333
FAIL syntax:'<percentage> | <length>+', initialValue:'calc(100vh - 10px) 30px' is valid The given initial value does not parse for the given syntax.
3434
FAIL syntax:'<number>', initialValue:'-109' is valid The given initial value does not parse for the given syntax.
@@ -58,44 +58,44 @@ FAIL syntax:'<color>', initialValue:'lightgoldenrodyellow' is valid The given in
5858
FAIL syntax:'<image>', initialValue:'url(a)' is valid The given initial value does not parse for the given syntax.
5959
FAIL syntax:'<image>', initialValue:'linear-gradient(yellow, blue)' is valid The given initial value does not parse for the given syntax.
6060
FAIL syntax:'<url>', initialValue:'url(a)' is valid The given initial value does not parse for the given syntax.
61-
FAIL syntax:'banana', initialValue:'banana' is valid The given initial value does not parse for the given syntax.
62-
FAIL syntax:'bAnAnA', initialValue:'bAnAnA' is valid The given initial value does not parse for the given syntax.
63-
FAIL syntax:'ba-na-nya', initialValue:'ba-na-nya' is valid The given initial value does not parse for the given syntax.
64-
FAIL syntax:'banana', initialValue:'banan\61' is valid The given initial value does not parse for the given syntax.
65-
FAIL syntax:'banan\61', initialValue:'banana' is valid The given initial value does not parse for the given syntax.
66-
FAIL syntax:'<custom-ident>', initialValue:'banan\61' is valid The given initial value does not parse for the given syntax.
67-
FAIL syntax:'big | bigger | BIGGER', initialValue:'bigger' is valid The given initial value does not parse for the given syntax.
61+
PASS syntax:'banana', initialValue:'banana' is valid
62+
PASS syntax:'bAnAnA', initialValue:'bAnAnA' is valid
63+
PASS syntax:'ba-na-nya', initialValue:'ba-na-nya' is valid
64+
PASS syntax:'banana', initialValue:'banan\61' is valid
65+
PASS syntax:'banan\61', initialValue:'banana' is valid
66+
PASS syntax:'<custom-ident>', initialValue:'banan\61' is valid
67+
PASS syntax:'big | bigger | BIGGER', initialValue:'bigger' is valid
6868
FAIL syntax:'foo+|bar', initialValue:'foo foo foo' is valid The given initial value does not parse for the given syntax.
69-
FAIL syntax:'banana ', initialValue:'banana' is valid The given initial value does not parse for the given syntax.
70-
FAIL syntax:'
69+
PASS syntax:'banana ', initialValue:'banana' is valid
70+
PASS syntax:'
7171
banana\r
72-
', initialValue:'banana' is valid The given initial value does not parse for the given syntax.
73-
FAIL syntax:'ba
74-
| na\r|nya', initialValue:'nya' is valid The given initial value does not parse for the given syntax.
75-
FAIL syntax:'null', initialValue:'null' is valid The given initial value does not parse for the given syntax.
72+
', initialValue:'banana' is valid
73+
PASS syntax:'ba
74+
| na\r|nya', initialValue:'nya' is valid
75+
PASS syntax:'null', initialValue:'null' is valid
7676
PASS syntax:'undefined', initialValue:'undefined' is valid
77-
FAIL syntax:'array', initialValue:'array' is valid The given initial value does not parse for the given syntax.
78-
FAIL syntax:'\1F914', initialValue:'🤔' is valid The given initial value does not parse for the given syntax.
79-
FAIL syntax:'hmm\1F914', initialValue:'hmm🤔' is valid The given initial value does not parse for the given syntax.
80-
FAIL syntax:'\1F914hmm', initialValue:'🤔hmm' is valid The given initial value does not parse for the given syntax.
81-
FAIL syntax:'\1F914 hmm', initialValue:'🤔hmm' is valid The given initial value does not parse for the given syntax.
82-
FAIL syntax:'\1F914\1F914', initialValue:'🤔🤔' is valid The given initial value does not parse for the given syntax.
77+
PASS syntax:'array', initialValue:'array' is valid
78+
PASS syntax:'\1F914', initialValue:'🤔' is valid
79+
PASS syntax:'hmm\1F914', initialValue:'hmm🤔' is valid
80+
PASS syntax:'\1F914hmm', initialValue:'🤔hmm' is valid
81+
PASS syntax:'\1F914 hmm', initialValue:'🤔hmm' is valid
82+
PASS syntax:'\1F914\1F914', initialValue:'🤔🤔' is valid
8383
PASS syntax:'banana,nya', initialValue:'banana' is invalid
84-
FAIL syntax:'<\6c ength>', initialValue:'10px' is invalid assert_throws_dom: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw
84+
PASS syntax:'<\6c ength>', initialValue:'10px' is invalid
8585
PASS syntax:'<banana>', initialValue:'banana' is invalid
8686
PASS syntax:'<Number>', initialValue:'10' is invalid
87-
FAIL syntax:'<length', initialValue:'10px' is invalid assert_throws_dom: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw
88-
FAIL syntax:'<LENGTH>', initialValue:'10px' is invalid assert_throws_dom: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw
89-
FAIL syntax:'< length>', initialValue:'10px' is invalid assert_throws_dom: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw
90-
FAIL syntax:'<length >', initialValue:'10px' is invalid assert_throws_dom: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw
91-
FAIL syntax:'<length> +', initialValue:'10px' is invalid assert_throws_dom: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw
87+
PASS syntax:'<length', initialValue:'10px' is invalid
88+
PASS syntax:'<LENGTH>', initialValue:'10px' is invalid
89+
PASS syntax:'< length>', initialValue:'10px' is invalid
90+
PASS syntax:'<length >', initialValue:'10px' is invalid
91+
PASS syntax:'<length> +', initialValue:'10px' is invalid
9292
PASS syntax:'<transform-list>+', initialValue:'scale(2)' is invalid
9393
PASS syntax:'<transform-list>#', initialValue:'scale(2)' is invalid
94-
FAIL syntax:'<length>++', initialValue:'10px' is invalid assert_throws_dom: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw
95-
FAIL syntax:'<length>##', initialValue:'10px' is invalid assert_throws_dom: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw
96-
FAIL syntax:'<length>+#', initialValue:'10px' is invalid assert_throws_dom: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw
97-
FAIL syntax:'<length>#+', initialValue:'10px' is invalid assert_throws_dom: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw
98-
FAIL syntax:'<length> | *', initialValue:'10px' is invalid assert_throws_dom: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw
94+
PASS syntax:'<length>++', initialValue:'10px' is invalid
95+
PASS syntax:'<length>##', initialValue:'10px' is invalid
96+
PASS syntax:'<length>+#', initialValue:'10px' is invalid
97+
PASS syntax:'<length>#+', initialValue:'10px' is invalid
98+
PASS syntax:'<length> | *', initialValue:'10px' is invalid
9999
PASS syntax:'*|banana', initialValue:'banana' is invalid
100100
PASS syntax:'|banana', initialValue:'banana' is invalid
101101
PASS syntax:'*+', initialValue:'banana' is invalid
@@ -114,8 +114,8 @@ PASS syntax:'unset', initialValue:'unset' is invalid
114114
PASS syntax:'revert', initialValue:'revert' is invalid
115115
PASS syntax:'revert-layer', initialValue:'revert-layer' is invalid
116116
PASS syntax:'default', initialValue:'default' is invalid
117-
FAIL syntax:'<length>|initial', initialValue:'10px' is invalid assert_throws_dom: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw
118-
FAIL syntax:'<length>|INHERIT', initialValue:'10px' is invalid assert_throws_dom: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw
117+
PASS syntax:'<length>|initial', initialValue:'10px' is invalid
118+
PASS syntax:'<length>|INHERIT', initialValue:'10px' is invalid
119119
PASS syntax:'<percentage>|unsEt', initialValue:'2%' is invalid
120120
PASS syntax:'<color>|REVert', initialValue:'red' is invalid
121121
PASS syntax:'<integer>|deFAUlt', initialValue:'1' is invalid
@@ -161,15 +161,15 @@ FAIL syntax:'<length>+', initialValue:'' is invalid assert_throws_dom: function
161161
FAIL syntax:'<length>#', initialValue:'' is invalid assert_throws_dom: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw
162162
PASS syntax:'<length>', initialValue:'10px;' is invalid
163163
PASS syntax:'<length-percentage>', initialValue:'calc(2px + 10% + 7ex)' is invalid
164-
FAIL syntax:'<percentage>', initialValue:'0' is invalid assert_throws_dom: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw
164+
PASS syntax:'<percentage>', initialValue:'0' is invalid
165165
PASS syntax:'<integer>', initialValue:'1.0' is invalid
166166
PASS syntax:'<integer>', initialValue:'1e0' is invalid
167167
PASS syntax:'<number>|foo', initialValue:'foo var(--foo, bla)' is invalid
168168
PASS syntax:'Foo | bar', initialValue:'foo' is invalid
169169
PASS syntax:'Foo | bar', initialValue:'Bar' is invalid
170-
FAIL syntax:'<angle>', initialValue:'0' is invalid assert_throws_dom: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw
170+
PASS syntax:'<angle>', initialValue:'0' is invalid
171171
PASS syntax:'<angle>', initialValue:'10%' is invalid
172-
FAIL syntax:'<time>', initialValue:'2px' is invalid assert_throws_dom: function "() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false})" did not throw
172+
PASS syntax:'<time>', initialValue:'2px' is invalid
173173
PASS syntax:'<resolution>', initialValue:'10' is invalid
174174
PASS syntax:'<transform-function>', initialValue:'scale()' is invalid
175175
PASS syntax:'<transform-list>', initialValue:'scale()' is invalid

LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/registered-property-computation-expected.txt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ PASS <length> values are computed correctly [6pc]
1515
PASS <length> values are computed correctly [72pt]
1616
PASS <length> values are computed correctly [10lh]
1717
PASS <length-percentage> values are computed correctly [17em]
18-
FAIL <length-percentage> values are computed correctly [18%] assert_equals: expected "18%" but got "0px"
19-
FAIL <length-percentage> values are computed correctly [calc(19em - 2%)] assert_equals: expected "calc(-2% + 190px)" but got "0px"
18+
PASS <length-percentage> values are computed correctly [18%]
19+
FAIL <length-percentage> values are computed correctly [calc(19em - 2%)] assert_equals: expected "calc(-2% + 190px)" but got "calc(19em - 2%)"
2020
FAIL <length># values are computed correctly [10px, 3em] assert_equals: expected "10px, 30px" but got "0px"
2121
FAIL <length># values are computed correctly [4em ,9px] assert_equals: expected "40px, 9px" but got "0px"
2222
PASS <length># values are computed correctly [8em]
2323
FAIL <length-percentage># values are computed correctly [3% , 10vmax , 22px] assert_equals: expected "3%, 80px, 22px" but got "0px"
2424
FAIL <length-percentage># values are computed correctly [calc(50% + 1em), 4px] assert_equals: expected "calc(50% + 10px), 4px" but got "0px"
25-
FAIL <length-percentage># values are computed correctly [calc(13% + 37px)] assert_equals: expected "calc(13% + 37px)" but got "0px"
25+
PASS <length-percentage># values are computed correctly [calc(13% + 37px)]
2626
FAIL <length>+ values are computed correctly [10px 3em] assert_equals: expected "10px 30px" but got "0px"
2727
FAIL <length>+ values are computed correctly [4em 9px] assert_equals: expected "40px 9px" but got "0px"
2828
FAIL <length-percentage>+ values are computed correctly [3% 10vmax 22px] assert_equals: expected "3% 80px 22px" but got "0px"
@@ -31,12 +31,12 @@ FAIL <transform-function> values are computed correctly [translateX(2px)] The gi
3131
FAIL <transform-function> values are computed correctly [translateX(10em)] The given initial value does not parse for the given syntax.
3232
FAIL <transform-function> values are computed correctly [translateX(calc(11em + 10%))] The given initial value does not parse for the given syntax.
3333
FAIL <transform-function>+ values are computed correctly [translateX(10%) scale(2)] The given initial value does not parse for the given syntax.
34-
FAIL <integer> values are computed correctly [15] assert_equals: expected "15" but got "0px"
35-
FAIL <integer> values are computed correctly [calc(15 + 15)] assert_equals: expected "30" but got "0px"
36-
FAIL <integer> values are computed correctly [calc(2.4)] assert_equals: expected "2" but got "0px"
37-
FAIL <integer> values are computed correctly [calc(2.6)] assert_equals: expected "3" but got "0px"
38-
FAIL <integer> values are computed correctly [calc(2.6 + 3.1)] assert_equals: expected "6" but got "0px"
39-
FAIL <integer>+ values are computed correctly [15 calc(2.4) calc(2.6)] assert_equals: expected "15 2 3" but got "0px"
34+
FAIL <integer> values are computed correctly [15] The given initial value does not parse for the given syntax.
35+
FAIL <integer> values are computed correctly [calc(15 + 15)] The given initial value does not parse for the given syntax.
36+
FAIL <integer> values are computed correctly [calc(2.4)] The given initial value does not parse for the given syntax.
37+
FAIL <integer> values are computed correctly [calc(2.6)] The given initial value does not parse for the given syntax.
38+
FAIL <integer> values are computed correctly [calc(2.6 + 3.1)] The given initial value does not parse for the given syntax.
39+
FAIL <integer>+ values are computed correctly [15 calc(2.4) calc(2.6)] The given initial value does not parse for the given syntax.
4040
FAIL <color> values are computed correctly [#ff0000] The given initial value does not parse for the given syntax.
4141
FAIL <color> values are computed correctly [#000f00] The given initial value does not parse for the given syntax.
4242
FAIL <color> values are computed correctly [#00000a] The given initial value does not parse for the given syntax.
@@ -46,8 +46,8 @@ FAIL <color> values are computed correctly [tomato] The given initial value does
4646
FAIL <color> values are computed correctly [plum] The given initial value does not parse for the given syntax.
4747
FAIL <color> values are computed correctly [currentcolor] The given initial value does not parse for the given syntax.
4848
PASS * values are computed correctly [tomato]
49-
FAIL tomato | plum values are computed correctly [plum] The given initial value does not parse for the given syntax.
50-
FAIL tomato | plum | <color> values are computed correctly [plum] The given initial value does not parse for the given syntax.
49+
PASS tomato | plum values are computed correctly [plum]
50+
PASS tomato | plum | <color> values are computed correctly [plum]
5151
PASS * values are computed correctly [-50grad]
5252
FAIL <angle> values are computed correctly [180deg] The given initial value does not parse for the given syntax.
5353
FAIL <angle> values are computed correctly [400grad] The given initial value does not parse for the given syntax.

0 commit comments

Comments
 (0)