diff options
author | rbyers <rbyers@chromium.org> | 2015-10-30 08:49:10 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-30 15:50:02 +0000 |
commit | a8b478daf9eef9e4f8e1ba21327c081b0301945e (patch) | |
tree | 806da0b7297542b87a2fe8b32f67927663283f67 /content/common/input | |
parent | dac70afef0bbd3661067adcb7746a56f5baf22b2 (diff) | |
download | chromium_src-a8b478daf9eef9e4f8e1ba21327c081b0301945e.zip chromium_src-a8b478daf9eef9e4f8e1ba21327c081b0301945e.tar.gz chromium_src-a8b478daf9eef9e4f8e1ba21327c081b0301945e.tar.bz2 |
Simplify TouchAction enum to be a simple bit flag
Originally I used the value 0 for the default touch-action value
(TouchActionAuto). But as touch-action has expanded, it would be
a lot more convenient if we used a pure bit field (where "auto"
was all flags set, and "none" was 0). This was hard to change
before the blink merge, but is now pretty easy.
BUG=None
Review URL: https://codereview.chromium.org/1422513006
Cr-Commit-Position: refs/heads/master@{#357111}
Diffstat (limited to 'content/common/input')
-rw-r--r-- | content/common/input/touch_action.h | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/content/common/input/touch_action.h b/content/common/input/touch_action.h index 89f000d..2a00a03 100644 --- a/content/common/input/touch_action.h +++ b/content/common/input/touch_action.h @@ -11,33 +11,52 @@ namespace content { // (panning and zooming) are currently permitted via touch input. // See http://www.w3.org/TR/pointerevents/#the-touch-action-css-property. enum TouchAction { - // All actions are pemitted (the default). - TOUCH_ACTION_AUTO = 0, - // No scrolling or zooming allowed. - TOUCH_ACTION_NONE = 1 << 0, + TOUCH_ACTION_NONE = 0, - TOUCH_ACTION_PAN_LEFT = 1 << 1, + TOUCH_ACTION_PAN_LEFT = 1 << 0, - TOUCH_ACTION_PAN_RIGHT = 1 << 2, + TOUCH_ACTION_PAN_RIGHT = 1 << 1, TOUCH_ACTION_PAN_X = TOUCH_ACTION_PAN_LEFT | TOUCH_ACTION_PAN_RIGHT, - TOUCH_ACTION_PAN_UP = 1 << 3, + TOUCH_ACTION_PAN_UP = 1 << 2, - TOUCH_ACTION_PAN_DOWN = 1 << 4, + TOUCH_ACTION_PAN_DOWN = 1 << 3, TOUCH_ACTION_PAN_Y = TOUCH_ACTION_PAN_UP | TOUCH_ACTION_PAN_DOWN, - TOUCH_ACTION_PAN_X_Y = TOUCH_ACTION_PAN_X | TOUCH_ACTION_PAN_Y, + TOUCH_ACTION_PAN = TOUCH_ACTION_PAN_X | TOUCH_ACTION_PAN_Y, + + TOUCH_ACTION_PINCH_ZOOM = 1 << 4, - TOUCH_ACTION_PINCH_ZOOM = 1 << 5, + TOUCH_ACTION_MANIPULATION = TOUCH_ACTION_PAN | TOUCH_ACTION_PINCH_ZOOM, - TOUCH_ACTION_MANIPULATION = TOUCH_ACTION_PAN_X_Y | TOUCH_ACTION_PINCH_ZOOM, + TOUCH_ACTION_DOUBLE_TAP_ZOOM = 1 << 5, + + // All actions are permitted (the default). + TOUCH_ACTION_AUTO = TOUCH_ACTION_MANIPULATION | TOUCH_ACTION_DOUBLE_TAP_ZOOM, TOUCH_ACTION_MAX = (1 << 6) - 1 }; +inline TouchAction operator| (TouchAction a, TouchAction b) +{ + return static_cast<TouchAction>(int(a) | int(b)); +} +inline TouchAction& operator|= (TouchAction& a, TouchAction b) +{ + return a = a | b; +} +inline TouchAction operator& (TouchAction a, TouchAction b) +{ + return static_cast<TouchAction>(int(a) & int(b)); +} +inline TouchAction& operator&= (TouchAction& a, TouchAction b) +{ + return a = a & b; +} + } // namespace content #endif // CONTENT_COMMON_INPUT_TOUCH_ACTION_H_ |