| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 // | 116 // |
| 117 // The proposed extension to W3C Touch Events specifies the touch ellipse | 117 // The proposed extension to W3C Touch Events specifies the touch ellipse |
| 118 // using two radii along x- & y-axes and a positive acute rotation angle in | 118 // using two radii along x- & y-axes and a positive acute rotation angle in |
| 119 // degrees. See: | 119 // degrees. See: |
| 120 // http://dvcs.w3.org/hg/webevents/raw-file/default/touchevents.html | 120 // http://dvcs.w3.org/hg/webevents/raw-file/default/touchevents.html |
| 121 | 121 |
| 122 float major_radius = event.GetTouchMajor(pointer_index) / 2.f; | 122 float major_radius = event.GetTouchMajor(pointer_index) / 2.f; |
| 123 float minor_radius = event.GetTouchMinor(pointer_index) / 2.f; | 123 float minor_radius = event.GetTouchMinor(pointer_index) / 2.f; |
| 124 | 124 |
| 125 DCHECK_LE(minor_radius, major_radius); | 125 DCHECK_LE(minor_radius, major_radius); |
| 126 DCHECK(!major_radius || minor_radius); | 126 DCHECK_IMPLIES(major_radius, minor_radius); |
| 127 | 127 |
| 128 float orientation_deg = event.GetOrientation(pointer_index) * 180.f / M_PI; | 128 float orientation_deg = event.GetOrientation(pointer_index) * 180.f / M_PI; |
| 129 DCHECK_GE(major_radius, 0); | 129 DCHECK_GE(major_radius, 0); |
| 130 DCHECK_GE(minor_radius, 0); | 130 DCHECK_GE(minor_radius, 0); |
| 131 DCHECK_GE(major_radius, minor_radius); | 131 DCHECK_GE(major_radius, minor_radius); |
| 132 // Orientation lies in [-180, 180] for a stylus, and [-90, 90] for other | 132 // Orientation lies in [-180, 180] for a stylus, and [-90, 90] for other |
| 133 // touchscreen inputs. There are exceptions on Android when a device is | 133 // touchscreen inputs. There are exceptions on Android when a device is |
| 134 // rotated, yielding touch orientations in the range of [-180, 180]. | 134 // rotated, yielding touch orientations in the range of [-180, 180]. |
| 135 // Regardless, normalise to [-90, 90), allowing a small tolerance to account | 135 // Regardless, normalise to [-90, 90), allowing a small tolerance to account |
| 136 // for floating point conversion. | 136 // for floating point conversion. |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 } | 347 } |
| 348 | 348 |
| 349 WebGestureEvent CreateWebGestureEventFromGestureEventData( | 349 WebGestureEvent CreateWebGestureEventFromGestureEventData( |
| 350 const GestureEventData& data) { | 350 const GestureEventData& data) { |
| 351 return CreateWebGestureEvent(data.details, data.time - base::TimeTicks(), | 351 return CreateWebGestureEvent(data.details, data.time - base::TimeTicks(), |
| 352 gfx::PointF(data.x, data.y), | 352 gfx::PointF(data.x, data.y), |
| 353 gfx::PointF(data.raw_x, data.raw_y), data.flags); | 353 gfx::PointF(data.raw_x, data.raw_y), data.flags); |
| 354 } | 354 } |
| 355 | 355 |
| 356 } // namespace ui | 356 } // namespace ui |
| OLD | NEW |