OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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. | |
tdresser
2014/08/27 18:31:34
Add an
#include <cmath>
(Include what you use)
mustaq
2014/08/27 20:51:08
Done.
| |
6 #define _USE_MATH_DEFINES | |
7 | |
5 #include "content/browser/renderer_host/input/web_input_event_util.h" | 8 #include "content/browser/renderer_host/input/web_input_event_util.h" |
6 | 9 |
7 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
8 #include "content/common/input/web_touch_event_traits.h" | 11 #include "content/common/input/web_touch_event_traits.h" |
9 #include "ui/events/gesture_detection/gesture_event_data.h" | 12 #include "ui/events/gesture_detection/gesture_event_data.h" |
10 #include "ui/events/gesture_detection/motion_event.h" | 13 #include "ui/events/gesture_detection/motion_event.h" |
11 | 14 |
12 using blink::WebGestureEvent; | 15 using blink::WebGestureEvent; |
13 using blink::WebInputEvent; | 16 using blink::WebInputEvent; |
14 using blink::WebTouchEvent; | 17 using blink::WebTouchEvent; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 } | 178 } |
176 NOTREACHED() << "Invalid MotionEvent::Action."; | 179 NOTREACHED() << "Invalid MotionEvent::Action."; |
177 return WebTouchPoint::StateUndefined; | 180 return WebTouchPoint::StateUndefined; |
178 } | 181 } |
179 | 182 |
180 WebTouchPoint CreateWebTouchPoint(const MotionEvent& event, | 183 WebTouchPoint CreateWebTouchPoint(const MotionEvent& event, |
181 size_t pointer_index) { | 184 size_t pointer_index) { |
182 WebTouchPoint touch; | 185 WebTouchPoint touch; |
183 touch.id = event.GetPointerId(pointer_index); | 186 touch.id = event.GetPointerId(pointer_index); |
184 touch.state = ToWebTouchPointState( | 187 touch.state = ToWebTouchPointState( |
185 event.GetAction(), | 188 event.GetAction(), |
jdduke (slow)
2014/08/27 18:21:10
This indentation looks off by a couple spaces?
tdresser
2014/08/27 18:31:34
Revert indentation change.
mustaq
2014/08/27 20:51:08
Done.
| |
186 static_cast<int>(pointer_index) == event.GetActionIndex()); | 189 static_cast<int>(pointer_index) == event.GetActionIndex()); |
187 touch.position.x = event.GetX(pointer_index); | 190 touch.position.x = event.GetX(pointer_index); |
188 touch.position.y = event.GetY(pointer_index); | 191 touch.position.y = event.GetY(pointer_index); |
189 touch.screenPosition.x = event.GetRawX(pointer_index); | 192 touch.screenPosition.x = event.GetRawX(pointer_index); |
190 touch.screenPosition.y = event.GetRawY(pointer_index); | 193 touch.screenPosition.y = event.GetRawY(pointer_index); |
191 touch.radiusX = touch.radiusY = event.GetTouchMajor(pointer_index) * 0.5f; | 194 |
195 float major_radius = event.GetTouchMajor(pointer_index) / 2.f; | |
196 float minor_radius = event.GetTouchMinor(pointer_index) / 2.f; | |
197 float orientationDeg = event.GetOrientation(pointer_index) * 180.f / M_PI; | |
jdduke (slow)
2014/08/27 18:21:10
Nit: orientation_deg, though it's still not clear
mustaq
2014/08/27 19:08:57
I totally agree, thanks for pointing to the origin
jdduke (slow)
2014/08/27 19:16:13
Yeah, this is probably as reasonable a place as an
mustaq
2014/08/27 20:51:08
Done.
| |
198 DCHECK_GE(major_radius, 0) << "Unexpected touch major < 0"; | |
199 DCHECK_GE(minor_radius, 0) << "Unexpected touch minor < 0"; | |
200 DCHECK_GE(major_radius, minor_radius) << "Unexpected major/minor touch radii"; | |
201 DCHECK(-90 <= orientationDeg && orientationDeg <= 90) | |
202 << "Unexpected touch orientation angle"; | |
203 if (orientationDeg >= 0) { | |
204 touch.radiusX = major_radius; | |
205 touch.radiusY = minor_radius; | |
206 touch.rotationAngle = orientationDeg; | |
207 } else { | |
208 touch.radiusX = minor_radius; | |
209 touch.radiusY = major_radius; | |
210 touch.rotationAngle = orientationDeg + 90; | |
211 } | |
212 | |
192 touch.force = event.GetPressure(pointer_index); | 213 touch.force = event.GetPressure(pointer_index); |
193 | 214 |
194 return touch; | 215 return touch; |
195 } | 216 } |
196 | 217 |
197 } // namespace | 218 } // namespace |
198 | 219 |
199 namespace content { | 220 namespace content { |
200 | 221 |
201 void UpdateWindowsKeyCodeAndKeyIdentifier(blink::WebKeyboardEvent* event, | 222 void UpdateWindowsKeyCodeAndKeyIdentifier(blink::WebKeyboardEvent* event, |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 break; | 351 break; |
331 default: | 352 default: |
332 NOTREACHED() << "ui::EventType provided wasn't a valid gesture event."; | 353 NOTREACHED() << "ui::EventType provided wasn't a valid gesture event."; |
333 break; | 354 break; |
334 } | 355 } |
335 | 356 |
336 return gesture; | 357 return gesture; |
337 } | 358 } |
338 | 359 |
339 } // namespace content | 360 } // namespace content |
OLD | NEW |