-
Notifications
You must be signed in to change notification settings - Fork 3.3k
/
Copy pathmarker-supported-properties-in-animation.html
405 lines (390 loc) · 9.06 KB
/
marker-supported-properties-in-animation.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Pseudo-Elements Test: Supported properties in ::marker animations</title>
<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#marker-pseudo">
<link rel="help" href="https://drafts.csswg.org/css-animations-1/#keyframes">
<link rel="help" href="https://drafts.csswg.org/css-transitions-1/#transitions">
<link rel="author" title="Oriol Brufau" href="mailto:[email protected]">
<meta name="assert" content="This test checks ::marker supports animations and transitions, but only for the properties that apply to ::marker." />
<style id="style"></style>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<ul>
<li id="target">target</li>
</ul>
<script>
const interpolationTests = [
// ::marker supports all font properties.
{
property: "font",
from: "oblique normal 100 ultra-condensed 5px / 20px serif",
to: "italic small-caps 900 ultra-expanded 25px / 50px Ahem",
midPoint: ["italic small-caps 500 expanded 15px / 35px Ahem", "italic small-caps 500 expanded 15px/35px Ahem"],
},
{
property: "font-family",
from: "serif",
to: "Ahem",
midPoint: "Ahem",
},
{
property: "font-feature-settings",
from: "'c2sc'",
to: "'smcp'",
midPoint: "\"smcp\"",
},
{
property: "font-kerning",
from: "normal",
to: "none",
midPoint: "none",
},
{
property: "font-size",
from: "5px",
to: "25px",
midPoint: "15px",
},
{
property: "font-size-adjust",
from: "1",
to: "3",
midPoint: "2",
},
{
property: "font-stretch",
from: "ultra-condensed",
to: "ultra-expanded",
midPoint: ["expanded", "125%"],
},
{
property: "font-style",
from: "oblique",
to: "italic",
midPoint: "italic",
},
{
property: "font-synthesis",
from: "weight",
to: "none",
midPoint: "none",
},
{
property: "font-synthesis-small-caps",
from: "auto",
to: "none",
midPoint: "none",
},
{
property: "font-synthesis-style",
from: "auto",
to: "none",
midPoint: "none",
},
{
property: "font-synthesis-weight",
from: "auto",
to: "none",
midPoint: "none",
},
{
property: "font-variant",
from: "unicase",
to: "small-caps",
midPoint: "small-caps",
},
{
property: "font-variant-caps",
from: "unicase",
to: "small-caps",
midPoint: "small-caps",
},
{
property: "font-variant-east-asian",
from: "proportional-width",
to: "full-width",
midPoint: "full-width",
},
{
property: "font-variant-ligatures",
from: "no-historical-ligatures",
to: "historical-ligatures",
midPoint: "historical-ligatures",
},
{
property: "font-variant-numeric",
from: "ordinal",
to: "slashed-zero",
midPoint: "slashed-zero",
},
{
property: "font-variant-position",
from: "super",
to: "sub",
midPoint: "sub",
},
{
property: "font-weight",
from: "100",
to: "900",
midPoint: "500",
},
// `line-height` is not a font property but is a longhand of `font`, and is also supported.
{
property: "line-height",
from: "20px",
to: "50px",
midPoint: "35px",
},
// ::marker supports `white-space`
{
property: "white-space",
from: "pre-line",
to: "nowrap",
midPoint: "nowrap",
},
// ::marker supports `color`
{
property: "color",
from: "rgb(0, 100, 200)",
to: "rgb(100, 200, 0)",
midPoint: "rgb(50, 150, 100)",
},
// ::marker supports `text-combine-upright`, `unicode-bidi` and `direction`,
// but they are not animatable.
{
property: "text-combine-upright",
from: "all",
to: "all",
midPoint: null,
},
{
property: "unicode-bidi",
from: "embed",
to: "plaintext",
midPoint: null,
},
{
property: "direction",
from: "rtl",
to: "rtl",
midPoint: null,
},
// ::marker supports `content`
{
property: "content",
from: "'foo'",
to: "'bar'",
midPoint: "\"bar\"",
},
// ::marker supports text properties.
{
property: "hyphens",
from: "manual",
to: "none",
midPoint: "none",
},
{
property: "letter-spacing",
from: "0px",
to: "20px",
midPoint: "10px",
},
{
property: "line-break",
from: "strict",
to: "anywhere",
midPoint: "anywhere",
},
{
property: "overflow-wrap",
from: "break-word",
to: "anywhere",
midPoint: "anywhere",
},
{
property: "tab-size",
from: "0px",
to: "20px",
midPoint: "10px",
},
{
property: "text-transform",
from: "lowercase",
to: "uppercase",
midPoint: "uppercase",
},
{
property: "word-break",
from: "break-all",
to: "break-word",
midPoint: "break-word",
},
{
property: "word-spacing",
from: "0px",
to: "20px",
midPoint: "10px",
},
// ::marker supports inherited text decoration properties.
{
property: "text-decoration-skip-ink",
from: "auto",
to: "none",
midPoint: "none",
},
{
property: "text-emphasis",
from: "dot rgb(0, 200, 0)",
to: "triangle rgb(100, 0, 200)",
midPoint: "triangle rgb(50, 100, 100)",
},
{
property: "text-emphasis-color",
from: "rgb(0, 200, 0)",
to: "rgb(100, 0, 200)",
midPoint: "rgb(50, 100, 100)",
},
{
property: "text-emphasis-position",
from: "over right",
to: "under left",
midPoint: "under left",
},
{
property: "text-emphasis-style",
from: "filled dot",
to: "filled triangle",
midPoint: "triangle",
},
{
property: "text-shadow",
from: "rgb(0, 200, 0) 1px 2px 3px",
to: "rgb(100, 0, 200) 3px 2px 1px",
midPoint: "rgb(50, 100, 100) 2px 2px 2px",
},
// ::marker supports `cursor`.
{
property: "cursor",
from: "auto",
to: "move",
midPoint: "move",
},
// ::marker does NOT support layout properties
{
property: "display",
from: "flex",
to: "none",
midPoint: ["block", "inline", "inline-block"],
},
{
property: "position",
from: "fixed",
to: "absolute",
midPoint: "static",
},
{
property: "float",
from: "left",
to: "right",
midPoint: "none",
},
// ::marker does NOT support list properties despite being affected by them,
// they apply to the list item instead.
{
property: "list-style",
from: "inside url('foo') square",
to: "inside url('bar') decimal",
midPoint: "outside none disc",
},
{
property: "list-style-image",
from: "url('foo')",
to: "url('bar')",
midPoint: "none",
},
{
property: "list-style-position",
from: "inside",
to: "inside",
midPoint: "outside",
},
{
property: "list-style-type",
from: "square",
to: "decimal",
midPoint: "disc",
},
];
const target = document.getElementById("target");
const styleElement = document.getElementById("style");
const markerStyle = getComputedStyle(target, "::marker");
function check({property, from, to, midPoint}) {
assert_true(property in markerStyle, property + " doesn't seem to be supported in the computed style");
assert_true(CSS.supports(property, from), `'${from}' is a supported value for ${property}.`);
assert_true(CSS.supports(property, to), `'${to}' is a supported value for ${property}.`);
const computed = markerStyle.getPropertyValue(property);
if (Array.isArray(midPoint)) {
assert_in_array(computed, midPoint);
} else {
assert_equals(computed, midPoint);
}
}
function testAnimations(interpolationTests) {
styleElement.textContent = `
::marker {
animation: anim 2s -1s paused linear;
}
@keyframes anim {
from {}
to {}
}
`;
const keyframes = styleElement.sheet.cssRules[1];
const fromStyle = keyframes.cssRules[0].style;
const toStyle = keyframes.cssRules[1].style;
for (let {property, from, to, midPoint} of interpolationTests) {
fromStyle.cssText = "";
toStyle.cssText = "";
if (midPoint == null) {
midPoint = markerStyle.getPropertyValue(property);
}
fromStyle.setProperty(property, from);
toStyle.setProperty(property, to);
test(() => {
check({property, from, to, midPoint});
}, `Animation of ${property} in ::marker`);
}
}
function testTransitions(interpolationTests) {
styleElement.textContent = `
.transition::marker {
transition: all 2s -1s linear;
}
.from::marker {}
.to::marker {}
`;
const fromStyle = styleElement.sheet.cssRules[1].style;
const toStyle = styleElement.sheet.cssRules[2].style;
for (let {property, from, to, midPoint} of interpolationTests) {
fromStyle.cssText = "";
toStyle.cssText = "";
if (midPoint == null) {
midPoint = to;
}
fromStyle.setProperty(property, from);
toStyle.setProperty(property, to);
target.className = "from";
markerStyle.width;
target.classList.add("transition");
markerStyle.width;
target.classList.add("to");
test(() => {
check({property, from, to, midPoint});
}, `Transition of ${property} in ::marker`);
}
}
testAnimations(interpolationTests);
testTransitions(interpolationTests);
</script>