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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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_IMPLIES(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 // Allow a small bound tolerance to account for floating point conversion. | 106 if (event.GetToolType(pointer_index) == MotionEvent::TOOL_TYPE_STYLUS) { |
jdduke (slow)
2015/05/29 14:36:14
I guess at some point we should add some basic tes
| |
107 DCHECK_GT(orientation_deg, -90.01f); | 107 // Orientation lies in [-180, 180] for a stylus. |
tdresser
2015/05/29 15:01:21
Use () for open ranges.
USE eero AT chromium.org
2015/05/29 16:17:47
It is not an open but a closed range.
From http:/
tdresser
2015/05/29 16:45:44
Sorry, you're right.
| |
108 DCHECK_LT(orientation_deg, 90.01f); | 108 // Allow a small bound tolerance to account for floating point conversion. |
109 DCHECK_GT(orientation_deg, -180.01f); | |
110 DCHECK_LT(orientation_deg, 180.01f); | |
mustaq
2015/05/29 15:11:51
Please create a bug saying that "When Touch.rotati
USE eero AT chromium.org
2015/05/29 16:17:47
Done.
| |
111 if (orientation_deg >= 90.f) | |
jdduke (slow)
2015/05/29 14:36:14
Where does the spec say it's strictly less than 90
USE eero AT chromium.org
2015/05/29 16:17:47
In section 2.1 the spec says that than rotationAng
| |
112 orientation_deg -= 180.f; | |
113 else if (orientation_deg < -90.f) | |
114 orientation_deg += 180.f; | |
115 } else { | |
116 // Orientation lies in [-90, 90] for a stylus. | |
tdresser
2015/05/29 15:01:21
stylus -> touch.
USE eero AT chromium.org
2015/05/29 16:17:47
Done.
| |
117 // Allow a small bound tolerance to account for floating point conversion. | |
118 DCHECK_GT(orientation_deg, -90.01f); | |
119 DCHECK_LT(orientation_deg, 90.01f); | |
120 if (orientation_deg >= 90.f) | |
jdduke (slow)
2015/05/29 14:36:14
Nit: If we DCHECK, we shouldn't actually fix it if
USE eero AT chromium.org
2015/05/29 16:17:47
There is nothing wrong for orientation_deg to be e
| |
121 orientation_deg -= 180.f; | |
122 } | |
109 if (orientation_deg >= 0) { | 123 if (orientation_deg >= 0) { |
110 // The case orientation_deg == 0 is handled here on purpose: although the | 124 // The case orientation_deg == 0 is handled here on purpose: although the |
111 // 'else' block is equivalent in this case, we want to pass the 0 value | 125 // 'else' block is equivalent in this case, we want to pass the 0 value |
112 // unchanged (and 0 is the default value for many devices that don't | 126 // unchanged (and 0 is the default value for many devices that don't |
113 // report elliptical touches). | 127 // report elliptical touches). |
114 touch.radiusX = minor_radius; | 128 touch.radiusX = minor_radius; |
115 touch.radiusY = major_radius; | 129 touch.radiusY = major_radius; |
116 touch.rotationAngle = orientation_deg; | 130 touch.rotationAngle = orientation_deg; |
117 } else { | 131 } else { |
118 touch.radiusX = major_radius; | 132 touch.radiusX = major_radius; |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
294 } | 308 } |
295 | 309 |
296 WebGestureEvent CreateWebGestureEventFromGestureEventData( | 310 WebGestureEvent CreateWebGestureEventFromGestureEventData( |
297 const GestureEventData& data) { | 311 const GestureEventData& data) { |
298 return CreateWebGestureEvent(data.details, data.time - base::TimeTicks(), | 312 return CreateWebGestureEvent(data.details, data.time - base::TimeTicks(), |
299 gfx::PointF(data.x, data.y), | 313 gfx::PointF(data.x, data.y), |
300 gfx::PointF(data.raw_x, data.raw_y), data.flags); | 314 gfx::PointF(data.raw_x, data.raw_y), data.flags); |
301 } | 315 } |
302 | 316 |
303 } // namespace ui | 317 } // namespace ui |
OLD | NEW |