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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 : WebTouchPoint::StateStationary; | 64 : WebTouchPoint::StateStationary; |
65 case MotionEvent::ACTION_POINTER_UP: | 65 case MotionEvent::ACTION_POINTER_UP: |
66 return static_cast<int>(pointer_index) == event.GetActionIndex() | 66 return static_cast<int>(pointer_index) == event.GetActionIndex() |
67 ? WebTouchPoint::StateReleased | 67 ? WebTouchPoint::StateReleased |
68 : WebTouchPoint::StateStationary; | 68 : WebTouchPoint::StateStationary; |
69 } | 69 } |
70 NOTREACHED() << "Invalid MotionEvent::Action."; | 70 NOTREACHED() << "Invalid MotionEvent::Action."; |
71 return WebTouchPoint::StateUndefined; | 71 return WebTouchPoint::StateUndefined; |
72 } | 72 } |
73 | 73 |
| 74 WebTouchPoint::PointerType ToWebTouchPointPointerType(const MotionEvent& event, |
| 75 size_t pointer_index) { |
| 76 switch (event.GetToolType(pointer_index)) { |
| 77 case MotionEvent::TOOL_TYPE_UNKNOWN: |
| 78 return WebTouchPoint::PointerTypeUnknown; |
| 79 case MotionEvent::TOOL_TYPE_FINGER: |
| 80 return WebTouchPoint::PointerTypeTouch; |
| 81 case MotionEvent::TOOL_TYPE_STYLUS: |
| 82 return WebTouchPoint::PointerTypePen; |
| 83 case MotionEvent::TOOL_TYPE_MOUSE: |
| 84 return WebTouchPoint::PointerTypeMouse; |
| 85 case MotionEvent::TOOL_TYPE_ERASER: |
| 86 return WebTouchPoint::PointerTypeUnknown; |
| 87 } |
| 88 NOTREACHED() << "Invalid MotionEvent::ToolType = " |
| 89 << event.GetToolType(pointer_index); |
| 90 return WebTouchPoint::PointerTypeUnknown; |
| 91 } |
| 92 |
74 WebTouchPoint CreateWebTouchPoint(const MotionEvent& event, | 93 WebTouchPoint CreateWebTouchPoint(const MotionEvent& event, |
75 size_t pointer_index) { | 94 size_t pointer_index) { |
76 WebTouchPoint touch; | 95 WebTouchPoint touch; |
77 touch.id = event.GetPointerId(pointer_index); | 96 touch.id = event.GetPointerId(pointer_index); |
| 97 touch.pointerType = ToWebTouchPointPointerType(event, pointer_index); |
78 touch.state = ToWebTouchPointState(event, pointer_index); | 98 touch.state = ToWebTouchPointState(event, pointer_index); |
79 touch.position.x = event.GetX(pointer_index); | 99 touch.position.x = event.GetX(pointer_index); |
80 touch.position.y = event.GetY(pointer_index); | 100 touch.position.y = event.GetY(pointer_index); |
81 touch.screenPosition.x = event.GetRawX(pointer_index); | 101 touch.screenPosition.x = event.GetRawX(pointer_index); |
82 touch.screenPosition.y = event.GetRawY(pointer_index); | 102 touch.screenPosition.y = event.GetRawY(pointer_index); |
83 | 103 |
84 // A note on touch ellipse specifications: | 104 // A note on touch ellipse specifications: |
85 // | 105 // |
86 // Android MotionEvent provides the major and minor axes of the touch ellipse, | 106 // Android MotionEvent provides the major and minor axes of the touch ellipse, |
87 // as well as the orientation of the major axis clockwise from vertical, in | 107 // as well as the orientation of the major axis clockwise from vertical, in |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 } | 330 } |
311 | 331 |
312 WebGestureEvent CreateWebGestureEventFromGestureEventData( | 332 WebGestureEvent CreateWebGestureEventFromGestureEventData( |
313 const GestureEventData& data) { | 333 const GestureEventData& data) { |
314 return CreateWebGestureEvent(data.details, data.time - base::TimeTicks(), | 334 return CreateWebGestureEvent(data.details, data.time - base::TimeTicks(), |
315 gfx::PointF(data.x, data.y), | 335 gfx::PointF(data.x, data.y), |
316 gfx::PointF(data.raw_x, data.raw_y), data.flags); | 336 gfx::PointF(data.raw_x, data.raw_y), data.flags); |
317 } | 337 } |
318 | 338 |
319 } // namespace ui | 339 } // namespace ui |
OLD | NEW |