OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // MSVC++ requires this to be set before any other includes to get M_PI. | 5 // MSVC++ requires this to be set before any other includes to get M_PI. |
6 #define _USE_MATH_DEFINES | 6 #define _USE_MATH_DEFINES |
7 | 7 |
8 #include "ui/events/blink/blink_event_util.h" | 8 #include "ui/events/blink/blink_event_util.h" |
9 | 9 |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 | 46 |
47 // Note that |is_action_pointer| is meaningful only in the context of | 47 // Note that |is_action_pointer| is meaningful only in the context of |
48 // |ACTION_POINTER_UP| and |ACTION_POINTER_DOWN|; other actions map directly to | 48 // |ACTION_POINTER_UP| and |ACTION_POINTER_DOWN|; other actions map directly to |
49 // WebTouchPoint::State. | 49 // WebTouchPoint::State. |
50 WebTouchPoint::State ToWebTouchPointState(const MotionEvent& event, | 50 WebTouchPoint::State ToWebTouchPointState(const MotionEvent& event, |
51 size_t pointer_index) { | 51 size_t pointer_index) { |
52 switch (event.GetAction()) { | 52 switch (event.GetAction()) { |
53 case MotionEvent::ACTION_DOWN: | 53 case MotionEvent::ACTION_DOWN: |
54 return WebTouchPoint::StatePressed; | 54 return WebTouchPoint::StatePressed; |
55 case MotionEvent::ACTION_MOVE: | 55 case MotionEvent::ACTION_MOVE: |
56 return WebTouchPoint::StateMoved; | 56 return static_cast<int>(pointer_index) == event.GetActionIndex() |
tdresser
2015/05/04 20:39:37
GetActionIndex is only valid if |GetAction()| retu
| |
57 ? WebTouchPoint::StateMoved | |
58 : WebTouchPoint::StateStationary; | |
57 case MotionEvent::ACTION_UP: | 59 case MotionEvent::ACTION_UP: |
58 return WebTouchPoint::StateReleased; | 60 return WebTouchPoint::StateReleased; |
59 case MotionEvent::ACTION_CANCEL: | 61 case MotionEvent::ACTION_CANCEL: |
60 return WebTouchPoint::StateCancelled; | 62 return static_cast<int>(pointer_index) == event.GetActionIndex() |
63 ? WebTouchPoint::StateCancelled | |
64 : WebTouchPoint::StateStationary; | |
61 case MotionEvent::ACTION_POINTER_DOWN: | 65 case MotionEvent::ACTION_POINTER_DOWN: |
62 return static_cast<int>(pointer_index) == event.GetActionIndex() | 66 return static_cast<int>(pointer_index) == event.GetActionIndex() |
63 ? WebTouchPoint::StatePressed | 67 ? WebTouchPoint::StatePressed |
64 : WebTouchPoint::StateStationary; | 68 : WebTouchPoint::StateStationary; |
65 case MotionEvent::ACTION_POINTER_UP: | 69 case MotionEvent::ACTION_POINTER_UP: |
66 return static_cast<int>(pointer_index) == event.GetActionIndex() | 70 return static_cast<int>(pointer_index) == event.GetActionIndex() |
67 ? WebTouchPoint::StateReleased | 71 ? WebTouchPoint::StateReleased |
68 : WebTouchPoint::StateStationary; | 72 : WebTouchPoint::StateStationary; |
69 } | 73 } |
70 NOTREACHED() << "Invalid MotionEvent::Action."; | 74 NOTREACHED() << "Invalid MotionEvent::Action."; |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
296 } | 300 } |
297 | 301 |
298 WebGestureEvent CreateWebGestureEventFromGestureEventData( | 302 WebGestureEvent CreateWebGestureEventFromGestureEventData( |
299 const GestureEventData& data) { | 303 const GestureEventData& data) { |
300 return CreateWebGestureEvent(data.details, data.time - base::TimeTicks(), | 304 return CreateWebGestureEvent(data.details, data.time - base::TimeTicks(), |
301 gfx::PointF(data.x, data.y), | 305 gfx::PointF(data.x, data.y), |
302 gfx::PointF(data.raw_x, data.raw_y), data.flags); | 306 gfx::PointF(data.raw_x, data.raw_y), data.flags); |
303 } | 307 } |
304 | 308 |
305 } // namespace ui | 309 } // namespace ui |
OLD | NEW |