Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(444)

Side by Side Diff: content/common/input/touch_action.h

Issue 1422513006: Simplify TouchAction enum to be a simple bit flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix windows build warning Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_COMMON_INPUT_TOUCH_ACTION_H_ 5 #ifndef CONTENT_COMMON_INPUT_TOUCH_ACTION_H_
6 #define CONTENT_COMMON_INPUT_TOUCH_ACTION_H_ 6 #define CONTENT_COMMON_INPUT_TOUCH_ACTION_H_
7 7
8 namespace content { 8 namespace content {
9 9
10 // The current touch action specifies what accelerated browser operations 10 // The current touch action specifies what accelerated browser operations
11 // (panning and zooming) are currently permitted via touch input. 11 // (panning and zooming) are currently permitted via touch input.
12 // See http://www.w3.org/TR/pointerevents/#the-touch-action-css-property. 12 // See http://www.w3.org/TR/pointerevents/#the-touch-action-css-property.
13 enum TouchAction { 13 enum TouchAction {
jdduke (slow) 2015/10/29 15:40:26 Now that we expose proper operators, should this b
jdduke (slow) 2015/10/29 15:41:44 Actually, not sure if that works if the operators
tdresser 2015/10/29 15:43:00 It would require renaming everything, but it's lik
14 // All actions are pemitted (the default). 14 // No scrolling or zooming allowed.
15 TOUCH_ACTION_AUTO = 0, 15 TOUCH_ACTION_NONE = 0,
16 16
17 // No scrolling or zooming allowed. 17 TOUCH_ACTION_PAN_LEFT = 1 << 0,
18 TOUCH_ACTION_NONE = 1 << 0,
19 18
20 TOUCH_ACTION_PAN_LEFT = 1 << 1, 19 TOUCH_ACTION_PAN_RIGHT = 1 << 1,
21
22 TOUCH_ACTION_PAN_RIGHT = 1 << 2,
23 20
24 TOUCH_ACTION_PAN_X = TOUCH_ACTION_PAN_LEFT | TOUCH_ACTION_PAN_RIGHT, 21 TOUCH_ACTION_PAN_X = TOUCH_ACTION_PAN_LEFT | TOUCH_ACTION_PAN_RIGHT,
25 22
26 TOUCH_ACTION_PAN_UP = 1 << 3, 23 TOUCH_ACTION_PAN_UP = 1 << 2,
27 24
28 TOUCH_ACTION_PAN_DOWN = 1 << 4, 25 TOUCH_ACTION_PAN_DOWN = 1 << 3,
29 26
30 TOUCH_ACTION_PAN_Y = TOUCH_ACTION_PAN_UP | TOUCH_ACTION_PAN_DOWN, 27 TOUCH_ACTION_PAN_Y = TOUCH_ACTION_PAN_UP | TOUCH_ACTION_PAN_DOWN,
31 28
32 TOUCH_ACTION_PAN_X_Y = TOUCH_ACTION_PAN_X | TOUCH_ACTION_PAN_Y, 29 TOUCH_ACTION_PAN = TOUCH_ACTION_PAN_X | TOUCH_ACTION_PAN_Y,
33 30
34 TOUCH_ACTION_PINCH_ZOOM = 1 << 5, 31 TOUCH_ACTION_PINCH_ZOOM = 1 << 4,
35 32
36 TOUCH_ACTION_MANIPULATION = TOUCH_ACTION_PAN_X_Y | TOUCH_ACTION_PINCH_ZOOM, 33 TOUCH_ACTION_MANIPULATION = TOUCH_ACTION_PAN | TOUCH_ACTION_PINCH_ZOOM,
34
35 TOUCH_ACTION_DOUBLE_TAP_ZOOM = 1 << 5,
36
37 // All actions are pemitted (the default).
tdresser 2015/10/29 15:30:35 pemitted -> permitted
Rick Byers 2015/10/29 16:56:04 Done.
38 TOUCH_ACTION_AUTO = TOUCH_ACTION_MANIPULATION | TOUCH_ACTION_DOUBLE_TAP_ZOOM,
37 39
38 TOUCH_ACTION_MAX = (1 << 6) - 1 40 TOUCH_ACTION_MAX = (1 << 6) - 1
39 }; 41 };
40 42
43 inline TouchAction operator| (TouchAction a, TouchAction b)
44 {
45 return TouchAction(int(a) | int(b));
tdresser 2015/10/29 15:30:35 Use static_cast.
dtapuska 2015/10/29 15:38:44 WebTouchAction also does this; and occurs in a few
Rick Byers 2015/10/29 16:56:04 I think I've found them all and switched to static
46 }
47 inline TouchAction& operator|= (TouchAction& a, TouchAction b)
48 {
49 return a = a | b;
50 }
51 inline TouchAction operator& (TouchAction a, TouchAction b)
52 {
53 return TouchAction(int(a) & int(b));
54 }
55 inline TouchAction& operator&= (TouchAction& a, TouchAction b)
56 {
57 return a = a & b;
58 }
59
41 } // namespace content 60 } // namespace content
42 61
43 #endif // CONTENT_COMMON_INPUT_TOUCH_ACTION_H_ 62 #endif // CONTENT_COMMON_INPUT_TOUCH_ACTION_H_
OLDNEW
« no previous file with comments | « content/browser/renderer_host/input/touch_action_filter_unittest.cc ('k') | content/renderer/render_widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698