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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // | 90 // |
91 // The proposed extension to W3C Touch Events specifies the touch ellipse | 91 // The proposed extension to W3C Touch Events specifies the touch ellipse |
92 // using two radii along x- & y-axes and a positive acute rotation angle in | 92 // using two radii along x- & y-axes and a positive acute rotation angle in |
93 // degrees. See: | 93 // degrees. See: |
94 // http://dvcs.w3.org/hg/webevents/raw-file/default/touchevents.html | 94 // http://dvcs.w3.org/hg/webevents/raw-file/default/touchevents.html |
95 | 95 |
96 float major_radius = event.GetTouchMajor(pointer_index) / 2.f; | 96 float major_radius = event.GetTouchMajor(pointer_index) / 2.f; |
97 float minor_radius = event.GetTouchMinor(pointer_index) / 2.f; | 97 float minor_radius = event.GetTouchMinor(pointer_index) / 2.f; |
98 | 98 |
99 DCHECK_LE(minor_radius, major_radius); | 99 DCHECK_LE(minor_radius, major_radius); |
100 DCHECK_IMPLIES(major_radius, minor_radius); | 100 DCHECK(!major_radius || minor_radius); |
101 | 101 |
102 float orientation_deg = event.GetOrientation(pointer_index) * 180.f / M_PI; | 102 float orientation_deg = event.GetOrientation(pointer_index) * 180.f / M_PI; |
103 DCHECK_GE(major_radius, 0); | 103 DCHECK_GE(major_radius, 0); |
104 DCHECK_GE(minor_radius, 0); | 104 DCHECK_GE(minor_radius, 0); |
105 DCHECK_GE(major_radius, minor_radius); | 105 DCHECK_GE(major_radius, minor_radius); |
106 if (event.GetToolType(pointer_index) == MotionEvent::TOOL_TYPE_STYLUS) { | 106 if (event.GetToolType(pointer_index) == MotionEvent::TOOL_TYPE_STYLUS) { |
107 // Orientation lies in [-180, 180] for a stylus. Normalise to [-90, 90). | 107 // Orientation lies in [-180, 180] for a stylus. Normalise to [-90, 90). |
108 // Allow a small bound tolerance to account for floating point conversion. | 108 // Allow a small bound tolerance to account for floating point conversion. |
109 // TODO(e_hakkinen): crbug.com/493728: Pass also unaltered orientation | 109 // TODO(e_hakkinen): crbug.com/493728: Pass also unaltered orientation |
110 // to touch in order not to lose quadrant information. | 110 // to touch in order not to lose quadrant information. |
(...skipping 199 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 |