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
cc / input / touch_action.h [blame]
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CC_INPUT_TOUCH_ACTION_H_
#define CC_INPUT_TOUCH_ACTION_H_
#include <cstdlib>
#include "base/notreached.h"
namespace cc {
// The current touch action specifies what accelerated browser operations
// (panning and zooming) are currently permitted via touch input.
// See http://www.w3.org/TR/pointerevents/#the-touch-action-css-property.
// This is intended to be the single canonical definition of the enum, it's used
// elsewhere in both Blink and content since touch action logic spans those
// subsystems.
const size_t kTouchActionBits = 6;
enum class TouchAction {
// No scrolling or zooming allowed.
kNone = 0x0,
kPanLeft = 0x1,
kPanRight = 0x2,
kPanX = kPanLeft | kPanRight,
kPanUp = 0x4,
kPanDown = 0x8,
kPanY = kPanUp | kPanDown,
kPan = kPanX | kPanY,
kPinchZoom = 0x10,
kDoubleTapZoom = 0x20,
// Used by swipe to move cursor feature. This is only used internally
// for swipe to move cursor feature and it is not a web-visible value. When
// an element have this bit or doesn't have kPanX, we will disable swipe to
// move cursor feature for that element. When the element is contenteditable
// and it doesn't have a horizontal scrollable ancestor (including
// itself), we don't set this bit.
kInternalPanXScrolls = 0x40,
// This is used internally by stylus handwriting feature. Stylus writing would
// not be started when this bit is set. When the element is non-password edit
// field and has kPan, we don't set this bit.
kInternalNotWritable = 0x80,
// TODO(crbug.com/382525574): This value is currently being used to measure
// how many pages would lose handwriting if handwriting were to ship as a new
// touch action value as describedd in the linked bug.
kInternalHandwriting = 0x100,
kManipulation = kPan | kPinchZoom | kInternalHandwriting,
kAuto = kManipulation | kDoubleTapZoom | kInternalPanXScrolls |
kInternalNotWritable | kInternalHandwriting,
kMax = (1 << 9) - 1
};
inline TouchAction operator|(TouchAction a, TouchAction b) {
return static_cast<TouchAction>(static_cast<int>(a) | static_cast<int>(b));
}
inline TouchAction& operator|=(TouchAction& a, TouchAction b) {
return a = a | b;
}
inline TouchAction operator&(TouchAction a, TouchAction b) {
return static_cast<TouchAction>(static_cast<int>(a) & static_cast<int>(b));
}
inline TouchAction& operator&=(TouchAction& a, TouchAction b) {
return a = a & b;
}
inline TouchAction operator~(TouchAction touch_action) {
return static_cast<TouchAction>(~static_cast<int>(touch_action));
}
inline const char* TouchActionToString(TouchAction touch_action) {
// we skip printing internal panx scrolls since it's not a web exposed touch
// action field.
touch_action &= ~TouchAction::kInternalPanXScrolls;
// we skip printing kInternalNotWritable since it's not a web exposed
// touch action field.
touch_action &= ~TouchAction::kInternalNotWritable;
// Until handwriting is a web exposed feature, the combination of
// non-handwriting bits should result in values of auto / manipulation in the
// exposed CSS value.
// TODO(crbug.com/382525574): Launch or clean up kHandwriting.
touch_action &= ~TouchAction::kInternalHandwriting;
switch (static_cast<int>(touch_action)) {
case 0:
return "NONE";
case 1:
return "PAN_LEFT";
case 2:
return "PAN_RIGHT";
case 3:
return "PAN_X";
case 4:
return "PAN_UP";
case 5:
return "PAN_LEFT_PAN_UP";
case 6:
return "PAN_RIGHT_PAN_UP";
case 7:
return "PAN_X_PAN_UP";
case 8:
return "PAN_DOWN";
case 9:
return "PAN_LEFT_PAN_DOWN";
case 10:
return "PAN_RIGHT_PAN_DOWN";
case 11:
return "PAN_X_PAN_DOWN";
case 12:
return "PAN_Y";
case 13:
return "PAN_LEFT_PAN_Y";
case 14:
return "PAN_RIGHT_PAN_Y";
case 15:
return "PAN_X_PAN_Y";
case 16:
return "PINCH_ZOOM";
case 17:
return "PAN_LEFT_PINCH_ZOOM";
case 18:
return "PAN_RIGHT_PINCH_ZOOM";
case 19:
return "PAN_X_PINCH_ZOOM";
case 20:
return "PAN_UP_PINCH_ZOOM";
case 21:
return "PAN_LEFT_PAN_UP_PINCH_ZOOM";
case 22:
return "PAN_RIGHT_PAN_UP_PINCH_ZOOM";
case 23:
return "PAN_X_PAN_UP_PINCH_ZOOM";
case 24:
return "PAN_DOWN_PINCH_ZOOM";
case 25:
return "PAN_LEFT_PAN_DOWN_PINCH_ZOOM";
case 26:
return "PAN_RIGHT_PAN_DOWN_PINCH_ZOOM";
case 27:
return "PAN_X_PAN_DOWN_PINCH_ZOOM";
case 28:
return "PAN_Y_PINCH_ZOOM";
case 29:
return "PAN_LEFT_PAN_Y_PINCH_ZOOM";
case 30:
return "PAN_RIGHT_PAN_Y_PINCH_ZOOM";
case 32:
return "DOUBLE_TAP_ZOOM";
case 31:
return "MANIPULATION";
case 33:
return "PAN_LEFT_DOUBLE_TAP_ZOOM";
case 34:
return "PAN_RIGHT_DOUBLE_TAP_ZOOM";
case 35:
return "PAN_X_DOUBLE_TAP_ZOOM";
case 36:
return "PAN_UP_DOUBLE_TAP_ZOOM";
case 37:
return "PAN_LEFT_PAN_UP_DOUBLE_TAP_ZOOM";
case 38:
return "PAN_RIGHT_PAN_UP_DOUBLE_TAP_ZOOM";
case 39:
return "PAN_X_PAN_UP_DOUBLE_TAP_ZOOM";
case 40:
return "PAN_DOWN_DOUBLE_TAP_ZOOM";
case 41:
return "PAN_LEFT_PAN_DOWN_DOUBLE_TAP_ZOOM";
case 42:
return "PAN_RIGHT_PAN_DOWN_DOUBLE_TAP_ZOOM";
case 43:
return "PAN_X_PAN_DOWN_DOUBLE_TAP_ZOOM";
case 44:
return "PAN_Y_DOUBLE_TAP_ZOOM";
case 45:
return "PAN_LEFT_PAN_Y_DOUBLE_TAP_ZOOM";
case 46:
return "PAN_RIGHT_PAN_Y_DOUBLE_TAP_ZOOM";
case 47:
return "PAN_X_PAN_Y_DOUBLE_TAP_ZOOM";
case 48:
return "PINCH_ZOOM_DOUBLE_TAP_ZOOM";
case 49:
return "PAN_LEFT_PINCH_ZOOM_DOUBLE_TAP_ZOOM";
case 50:
return "PAN_RIGHT_PINCH_ZOOM_DOUBLE_TAP_ZOOM";
case 51:
return "PAN_X_PINCH_ZOOM_DOUBLE_TAP_ZOOM";
case 52:
return "PAN_UP_PINCH_ZOOM_DOUBLE_TAP_ZOOM";
case 53:
return "PAN_LEFT_PAN_UP_PINCH_ZOOM_DOUBLE_TAP_ZOOM";
case 54:
return "PAN_RIGHT_PAN_UP_PINCH_ZOOM_DOUBLE_TAP_ZOOM";
case 55:
return "PAN_X_PAN_UP_PINCH_ZOOM_DOUBLE_TAP_ZOOM";
case 56:
return "PAN_DOWN_PINCH_ZOOM_DOUBLE_TAP_ZOOM";
case 57:
return "PAN_LEFT_PAN_DOWN_PINCH_ZOOM_DOUBLE_TAP_ZOOM";
case 58:
return "PAN_RIGHT_PAN_DOWN_PINCH_ZOOM_DOUBLE_TAP_ZOOM";
case 59:
return "PAN_X_PAN_DOWN_PINCH_ZOOM_DOUBLE_TAP_ZOOM";
case 60:
return "PAN_Y_PINCH_ZOOM_DOUBLE_TAP_ZOOM";
case 61:
return "PAN_LEFT_PAN_Y_PINCH_ZOOM_DOUBLE_TAP_ZOOM";
case 62:
return "PAN_RIGHT_PAN_Y_PINCH_ZOOM_DOUBLE_TAP_ZOOM";
case 63:
return "AUTO";
}
NOTREACHED();
}
} // namespace cc
#endif // CC_INPUT_TOUCH_ACTION_H_