Skip to content

Commit 5bbcd0a

Browse files
Calme1709AtkinsSJ
authored andcommitted
LibWeb: Parse the animation-timeline CSS property
1 parent d79aba6 commit 5bbcd0a

File tree

14 files changed

+532
-13
lines changed

14 files changed

+532
-13
lines changed

Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ Parser::ParseErrorOr<NonnullRefPtr<StyleValue const>> Parser::parse_css_value(Pr
539539
case PropertyID::AnimationIterationCount:
540540
case PropertyID::AnimationName:
541541
case PropertyID::AnimationPlayState:
542+
case PropertyID::AnimationTimeline:
542543
case PropertyID::AnimationTimingFunction:
543544
return parse_all_as(tokens, [this, property_id](auto& tokens) { return parse_simple_comma_separated_value_list(property_id, tokens); });
544545
case PropertyID::BackdropFilter:
@@ -1202,7 +1203,9 @@ RefPtr<StyleValue const> Parser::parse_aspect_ratio_value(TokenStream<ComponentV
12021203
RefPtr<StyleValue const> Parser::parse_animation_value(TokenStream<ComponentValue>& tokens)
12031204
{
12041205
// [<'animation-duration'> || <easing-function> || <'animation-delay'> || <single-animation-iteration-count> || <single-animation-direction> || <single-animation-fill-mode> || <single-animation-play-state> || [ none | <keyframes-name> ] || <single-animation-timeline>]#
1205-
// FIXME: Support <single-animation-timeline>
1206+
// NB: While it isn't in the spec the CSSWG resolved to include `animation-timeline` as a reset-only sub-property
1207+
// of the `animation` shorthand so we shouldn't actually allow <single-animation-timeline>.
1208+
// https://github.com/w3c/csswg-drafts/issues/6946#issuecomment-1233190360
12061209

12071210
Vector<PropertyID> longhand_ids {
12081211
PropertyID::AnimationDuration,
@@ -1216,7 +1219,7 @@ RefPtr<StyleValue const> Parser::parse_animation_value(TokenStream<ComponentValu
12161219
};
12171220

12181221
// FIXME: The animation-trigger properties are reset-only sub-properties of the animation shorthand.
1219-
return parse_coordinating_value_list_shorthand(tokens, PropertyID::Animation, longhand_ids);
1222+
return parse_coordinating_value_list_shorthand(tokens, PropertyID::Animation, longhand_ids, { PropertyID::AnimationTimeline });
12201223
}
12211224

12221225
RefPtr<StyleValue const> Parser::parse_background_value(TokenStream<ComponentValue>& tokens)

Libraries/LibWeb/CSS/Properties.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@
232232
"animation-direction",
233233
"animation-fill-mode",
234234
"animation-play-state",
235-
"animation-name"
235+
"animation-name",
236+
"animation-timeline"
236237
]
237238
},
238239
"animation-composition": {
@@ -338,6 +339,21 @@
338339
"paused"
339340
]
340341
},
342+
"animation-timeline": {
343+
"affects-layout": false,
344+
"animation-type": "none",
345+
"inherited": false,
346+
"initial": "auto",
347+
"valid-types": [
348+
"dashed-ident"
349+
],
350+
"valid-identifiers": [
351+
"auto",
352+
"none"
353+
],
354+
"__comment": "FIXME: animation properties should be coordinating-lists, FIXME: support scroll() and view() functions",
355+
"multiplicity": "single"
356+
},
341357
"animation-timing-function": {
342358
"affects-layout": false,
343359
"animation-type": "none",

Libraries/LibWeb/CSS/StyleValues/ShorthandStyleValue.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ String ShorthandStyleValue::to_string(SerializationMode mode) const
229229
return ""_string;
230230
}
231231
case PropertyID::Animation:
232-
return coordinating_value_list_shorthand_to_string("none"sv);
232+
return coordinating_value_list_shorthand_to_string("none"sv, {}, { PropertyID::AnimationTimeline });
233233
case PropertyID::Background: {
234234
auto color = longhand(PropertyID::BackgroundColor);
235235
auto image = longhand(PropertyID::BackgroundImage);

Tests/LibWeb/Text/expected/css/CSSStyleDeclaration-has-indexed-property-getter.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ All properties associated with getComputedStyle(document.body):
8787
"animation-iteration-count",
8888
"animation-name",
8989
"animation-play-state",
90+
"animation-timeline",
9091
"animation-timing-function",
9192
"appearance",
9293
"aspect-ratio",

Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ All supported properties and their default values exposed from CSSStylePropertie
177177
'animation-name': 'none'
178178
'animationPlayState': 'running'
179179
'animation-play-state': 'running'
180+
'animationTimeline': 'auto'
181+
'animation-timeline': 'auto'
180182
'animationTimingFunction': 'ease'
181183
'animation-timing-function': 'ease'
182184
'appearance': 'none'

Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ animation-fill-mode: none
8585
animation-iteration-count: 1
8686
animation-name: none
8787
animation-play-state: running
88+
animation-timeline: auto
8889
animation-timing-function: ease
8990
appearance: none
9091
aspect-ratio: auto
@@ -99,7 +100,7 @@ background-position-x: 0%
99100
background-position-y: 0%
100101
background-repeat: repeat
101102
background-size: auto
102-
block-size: 1515px
103+
block-size: 1530px
103104
border-block-end-color: rgb(0, 0, 0)
104105
border-block-end-style: none
105106
border-block-end-width: 0px
@@ -185,7 +186,7 @@ grid-row-start: auto
185186
grid-template-areas: none
186187
grid-template-columns: none
187188
grid-template-rows: none
188-
height: 2805px
189+
height: 2820px
189190
inline-size: 784px
190191
inset-block-end: auto
191192
inset-block-start: auto

Tests/LibWeb/Text/expected/wpt-import/css/css-animations/parsing/animation-shorthand.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ Harness status: OK
22

33
Found 36 tests
44

5-
25 Pass
6-
11 Fail
5+
28 Pass
6+
8 Fail
77
Pass e.style['animation'] = "anim paused both reverse 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-delay
88
Pass e.style['animation'] = "anim paused both reverse 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-direction
99
Pass e.style['animation'] = "anim paused both reverse 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-duration
@@ -13,7 +13,7 @@ Pass e.style['animation'] = "anim paused both reverse 4 1s -3s cubic-bezier(0, -
1313
Pass e.style['animation'] = "anim paused both reverse 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-play-state
1414
Fail e.style['animation'] = "anim paused both reverse 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-range-end
1515
Fail e.style['animation'] = "anim paused both reverse 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-range-start
16-
Fail e.style['animation'] = "anim paused both reverse 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-timeline
16+
Pass e.style['animation'] = "anim paused both reverse 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-timeline
1717
Pass e.style['animation'] = "anim paused both reverse 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-timing-function
1818
Pass e.style['animation'] = "anim paused both reverse 4 1s -3s cubic-bezier(0, -2, 1, 3)" should not set unrelated longhands
1919
Pass e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-delay
@@ -25,7 +25,7 @@ Pass e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0,
2525
Pass e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-play-state
2626
Fail e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-range-end
2727
Fail e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-range-start
28-
Fail e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-timeline
28+
Pass e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-timeline
2929
Pass e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0, -2, 1, 3)" should set animation-timing-function
3030
Pass e.style['animation'] = "anim paused both reverse, 4 1s -3s cubic-bezier(0, -2, 1, 3)" should not set unrelated longhands
3131
Pass e.style['animation'] = "4 1s -3s cubic-bezier(0, -2, 1, 3), anim paused both reverse" should set animation-delay
@@ -37,6 +37,6 @@ Pass e.style['animation'] = "4 1s -3s cubic-bezier(0, -2, 1, 3), anim paused bot
3737
Pass e.style['animation'] = "4 1s -3s cubic-bezier(0, -2, 1, 3), anim paused both reverse" should set animation-play-state
3838
Fail e.style['animation'] = "4 1s -3s cubic-bezier(0, -2, 1, 3), anim paused both reverse" should set animation-range-end
3939
Fail e.style['animation'] = "4 1s -3s cubic-bezier(0, -2, 1, 3), anim paused both reverse" should set animation-range-start
40-
Fail e.style['animation'] = "4 1s -3s cubic-bezier(0, -2, 1, 3), anim paused both reverse" should set animation-timeline
40+
Pass e.style['animation'] = "4 1s -3s cubic-bezier(0, -2, 1, 3), anim paused both reverse" should set animation-timeline
4141
Pass e.style['animation'] = "4 1s -3s cubic-bezier(0, -2, 1, 3), anim paused both reverse" should set animation-timing-function
4242
Pass e.style['animation'] = "4 1s -3s cubic-bezier(0, -2, 1, 3), anim paused both reverse" should not set unrelated longhands

Tests/LibWeb/Text/expected/wpt-import/css/css-cascade/all-prop-revert-layer.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Harness status: OK
22

3-
Found 277 tests
3+
Found 278 tests
44

5-
271 Pass
5+
272 Pass
66
6 Fail
77
Pass accent-color
88
Pass border-collapse
@@ -86,6 +86,7 @@ Pass animation-fill-mode
8686
Pass animation-iteration-count
8787
Pass animation-name
8888
Pass animation-play-state
89+
Pass animation-timeline
8990
Pass animation-timing-function
9091
Pass appearance
9192
Pass aspect-ratio
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Harness status: OK
2+
3+
Found 27 tests
4+
5+
14 Pass
6+
13 Fail
7+
Pass e.style['animation'] = "1s linear 1s 2 reverse forwards paused anim" should set the property value
8+
Pass e.style['animation'] = "1s linear 1s 2 reverse forwards paused anim initial" should not set the property value
9+
Pass e.style['animation'] = "1s linear 1s 2 reverse forwards paused anim 2000" should not set the property value
10+
Pass e.style['animation'] = "1s linear 1s 2 reverse forwards paused anim scroll()" should not set the property value
11+
Pass e.style['animation'] = "1s linear 1s 2 reverse forwards paused anim view()" should not set the property value
12+
Pass e.style['animation'] = "1s linear 1s 2 reverse forwards paused anim --timeline" should not set the property value
13+
Pass Property animation value '1s linear 1s 2 reverse forwards paused anim'
14+
Fail e.style['animation'] = "1s linear 1s 2 reverse forwards paused anim1,\n 1s linear 1s 2 reverse forwards paused anim2,\n 1s linear 1s 2 reverse forwards paused anim3" should set animation-delay
15+
Fail e.style['animation'] = "1s linear 1s 2 reverse forwards paused anim1,\n 1s linear 1s 2 reverse forwards paused anim2,\n 1s linear 1s 2 reverse forwards paused anim3" should set animation-direction
16+
Fail e.style['animation'] = "1s linear 1s 2 reverse forwards paused anim1,\n 1s linear 1s 2 reverse forwards paused anim2,\n 1s linear 1s 2 reverse forwards paused anim3" should set animation-duration
17+
Fail e.style['animation'] = "1s linear 1s 2 reverse forwards paused anim1,\n 1s linear 1s 2 reverse forwards paused anim2,\n 1s linear 1s 2 reverse forwards paused anim3" should set animation-fill-mode
18+
Fail e.style['animation'] = "1s linear 1s 2 reverse forwards paused anim1,\n 1s linear 1s 2 reverse forwards paused anim2,\n 1s linear 1s 2 reverse forwards paused anim3" should set animation-iteration-count
19+
Pass e.style['animation'] = "1s linear 1s 2 reverse forwards paused anim1,\n 1s linear 1s 2 reverse forwards paused anim2,\n 1s linear 1s 2 reverse forwards paused anim3" should set animation-name
20+
Fail e.style['animation'] = "1s linear 1s 2 reverse forwards paused anim1,\n 1s linear 1s 2 reverse forwards paused anim2,\n 1s linear 1s 2 reverse forwards paused anim3" should set animation-play-state
21+
Fail e.style['animation'] = "1s linear 1s 2 reverse forwards paused anim1,\n 1s linear 1s 2 reverse forwards paused anim2,\n 1s linear 1s 2 reverse forwards paused anim3" should set animation-range-end
22+
Fail e.style['animation'] = "1s linear 1s 2 reverse forwards paused anim1,\n 1s linear 1s 2 reverse forwards paused anim2,\n 1s linear 1s 2 reverse forwards paused anim3" should set animation-range-start
23+
Pass e.style['animation'] = "1s linear 1s 2 reverse forwards paused anim1,\n 1s linear 1s 2 reverse forwards paused anim2,\n 1s linear 1s 2 reverse forwards paused anim3" should set animation-timeline
24+
Fail e.style['animation'] = "1s linear 1s 2 reverse forwards paused anim1,\n 1s linear 1s 2 reverse forwards paused anim2,\n 1s linear 1s 2 reverse forwards paused anim3" should set animation-timing-function
25+
Pass e.style['animation'] = "1s linear 1s 2 reverse forwards paused anim1,\n 1s linear 1s 2 reverse forwards paused anim2,\n 1s linear 1s 2 reverse forwards paused anim3" should not set unrelated longhands
26+
Pass Animation shorthand can not represent non-initial timelines (specified)
27+
Pass Animation shorthand can not represent non-initial timelines (computed)
28+
Fail Animation shorthand can not represent non-initial animation-range-start (specified)
29+
Fail Animation shorthand can not represent non-initial animation-range-start (computed)
30+
Fail Animation shorthand can not represent non-initial animation-range-end (specified)
31+
Fail Animation shorthand can not represent non-initial animation-range-end (computed)
32+
Pass Animation shorthand can not be represented with same list length (specified)
33+
Pass Animation shorthand can be represented with same list length (computed)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
Harness status: OK
2+
3+
Found 44 tests
4+
5+
13 Pass
6+
31 Fail
7+
Pass Property animation-timeline value 'initial'
8+
Pass Property animation-timeline value 'inherit'
9+
Pass Property animation-timeline value 'unset'
10+
Pass Property animation-timeline value 'revert'
11+
Pass Property animation-timeline value 'auto'
12+
Pass Property animation-timeline value 'none'
13+
Fail Property animation-timeline value 'auto, auto'
14+
Fail Property animation-timeline value 'none, none'
15+
Pass Property animation-timeline value 'auto, none'
16+
Pass Property animation-timeline value 'none, auto'
17+
Pass Property animation-timeline value '--test'
18+
Pass Property animation-timeline value '--test1, --test2'
19+
Pass Property animation-timeline value '--test1, --test2, none, --test3, auto'
20+
Pass The animation-timeline property shows up in CSSStyleDeclaration enumeration
21+
Pass The animation-timeline property shows up in CSSStyleDeclaration.cssText
22+
Fail Property animation-timeline value 'scroll()'
23+
Fail Property animation-timeline value 'scroll(block)'
24+
Fail Property animation-timeline value 'scroll(inline)'
25+
Fail Property animation-timeline value 'scroll(x)'
26+
Fail Property animation-timeline value 'scroll(y)'
27+
Fail Property animation-timeline value 'scroll(root)'
28+
Fail Property animation-timeline value 'scroll(nearest)'
29+
Fail Property animation-timeline value 'scroll(self)'
30+
Fail Property animation-timeline value 'scroll(self), scroll(nearest)'
31+
Fail Property animation-timeline value 'scroll(inline nearest)'
32+
Fail Property animation-timeline value 'scroll(nearest inline)'
33+
Fail Property animation-timeline value 'scroll(block self)'
34+
Fail Property animation-timeline value 'scroll(self block)'
35+
Fail Property animation-timeline value 'scroll(y root)'
36+
Fail Property animation-timeline value 'view()'
37+
Fail Property animation-timeline value 'view(block)'
38+
Fail Property animation-timeline value 'view(inline)'
39+
Fail Property animation-timeline value 'view(x)'
40+
Fail Property animation-timeline value 'view(y)'
41+
Fail Property animation-timeline value 'view(y 1px)'
42+
Fail Property animation-timeline value 'view(1px auto)'
43+
Fail Property animation-timeline value 'view(auto 1px)'
44+
Fail Property animation-timeline value 'view(y 1px auto)'
45+
Fail Property animation-timeline value 'view(1px y)'
46+
Fail Property animation-timeline value 'view(y auto)'
47+
Fail Property animation-timeline value 'view(y auto auto)'
48+
Fail Property animation-timeline value 'view(10% 10px)'
49+
Fail Property animation-timeline value 'view(auto calc(1% + 1px))'
50+
Fail Property animation-timeline value 'view(2em calc(1% + 1em))'

0 commit comments

Comments
 (0)