-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Expand file tree
/
Copy pathshape-outside-interpolation.html
More file actions
250 lines (225 loc) · 8.06 KB
/
Copy pathshape-outside-interpolation.html
File metadata and controls
250 lines (225 loc) · 8.06 KB
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
<!DOCTYPE html>
<meta charset="UTF-8">
<title>shape-outside interpolation</title>
<link rel="help" href="https://drafts.csswg.org/css-shapes/#shape-outside-property">
<meta name="assert" content="shape-outside supports animation as <basic-shape> or discrete">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/interpolation-testcommon.js"></script>
<style>
.parent {
shape-outside: circle(80% at 30% 10%);
}
.target {
shape-outside: circle(60% at 10% 30%);
}
</style>
<body></body>
<script>
/* TODO: add inset test once blend() works for it */
test_interpolation({
property: 'shape-outside',
from: neutralKeyframe,
to: 'circle(40% at 20% 20%)',
}, [
{at: -0.3, expect: 'circle(66% at 7% 33%)'},
{at: 0, expect: 'circle(60% at 10% 30%)'},
{at: 0.3, expect: 'circle(54% at 13% 27%)'},
{at: 0.6, expect: 'circle(48% at 16% 24%)'},
{at: 1, expect: 'circle(40% at 20% 20%)'},
{at: 1.5, expect: 'circle(30% at 25% 15%)'},
]);
test_no_interpolation({
property: 'shape-outside',
from: 'initial',
to: 'circle(40% at 20% 20%)',
});
test_interpolation({
property: 'shape-outside',
from: 'inherit',
to: 'circle(40% at 20% 20%)',
}, [
{at: -0.3, expect: 'circle(92% at 33% 7%)'},
{at: 0, expect: 'circle(80% at 30% 10%)'},
{at: 0.3, expect: 'circle(68% at 27% 13%)'},
{at: 0.6, expect: 'circle(56% at 24% 16%)'},
{at: 1, expect: 'circle(40% at 20% 20%)'},
{at: 1.5, expect: 'circle(20% at 15% 25%)'},
]);
test_no_interpolation({
property: 'shape-outside',
from: 'unset',
to: 'circle(40% at 20% 20%)',
});
test_interpolation({
property: 'shape-outside',
from: 'circle(100% at 0% 0%)',
to: 'circle(50% at 25% 25%)',
}, [
{at: -0.3, expect: 'circle(115% at -7.5% -7.5%)'},
{at: 0, expect: 'circle(100% at 0% 0%)'},
{at: 0.3, expect: 'circle(85% at 7.5% 7.5%)'},
{at: 0.6, expect: 'circle(70% at 15% 15%)'},
{at: 1, expect: 'circle(50% at 25% 25%)'},
{at: 1.5, expect: 'circle(25% at 37.5% 37.5%)'}
]);
test_interpolation({
property: 'shape-outside',
from: 'ellipse(100% 100% at 0% 0%)',
to: 'ellipse(50% 50% at 25% 25%)',
}, [
{at: -0.3, expect: 'ellipse(115% 115% at -7.5% -7.5%)'},
{at: 0, expect: 'ellipse(100% 100% at 0% 0%)'},
{at: 0.3, expect: 'ellipse(85% 85% at 7.5% 7.5%)'},
{at: 0.6, expect: 'ellipse(70% 70% at 15% 15%)'},
{at: 1, expect: 'ellipse(50% 50% at 25% 25%)'},
{at: 1.5, expect: 'ellipse(25% 25% at 37.5% 37.5%)'}
]);
test_interpolation({
property: 'shape-outside',
from: 'polygon(nonzero, 0px 0px, 25px 25px, 50px 50px)',
to: 'polygon(nonzero, 25px 25px, 50px 50px, 75px 75px)',
}, [
{at: -0.3, expect: 'polygon(nonzero, -7.5px -7.5px, 17.5px 17.5px, 42.5px 42.5px)'},
{at: 0, expect: 'polygon(nonzero, 0px 0px, 25px 25px, 50px 50px)'},
{at: 0.3, expect: 'polygon(nonzero, 7.5px 7.5px, 32.5px 32.5px, 57.5px 57.5px)'},
{at: 0.6, expect: 'polygon(nonzero, 15px 15px, 40px 40px, 65px 65px)'},
{at: 1, expect: 'polygon(nonzero, 25px 25px, 50px 50px, 75px 75px)'},
{at: 1.5, expect: 'polygon(nonzero, 37.5px 37.5px, 62.5px 62.5px, 87.5px 87.5px)'}
]);
test_no_interpolation({
property: 'shape-outside',
from: 'polygon(evenodd, 0px 0px, 25px 25px, 50px 50px)',
to: 'polygon(nonzero, 25px 25px, 50px 50px, 75px 75px)',
});
test_interpolation({
property: 'shape-outside',
from: 'polygon(round 10px, 0px 0px, 100px 0px, 100px 100px)',
to: 'polygon(round 30px, 50px 50px, 150px 50px, 150px 150px)',
}, [
{at: -0.3, expect: 'polygon(round 4px, -15px -15px, 85px -15px, 85px 85px)'},
{at: 0, expect: 'polygon(round 10px, 0px 0px, 100px 0px, 100px 100px)'},
{at: 0.3, expect: 'polygon(round 16px, 15px 15px, 115px 15px, 115px 115px)'},
{at: 0.6, expect: 'polygon(round 22px, 30px 30px, 130px 30px, 130px 130px)'},
{at: 1, expect: 'polygon(round 30px, 50px 50px, 150px 50px, 150px 150px)'},
{at: 1.5, expect: 'polygon(round 40px, 75px 75px, 175px 75px, 175px 175px)'},
]);
test_interpolation({
property: 'shape-outside',
from: 'polygon(round 0px, 0px 0px, 100px 0px, 100px 100px)',
to: 'polygon(round 20px, 0px 0px, 100px 0px, 100px 100px)',
}, [
{at: 0, expect: 'polygon(0px 0px, 100px 0px, 100px 100px)'},
{at: 0.5, expect: 'polygon(round 10px, 0px 0px, 100px 0px, 100px 100px)'},
{at: 1, expect: 'polygon(round 20px, 0px 0px, 100px 0px, 100px 100px)'},
]);
test_interpolation({
property: 'shape-outside',
from: 'polygon(0px 0px, 100px 0px, 100px 100px)',
to: 'polygon(round 20px, 0px 0px, 100px 0px, 100px 100px)',
}, [
{at: 0, expect: 'polygon(0px 0px, 100px 0px, 100px 100px)'},
{at: 0.5, expect: 'polygon(round 10px, 0px 0px, 100px 0px, 100px 100px)'},
{at: 1, expect: 'polygon(round 20px, 0px 0px, 100px 0px, 100px 100px)'},
]);
test_interpolation({
property: 'shape-outside',
from: 'inset(100%)',
to: 'inset(120%)',
}, [
{at: -0.3, expect: 'inset(94%)'},
{at: 0, expect: 'inset(100%)'},
{at: 0.3, expect: 'inset(106%)'},
{at: 0.6, expect: 'inset(112%)'},
{at: 1, expect: 'inset(120%)'},
{at: 1.5, expect: 'inset(130%)'},
]);
// All <basic-shape-rect> functions (inset, rect, xywh) compute to the
// equivalent inset() and interpolate identically. Exercise every
// from/to combination of the three syntaxes, with and without a
// matching <shape-box>. A and B below describe the same rectangle in
// all three forms (per side: A = top 10%, right 20%, bottom 30%,
// left 40%; B = top 50%, right 20%, bottom 30%, left 20%).
for (const box of ['', ' border-box']) {
const A = {
inset: 'inset(10% 20% 30% 40%)' + box,
rect: 'rect(10% 80% 70% 40%)' + box,
xywh: 'xywh(40% 10% 40% 60%)' + box,
};
const B = {
inset: 'inset(50% 20% 30% 20%)' + box,
rect: 'rect(50% 80% 70% 20%)' + box,
xywh: 'xywh(20% 50% 60% 20%)' + box,
};
const expectations = [
{at: 0, expect: 'inset(10% 20% 30% 40%)' + box},
{at: 0.5, expect: 'inset(30% 20% 30% 30%)' + box},
{at: 1, expect: 'inset(50% 20% 30% 20%)' + box},
];
for (const fromForm of ['inset', 'rect', 'xywh']) {
for (const toForm of ['inset', 'rect', 'xywh']) {
test_interpolation({
property: 'shape-outside',
from: A[fromForm],
to: B[toForm],
}, expectations);
}
}
}
// Mixed forms with a round radius (not covered by the loop above).
test_interpolation({
property: 'shape-outside',
from: 'xywh(0px 10% 100px 40% round 20px)',
to: 'rect(20% 50% 200px 20px)',
}, [
{at: 0, expect: 'inset(10% calc(100% - 100px) 50% 0px round 20px)'},
{at: 0.5, expect: 'inset(15% calc(75% - 50px) calc(75% - 100px) 10px round 10px)'},
{at: 1, expect: 'inset(20% 50% calc(100% - 200px) 20px)'},
]);
test_no_interpolation({
property: 'shape-outside',
from: 'none',
to: 'ellipse(100% 100% at 0% 0%)',
});
// TODO: add intermediate keyframe tests when CSS shapes position computed values are cleaned up
test_interpolation({
property: 'shape-outside',
from: 'circle(25% at right 5% bottom 15px)',
to: 'circle(45% at right 25% bottom 35px)',
}, [
{at: 0.25, expect: 'circle(30% at 90% calc(-20px + 100%))'},
{at: 0.5, expect: 'circle(35% at 85% calc(-25px + 100%))'},
{at: 0.75, expect: 'circle(40% at 80% calc(-30px + 100%))'},
]);
// Other shapes also interpolate when both endpoints carry the same <shape-box>.
test_interpolation({
property: 'shape-outside',
from: 'circle(20% at 10% 10%) border-box',
to: 'circle(40% at 30% 30%) border-box',
}, [
{at: 0, expect: 'circle(20% at 10% 10%) border-box'},
{at: 0.5, expect: 'circle(30% at 20% 20%) border-box'},
{at: 1, expect: 'circle(40% at 30% 30%) border-box'},
]);
// Mismatched or missing <shape-box> is discrete.
test_no_interpolation({
property: 'shape-outside',
from: 'inset(10px) border-box',
to: 'inset(30px) padding-box',
});
test_no_interpolation({
property: 'shape-outside',
from: 'inset(10px)',
to: 'inset(30px) border-box',
});
test_no_interpolation({
property: 'shape-outside',
from: 'rect(10px 90px 90px 10px) border-box',
to: 'rect(30px 70px 70px 30px) padding-box',
});
test_no_interpolation({
property: 'shape-outside',
from: 'xywh(10px 10px 80px 80px) padding-box',
to: 'xywh(30px 30px 40px 40px) content-box',
});
</script>