summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-break/hit-test-inline-fragmentation-with-border-radius.html
blob: 4d0fc7eccc45e44480b4305632ceac2068c59919 (plain)
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
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="https://www.w3.org/TR/css-break-3/#break-decoration"/>
<style>
div {
  margin: 20px;
}

span.round {
  padding: 20px;
  line-height: 100px;
  font-size: 40px;
  border-radius: 40px;
  background-color: yellow;
}
</style>

<div>
<span id="horizontal" class="round">FOO<br>BAR</span>
</div>

<div style="writing-mode:vertical-lr">
<span id="vertical-lr" class="round">FOO<br>BAR</span>
</div>

<div style="writing-mode:vertical-rl">
<span id="vertical-rl" class="round">FOO<br>BAR</span>
</div>

<script>
// Hit test horizontal span with border radius
const horizontalSpan = document.getElementById('horizontal');
const horizontalDiv = horizontalSpan.parentNode;
const horizontalRects = horizontalSpan.getClientRects();
const horizontalLine1 = horizontalRects[0];
const horizontalLine2 = horizontalRects[1];

test(() => {
  const x = horizontalLine1.left + 5;
  const y = horizontalLine1.top + 5;
  assert_equals(document.elementFromPoint(x, y), horizontalDiv);
}, 'Horizontal line 1, hit test outside top-left rounded corner');

test(() => {
  const x = horizontalLine1.left + 20;
  const y = horizontalLine1.top + 20;
  assert_equals(document.elementFromPoint(x, y), horizontalSpan);
}, 'Horizontal line 1, hit test inside top-left rounded corner');

test(() => {
  const x = horizontalLine1.left + 5;
  const y = horizontalLine1.bottom - 5;
  assert_equals(document.elementFromPoint(x, y), horizontalDiv);
}, 'Horizontal line 1, hit test outside bottom-left rounded corner');

test(() => {
  const x = horizontalLine1.left + 20;
  const y = horizontalLine1.bottom - 20;
  assert_equals(document.elementFromPoint(x, y), horizontalSpan);
}, 'Horizontal line 1, hit test inside bottom-left rounded corner');

test(() => {
  const x = horizontalLine1.right - 5;
  const y = horizontalLine1.top + 5;
  assert_equals(document.elementFromPoint(x, y), horizontalSpan);
}, 'Horizontal line 1, hit test inside top-right right-angled corner')

test(() => {
  const x = horizontalLine1.right - 5;
  const y = horizontalLine1.bottom - 5;
  assert_equals(document.elementFromPoint(x, y), horizontalSpan);
}, 'Horizontal line 1, hit test inside bottom-right right-angled corner')

test(() => {
  const x = horizontalLine2.right - 5;
  const y = horizontalLine2.top + 5;
  assert_equals(document.elementFromPoint(x, y), horizontalDiv);
}, 'Horizontal line 2, hit test outside top-right rounded corner');

test(() => {
  const x = horizontalLine2.right - 20;
  const y = horizontalLine2.top + 20;
  assert_equals(document.elementFromPoint(x, y), horizontalSpan);
}, 'Horizontal line 2, hit test inside top-right rounded corner');

test(() => {
  const x = horizontalLine2.right - 5;
  const y = horizontalLine2.bottom - 5;
  assert_equals(document.elementFromPoint(x, y), horizontalDiv);
}, 'Horizontal line 2, hit test outside bottom-right rounded corner');

test(() => {
  const x = horizontalLine2.right - 20;
  const y = horizontalLine2.bottom - 20;
  assert_equals(document.elementFromPoint(x, y), horizontalSpan);
}, 'Horizontal line 2, hit test inside bottom-right rounded corner');

test(() => {
  const x = horizontalLine2.left + 5;
  const y = horizontalLine2.top + 5;
  assert_equals(document.elementFromPoint(x, y), horizontalSpan);
}, 'Horizontal line 2, hit test inside top-left right-angled corner')

test(() => {
  const x = horizontalLine2.left + 5;
  const y = horizontalLine2.bottom - 5;
  assert_equals(document.elementFromPoint(x, y), horizontalSpan);
}, 'Horizontal line 2, hit test inside bottom-left right-angled corner')

// Hit test vertical-lr span with border radius
const verticalLRSpan = document.getElementById('vertical-lr');
const verticalLRDiv = verticalLRSpan.parentNode;
const verticalLRRects = verticalLRSpan.getClientRects();
const verticalLRLine1 = verticalLRRects[0];
const verticalLRLine2 = verticalLRRects[1];

test(() => {
  const x = verticalLRLine1.left + 5;
  const y = verticalLRLine1.top + 5;
  assert_equals(document.elementFromPoint(x, y), verticalLRDiv);
}, 'Vertical LR line 1, hit test outside top-left rounded corner');

test(() => {
  const x = verticalLRLine1.left + 20;
  const y = verticalLRLine1.top + 20;
  assert_equals(document.elementFromPoint(x, y), verticalLRSpan);
}, 'Vertical LR line 1, hit test inside top-left rounded corner');

test(() => {
  const x = verticalLRLine1.right - 5;
  const y = verticalLRLine1.top + 5;
  assert_equals(document.elementFromPoint(x, y), verticalLRDiv);
}, 'Vertical LR line 1, hit test outside top-right rounded corner');

test(() => {
  const x = verticalLRLine1.right - 20;
  const y = verticalLRLine1.top + 20;
  assert_equals(document.elementFromPoint(x, y), verticalLRSpan);
}, 'Vertical LR line 1, hit test inside top-right rounded corner');

test(() => {
  const x = verticalLRLine1.left + 5;
  const y = verticalLRLine1.bottom - 5;
  assert_equals(document.elementFromPoint(x, y), verticalLRSpan);
}, 'Vertical LR line 1, hit test inside bottom-left right-angled corner')

test(() => {
  const x = verticalLRLine1.right - 5;
  const y = verticalLRLine1.bottom - 5;
  assert_equals(document.elementFromPoint(x, y), verticalLRSpan);
}, 'Vertical LR line 1, hit test inside bottom-right right-angled corner')

test(() => {
  const x = verticalLRLine2.left + 5;
  const y = verticalLRLine2.bottom - 5;
  assert_equals(document.elementFromPoint(x, y), verticalLRDiv);
}, 'Vertical LR line 2, hit test outside bottom-left rounded corner');

test(() => {
  const x = verticalLRLine2.left + 20;
  const y = verticalLRLine2.bottom - 20;
  assert_equals(document.elementFromPoint(x, y), verticalLRSpan);
}, 'Vertical LR line 2, hit test inside bottom-left rounded corner');

test(() => {
  const x = verticalLRLine2.right - 5;
  const y = verticalLRLine2.bottom - 5;
  assert_equals(document.elementFromPoint(x, y), verticalLRDiv);
}, 'Vertical LR line 2, hit test outside bottom-right rounded corner');

test(() => {
  const x = verticalLRLine2.right - 20;
  const y = verticalLRLine2.bottom - 20;
  assert_equals(document.elementFromPoint(x, y), verticalLRSpan);
}, 'Vertical LR line 2, hit test inside bottom-right rounded corner');

test(() => {
  const x = verticalLRLine2.left + 5;
  const y = verticalLRLine2.top + 5;
  assert_equals(document.elementFromPoint(x, y), verticalLRSpan);
}, 'Vertical LR line 2, hit test inside top-left right-angled corner')

test(() => {
  const x = verticalLRLine2.right - 5;
  const y = verticalLRLine2.top + 5;
  assert_equals(document.elementFromPoint(x, y), verticalLRSpan);
}, 'Vertical LR line 2, hit test inside top-right right-angled corner')

// Hit test vertical-rl span with border radius
const verticalRLSpan = document.getElementById('vertical-rl');
const verticalRLDiv = verticalRLSpan.parentNode;
const verticalRLRects = verticalRLSpan.getClientRects();
const verticalRLLine1 = verticalRLRects[0].left > verticalRLRects[1].left ? verticalRLRects[0] : verticalRLRects[1];
const verticalRLLine2 = verticalRLRects[0].left > verticalRLRects[1].left ? verticalRLRects[1] : verticalRLRects[0];

test(() => {
  const x = verticalRLLine1.left + 5;
  const y = verticalRLLine1.top + 5;
  assert_equals(document.elementFromPoint(x, y), verticalRLDiv);
}, 'Vertical RL line 1, hit test outside top-left rounded corner');

test(() => {
  const x = verticalRLLine1.left + 20;
  const y = verticalRLLine1.top + 20;
  assert_equals(document.elementFromPoint(x, y), verticalRLSpan);
}, 'Vertical RL line 1, hit test inside top-left rounded corner');

test(() => {
  const x = verticalRLLine1.right - 5;
  const y = verticalRLLine1.top + 5;
  assert_equals(document.elementFromPoint(x, y), verticalRLDiv);
}, 'Vertical RL line 1, hit test outside top-right rounded corner');

test(() => {
  const x = verticalRLLine1.right - 20;
  const y = verticalRLLine1.top + 20;
  assert_equals(document.elementFromPoint(x, y), verticalRLSpan);
}, 'Vertical RL line 1, hit test inside top-right rounded corner');

test(() => {
  const x = verticalRLLine1.left + 5;
  const y = verticalRLLine1.bottom - 5;
  assert_equals(document.elementFromPoint(x, y), verticalRLSpan);
}, 'Vertical RL line 1, hit test inside bottom-left right-angled corner')

test(() => {
  const x = verticalRLLine1.right - 5;
  const y = verticalRLLine1.bottom - 5;
  assert_equals(document.elementFromPoint(x, y), verticalRLSpan);
}, 'Vertical RL line 1, hit test inside bottom-right right-angled corner')

test(() => {
  const x = verticalRLLine2.left + 5;
  const y = verticalRLLine2.bottom - 5;
  assert_equals(document.elementFromPoint(x, y), verticalRLDiv);
}, 'Vertical RL line 2, hit test outside bottom-left rounded corner');

test(() => {
  const x = verticalRLLine2.left + 20;
  const y = verticalRLLine2.bottom - 20;
  assert_equals(document.elementFromPoint(x, y), verticalRLSpan);
}, 'Vertical RL line 2, hit test inside bottom-left rounded corner');

test(() => {
  const x = verticalRLLine2.right - 5;
  const y = verticalRLLine2.bottom - 5;
  assert_equals(document.elementFromPoint(x, y), verticalRLDiv);
}, 'Vertical RL line 2, hit test outside bottom-right rounded corner');

test(() => {
  const x = verticalRLLine2.right - 20;
  const y = verticalRLLine2.bottom - 20;
  assert_equals(document.elementFromPoint(x, y), verticalRLSpan);
}, 'Vertical RL line 2, hit test inside bottom-right rounded corner');

test(() => {
  const x = verticalRLLine2.left + 5;
  const y = verticalRLLine2.top + 5;
  assert_equals(document.elementFromPoint(x, y), verticalRLSpan);
}, 'Vertical RL line 2, hit test inside top-left right-angled corner')

test(() => {
  const x = verticalRLLine2.right - 5;
  const y = verticalRLLine2.top + 5;
  assert_equals(document.elementFromPoint(x, y), verticalRLSpan);
}, 'Vertical RL line 2, hit test inside top-right right-angled corner')
</script>