summaryrefslogtreecommitdiffstats
path: root/gfx/layers/apz/test/mochitest/helper_hittest_touchaction.html
blob: acabfcc07bfe2e05bdc47047275c6c99e9e6619c (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
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
<!DOCTYPE HTML>
<html>
<head>
  <title>Testing APZ hit-test with touch-action boxes</title>
  <script type="application/javascript" src="apz_test_utils.js"></script>
  <script type="application/javascript" src="apz_test_native_event_utils.js"></script>
  <script src="/tests/SimpleTest/paint_listener.js"></script>
  <meta name="viewport" content="width=device-width"/>
  <style>
.taBox {
    width: 20px;
    height: 20px;
    background-color: green;
    display: inline-block;
}
.taBox > div {
    /* make sure this doesn't obscure the center of the enclosing taBox */
    width: 5px;
    height: 5px;
    background-color: blue;
}

.taBigBox {
    width: 150px;
    height: 150px;
    background-color: green;
    display: inline-block;
}
.taBigBox > div {
    width: 40px;
    height: 40px;
    overflow: auto;
}
.taBigBox > div > div {
    width: 100px;
    height: 100px;
}
  </style>
</head>
<body>
<!-- Create a bunch of divs for hit-testing. Some of the divs also
    contain nested divs to test inheritance/combination of touch-action
    properties. This is not an exhaustive list of all the possible
    combinations but it's assorted enough to provide good coverage. -->
 <div id="taNone" class="taBox" style="touch-action: none">
  <div id="taInnerNonePanX" style="touch-action: pan-x"></div>
  <div id="taInnerNoneManip" style="touch-action: manipulation"></div>
 </div>
 <div id="taPanX" class="taBox" style="touch-action: pan-x">
  <div id="taInnerPanXY" style="touch-action: pan-y"></div>
  <div id="taInnerPanXManip" style="touch-action: manipulation"></div>
 </div>
 <div id="taPanY" class="taBox" style="touch-action: pan-y">
  <div id="taInnerPanYX" style="touch-action: pan-x"></div>
  <div id="taInnerPanYY" style="touch-action: pan-y"></div>
 </div>
 <div id="taPanXY" class="taBox" style="touch-action: pan-x pan-y">
  <div id="taInnerPanXYNone" style="touch-action: none"></div>
 </div>
 <div id="taManip" class="taBox" style="touch-action: manipulation">
  <div id="taInnerManipPanX" style="touch-action: pan-x"></div>
  <div id="taInnerManipNone" style="touch-action: none"></div>
  <div id="taInnerManipListener" ontouchstart="return false;"></div>
 </div>
 <div id="taListener" class="taBox" ontouchstart="return false;">
  <div id="taInnerListenerPanX" style="touch-action: pan-x"></div>
 </div>
 <div id="taPinchZoom" class="taBox" style="touch-action: pinch-zoom">
 </div>

 <br/>

 <!-- More divs for hit-testing. These comprise one big outer div with
     a touch-action property, then inside is a scrollable div, possibly with
     a touch-action of its own, and inside that is another div to make the
     scrollable div scrollable. Note that the touch-action for an element
     includes the restrictions from all ancestor elements up to and including
     the element that has the default action for that touch-action property.
     Panning actions therefore get inherited from the nearest scrollframe
     downwards, while zooming actions get inherited from the root content
     element (because that's the only one that has zooming as the default action)
     downwards. In effect, any pan restrictions on the outer div should not
     apply to the inner div, but zooming restrictions should. Also, the
     touch-action on the scrollable div itself should apply to user interaction
     inside the scrollable div. -->
 <div id="taOuterPanX" class="taBigBox" style="touch-action: pan-x">
  <div id="taScrollerPanY" style="touch-action: pan-y">
   <div></div>
  </div>
  <div id="taScroller">
   <div style="touch-action: pan-y"></div>
  </div>
  <div id="taScroller2">
   <div></div>
  </div>
 </div>
 <div id="taOuterManipulation" class="taBigBox" style="touch-action: manipulation">
  <div id="taScrollerPanX" style="touch-action: pan-x">
   <div></div>
  </div>
  <div id="taScroller3">
   <div></div>
  </div>
  <div id="taScroller4" style="touch-action: pan-y">
   <div style="overflow:hidden"></div>
  </div>
 </div>
</body>
<script type="application/javascript">

var config = getHitTestConfig();

async function test() {
  for (var scroller of document.querySelectorAll(".taBigBox > div")) {
    // layerize all the scrollable divs
    config.utils.setDisplayPortForElement(0, 0, 100, 100, scroller, 1);
  }
  await promiseApzFlushedRepaints();

  var scrollId = config.utils.getViewId(document.scrollingElement);
  var layersId = config.utils.getLayersId();

  checkHitResult(
      hitTest(centerOf("taNone")),
      APZHitResultFlags.VISIBLE |
      APZHitResultFlags.PAN_X_DISABLED |
      APZHitResultFlags.PAN_Y_DISABLED |
      APZHitResultFlags.PINCH_ZOOM_DISABLED |
      APZHitResultFlags.DOUBLE_TAP_ZOOM_DISABLED,
      scrollId,
      layersId,
      "touch-action: none");
  checkHitResult(
      hitTest(centerOf("taInnerNonePanX")),
      APZHitResultFlags.VISIBLE |
      APZHitResultFlags.PAN_X_DISABLED |
      APZHitResultFlags.PAN_Y_DISABLED |
      APZHitResultFlags.PINCH_ZOOM_DISABLED |
      APZHitResultFlags.DOUBLE_TAP_ZOOM_DISABLED,
      scrollId,
      layersId,
      "touch-action: pan-x inside touch-action: none");
  checkHitResult(
      hitTest(centerOf("taInnerNoneManip")),
      APZHitResultFlags.VISIBLE |
      APZHitResultFlags.PAN_X_DISABLED |
      APZHitResultFlags.PAN_Y_DISABLED |
      APZHitResultFlags.PINCH_ZOOM_DISABLED |
      APZHitResultFlags.DOUBLE_TAP_ZOOM_DISABLED,
      scrollId,
      layersId,
      "touch-action: manipulation inside touch-action: none");

  checkHitResult(
      hitTest(centerOf("taPanX")),
      APZHitResultFlags.VISIBLE |
      APZHitResultFlags.PAN_Y_DISABLED |
      APZHitResultFlags.PINCH_ZOOM_DISABLED |
      APZHitResultFlags.DOUBLE_TAP_ZOOM_DISABLED,
      scrollId,
      layersId,
      "touch-action: pan-x");
  checkHitResult(
      hitTest(centerOf("taInnerPanXY")),
      APZHitResultFlags.VISIBLE |
      APZHitResultFlags.PAN_X_DISABLED |
      APZHitResultFlags.PAN_Y_DISABLED |
      APZHitResultFlags.PINCH_ZOOM_DISABLED |
      APZHitResultFlags.DOUBLE_TAP_ZOOM_DISABLED,
      scrollId,
      layersId,
      "touch-action: pan-y inside touch-action: pan-x");
  checkHitResult(
      hitTest(centerOf("taInnerPanXManip")),
      APZHitResultFlags.VISIBLE |
      APZHitResultFlags.PAN_Y_DISABLED |
      APZHitResultFlags.PINCH_ZOOM_DISABLED |
      APZHitResultFlags.DOUBLE_TAP_ZOOM_DISABLED,
      scrollId,
      layersId,
      "touch-action: manipulation inside touch-action: pan-x");

  checkHitResult(
      hitTest(centerOf("taPanY")),
      APZHitResultFlags.VISIBLE |
      APZHitResultFlags.PAN_X_DISABLED |
      APZHitResultFlags.PINCH_ZOOM_DISABLED |
      APZHitResultFlags.DOUBLE_TAP_ZOOM_DISABLED,
      scrollId,
      layersId,
      "touch-action: pan-y");
  checkHitResult(
      hitTest(centerOf("taInnerPanYX")),
      APZHitResultFlags.VISIBLE |
      APZHitResultFlags.PAN_X_DISABLED |
      APZHitResultFlags.PAN_Y_DISABLED |
      APZHitResultFlags.PINCH_ZOOM_DISABLED |
      APZHitResultFlags.DOUBLE_TAP_ZOOM_DISABLED,
      scrollId,
      layersId,
      "touch-action: pan-x inside touch-action: pan-y");
  checkHitResult(
      hitTest(centerOf("taInnerPanYY")),
      APZHitResultFlags.VISIBLE |
      APZHitResultFlags.PAN_X_DISABLED |
      APZHitResultFlags.PINCH_ZOOM_DISABLED |
      APZHitResultFlags.DOUBLE_TAP_ZOOM_DISABLED,
      scrollId,
      layersId,
      "touch-action: pan-y inside touch-action: pan-y");

  checkHitResult(
      hitTest(centerOf("taPanXY")),
      APZHitResultFlags.VISIBLE |
      APZHitResultFlags.PINCH_ZOOM_DISABLED |
      APZHitResultFlags.DOUBLE_TAP_ZOOM_DISABLED,
      scrollId,
      layersId,
      "touch-action: pan-x pan-y");
  checkHitResult(
      hitTest(centerOf("taInnerPanXYNone")),
      APZHitResultFlags.VISIBLE |
      APZHitResultFlags.PAN_X_DISABLED |
      APZHitResultFlags.PAN_Y_DISABLED |
      APZHitResultFlags.PINCH_ZOOM_DISABLED |
      APZHitResultFlags.DOUBLE_TAP_ZOOM_DISABLED,
      scrollId,
      layersId,
      "touch-action: none inside touch-action: pan-x pan-y");

  checkHitResult(
      hitTest(centerOf("taManip")),
      APZHitResultFlags.VISIBLE |
      APZHitResultFlags.DOUBLE_TAP_ZOOM_DISABLED,
      scrollId,
      layersId,
      "touch-action: manipulation");
  checkHitResult(
      hitTest(centerOf("taInnerManipPanX")),
      APZHitResultFlags.VISIBLE |
      APZHitResultFlags.PAN_Y_DISABLED |
      APZHitResultFlags.PINCH_ZOOM_DISABLED |
      APZHitResultFlags.DOUBLE_TAP_ZOOM_DISABLED,
      scrollId,
      layersId,
      "touch-action: pan-x inside touch-action: manipulation");
  checkHitResult(
      hitTest(centerOf("taInnerManipNone")),
      APZHitResultFlags.VISIBLE |
      APZHitResultFlags.PAN_X_DISABLED |
      APZHitResultFlags.PAN_Y_DISABLED |
      APZHitResultFlags.PINCH_ZOOM_DISABLED |
      APZHitResultFlags.DOUBLE_TAP_ZOOM_DISABLED,
      scrollId,
      layersId,
      "touch-action: none inside touch-action: manipulation");
  checkHitResult(
      hitTest(centerOf("taInnerManipListener")),
      APZHitResultFlags.VISIBLE |
      APZHitResultFlags.APZ_AWARE_LISTENERS |
      APZHitResultFlags.DOUBLE_TAP_ZOOM_DISABLED,
      scrollId,
      layersId,
      "div with touch listener inside touch-action: manipulation");

  checkHitResult(
      hitTest(centerOf("taListener")),
      APZHitResultFlags.VISIBLE |
      APZHitResultFlags.APZ_AWARE_LISTENERS,
      scrollId,
      layersId,
      "div with touch listener");
  checkHitResult(
      hitTest(centerOf("taInnerListenerPanX")),
      APZHitResultFlags.VISIBLE |
      APZHitResultFlags.APZ_AWARE_LISTENERS |
      APZHitResultFlags.PAN_Y_DISABLED |
      APZHitResultFlags.PINCH_ZOOM_DISABLED |
      APZHitResultFlags.DOUBLE_TAP_ZOOM_DISABLED,
      scrollId,
      layersId,
      "touch-action: pan-x inside div with touch listener");

  checkHitResult(
      hitTest(centerOf("taPinchZoom")),
      APZHitResultFlags.VISIBLE |
      APZHitResultFlags.PAN_Y_DISABLED |
      APZHitResultFlags.PAN_X_DISABLED |
      APZHitResultFlags.DOUBLE_TAP_ZOOM_DISABLED,
      scrollId,
      layersId,
      "touch-action: pinch-zoom inside div with touch listener");

  checkHitResult(
      hitTest(centerOf("taScrollerPanY")),
      APZHitResultFlags.VISIBLE |
      APZHitResultFlags.PAN_X_DISABLED |
      APZHitResultFlags.PINCH_ZOOM_DISABLED |
      APZHitResultFlags.DOUBLE_TAP_ZOOM_DISABLED,
      config.utils.getViewId(document.getElementById("taScrollerPanY")),
      layersId,
      "touch-action: pan-y on scroller");
  checkHitResult(
      hitTest(centerOf("taScroller")),
      APZHitResultFlags.VISIBLE |
      APZHitResultFlags.PAN_X_DISABLED |
      APZHitResultFlags.PINCH_ZOOM_DISABLED |
      APZHitResultFlags.DOUBLE_TAP_ZOOM_DISABLED,
      config.utils.getViewId(document.getElementById("taScroller")),
      layersId,
      "touch-action: pan-y on div inside scroller");
  checkHitResult(
      hitTest(centerOf("taScroller2")),
      APZHitResultFlags.VISIBLE |
      APZHitResultFlags.PINCH_ZOOM_DISABLED |
      APZHitResultFlags.DOUBLE_TAP_ZOOM_DISABLED,
      config.utils.getViewId(document.getElementById("taScroller2")),
      layersId,
      "zooming restrictions from pan-x outside scroller get inherited in");

  checkHitResult(
      hitTest(centerOf("taScrollerPanX")),
      APZHitResultFlags.VISIBLE |
      APZHitResultFlags.PAN_Y_DISABLED |
      APZHitResultFlags.PINCH_ZOOM_DISABLED |
      APZHitResultFlags.DOUBLE_TAP_ZOOM_DISABLED,
      config.utils.getViewId(document.getElementById("taScrollerPanX")),
      layersId,
      "touch-action: pan-x on scroller inside manipulation");
  checkHitResult(
      hitTest(centerOf("taScroller3")),
      APZHitResultFlags.VISIBLE |
      APZHitResultFlags.DOUBLE_TAP_ZOOM_DISABLED,
      config.utils.getViewId(document.getElementById("taScroller3")),
      layersId,
      "touch-action: manipulation outside scroller gets inherited in");
  checkHitResult(
      hitTest(centerOf("taScroller4")),
      APZHitResultFlags.VISIBLE |
      APZHitResultFlags.PAN_X_DISABLED |
      APZHitResultFlags.PINCH_ZOOM_DISABLED |
      APZHitResultFlags.DOUBLE_TAP_ZOOM_DISABLED,
      config.utils.getViewId(document.getElementById("taScroller4")),
      layersId,
      "overflow:hidden div doesn't reset pan-x/pan-y from enclosing scroller");
}

waitUntilApzStable()
  .then(test)
  .then(subtestDone, subtestFailed);

</script>
</html>