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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 CreateWebTouchPoint(const MotionEvent& event, | 74 WebTouchPoint CreateWebTouchPoint(const MotionEvent& event, |
75 size_t pointer_index) { | 75 size_t pointer_index) { |
76 WebTouchPoint touch; | 76 WebTouchPoint touch; |
77 touch.id = event.GetPointerId(pointer_index); | 77 touch.pointerId = event.GetPointerId(pointer_index); |
78 touch.state = ToWebTouchPointState(event, pointer_index); | 78 touch.state = ToWebTouchPointState(event, pointer_index); |
79 touch.position.x = event.GetX(pointer_index); | 79 touch.position.x = event.GetX(pointer_index); |
80 touch.position.y = event.GetY(pointer_index); | 80 touch.position.y = event.GetY(pointer_index); |
81 touch.screenPosition.x = event.GetRawX(pointer_index); | 81 touch.screenPosition.x = event.GetRawX(pointer_index); |
82 touch.screenPosition.y = event.GetRawY(pointer_index); | 82 touch.screenPosition.y = event.GetRawY(pointer_index); |
83 | 83 |
84 // A note on touch ellipse specifications: | 84 // A note on touch ellipse specifications: |
85 // | 85 // |
86 // Android MotionEvent provides the major and minor axes of the touch ellipse, | 86 // 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 | 87 // as well as the orientation of the major axis clockwise from vertical, in |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 DCHECK_GT(orientation_deg, -90.01f); | 120 DCHECK_GT(orientation_deg, -90.01f); |
121 DCHECK_LT(orientation_deg, 90.01f); | 121 DCHECK_LT(orientation_deg, 90.01f); |
122 if (orientation_deg >= 90.f) | 122 if (orientation_deg >= 90.f) |
123 orientation_deg -= 180.f; | 123 orientation_deg -= 180.f; |
124 } | 124 } |
125 if (orientation_deg >= 0) { | 125 if (orientation_deg >= 0) { |
126 // The case orientation_deg == 0 is handled here on purpose: although the | 126 // The case orientation_deg == 0 is handled here on purpose: although the |
127 // 'else' block is equivalent in this case, we want to pass the 0 value | 127 // 'else' block is equivalent in this case, we want to pass the 0 value |
128 // unchanged (and 0 is the default value for many devices that don't | 128 // unchanged (and 0 is the default value for many devices that don't |
129 // report elliptical touches). | 129 // report elliptical touches). |
130 touch.radiusX = minor_radius; | 130 touch.width = minor_radius; |
131 touch.radiusY = major_radius; | 131 touch.height = major_radius; |
132 touch.rotationAngle = orientation_deg; | 132 touch.rotationAngle = orientation_deg; |
133 } else { | 133 } else { |
134 touch.radiusX = major_radius; | 134 touch.width = major_radius; |
135 touch.radiusY = minor_radius; | 135 touch.height = minor_radius; |
136 touch.rotationAngle = orientation_deg + 90; | 136 touch.rotationAngle = orientation_deg + 90; |
137 } | 137 } |
138 | 138 |
139 touch.force = event.GetPressure(pointer_index); | 139 touch.pressure = event.GetPressure(pointer_index); |
140 | 140 |
141 return touch; | 141 return touch; |
142 } | 142 } |
143 | 143 |
144 } // namespace | 144 } // namespace |
145 | 145 |
146 blink::WebTouchEvent CreateWebTouchEventFromMotionEvent( | 146 blink::WebTouchEvent CreateWebTouchEventFromMotionEvent( |
147 const MotionEvent& event, | 147 const MotionEvent& event, |
148 bool may_cause_scrolling) { | 148 bool may_cause_scrolling) { |
149 static_assert(static_cast<int>(MotionEvent::MAX_TOUCH_POINT_COUNT) == | 149 static_assert(static_cast<int>(MotionEvent::MAX_TOUCH_POINT_COUNT) == |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 } | 310 } |
311 | 311 |
312 WebGestureEvent CreateWebGestureEventFromGestureEventData( | 312 WebGestureEvent CreateWebGestureEventFromGestureEventData( |
313 const GestureEventData& data) { | 313 const GestureEventData& data) { |
314 return CreateWebGestureEvent(data.details, data.time - base::TimeTicks(), | 314 return CreateWebGestureEvent(data.details, data.time - base::TimeTicks(), |
315 gfx::PointF(data.x, data.y), | 315 gfx::PointF(data.x, data.y), |
316 gfx::PointF(data.raw_x, data.raw_y), data.flags); | 316 gfx::PointF(data.raw_x, data.raw_y), data.flags); |
317 } | 317 } |
318 | 318 |
319 } // namespace ui | 319 } // namespace ui |
OLD | NEW |