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( | |
75 const MotionEvent& event, 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(); | |
sadrul
2015/08/11 19:33:34
NOTREACHED() << "Invalid MotionEvent::ToolType = "
USE eero AT chromium.org
2015/08/12 07:50:11
Done.
| |
89 return WebTouchPoint::PointerTypeUnknown; | |
90 } | |
91 | |
74 WebTouchPoint CreateWebTouchPoint(const MotionEvent& event, | 92 WebTouchPoint CreateWebTouchPoint(const MotionEvent& event, |
75 size_t pointer_index) { | 93 size_t pointer_index) { |
76 WebTouchPoint touch; | 94 WebTouchPoint touch; |
77 touch.id = event.GetPointerId(pointer_index); | 95 touch.id = event.GetPointerId(pointer_index); |
96 touch.pointerType = ToWebTouchPointPointerType(event, pointer_index); | |
78 touch.state = ToWebTouchPointState(event, pointer_index); | 97 touch.state = ToWebTouchPointState(event, pointer_index); |
79 touch.position.x = event.GetX(pointer_index); | 98 touch.position.x = event.GetX(pointer_index); |
80 touch.position.y = event.GetY(pointer_index); | 99 touch.position.y = event.GetY(pointer_index); |
81 touch.screenPosition.x = event.GetRawX(pointer_index); | 100 touch.screenPosition.x = event.GetRawX(pointer_index); |
82 touch.screenPosition.y = event.GetRawY(pointer_index); | 101 touch.screenPosition.y = event.GetRawY(pointer_index); |
83 | 102 |
84 // A note on touch ellipse specifications: | 103 // A note on touch ellipse specifications: |
85 // | 104 // |
86 // Android MotionEvent provides the major and minor axes of the touch ellipse, | 105 // 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 | 106 // 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 } | 329 } |
311 | 330 |
312 WebGestureEvent CreateWebGestureEventFromGestureEventData( | 331 WebGestureEvent CreateWebGestureEventFromGestureEventData( |
313 const GestureEventData& data) { | 332 const GestureEventData& data) { |
314 return CreateWebGestureEvent(data.details, data.time - base::TimeTicks(), | 333 return CreateWebGestureEvent(data.details, data.time - base::TimeTicks(), |
315 gfx::PointF(data.x, data.y), | 334 gfx::PointF(data.x, data.y), |
316 gfx::PointF(data.raw_x, data.raw_y), data.flags); | 335 gfx::PointF(data.raw_x, data.raw_y), data.flags); |
317 } | 336 } |
318 | 337 |
319 } // namespace ui | 338 } // namespace ui |
OLD | NEW |