Chromium Code Reviews| Index: content/browser/renderer_host/input/web_input_event_util.cc |
| diff --git a/content/browser/renderer_host/input/web_input_event_util.cc b/content/browser/renderer_host/input/web_input_event_util.cc |
| index 303a8d0844c86fa99f345dc34908ac808d600193..953b27fe2cd24e18845449d27e4ed67074d3e46e 100644 |
| --- a/content/browser/renderer_host/input/web_input_event_util.cc |
| +++ b/content/browser/renderer_host/input/web_input_event_util.cc |
| @@ -2,6 +2,9 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +// 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.
|
| +#define _USE_MATH_DEFINES |
| + |
| #include "content/browser/renderer_host/input/web_input_event_util.h" |
| #include "base/strings/string_util.h" |
| @@ -182,13 +185,31 @@ WebTouchPoint CreateWebTouchPoint(const MotionEvent& event, |
| WebTouchPoint touch; |
| touch.id = event.GetPointerId(pointer_index); |
| touch.state = ToWebTouchPointState( |
| - event.GetAction(), |
| - static_cast<int>(pointer_index) == event.GetActionIndex()); |
| + 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.
|
| + static_cast<int>(pointer_index) == event.GetActionIndex()); |
| touch.position.x = event.GetX(pointer_index); |
| touch.position.y = event.GetY(pointer_index); |
| touch.screenPosition.x = event.GetRawX(pointer_index); |
| touch.screenPosition.y = event.GetRawY(pointer_index); |
| - touch.radiusX = touch.radiusY = event.GetTouchMajor(pointer_index) * 0.5f; |
| + |
| + float major_radius = event.GetTouchMajor(pointer_index) / 2.f; |
| + float minor_radius = event.GetTouchMinor(pointer_index) / 2.f; |
| + 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.
|
| + DCHECK_GE(major_radius, 0) << "Unexpected touch major < 0"; |
| + DCHECK_GE(minor_radius, 0) << "Unexpected touch minor < 0"; |
| + DCHECK_GE(major_radius, minor_radius) << "Unexpected major/minor touch radii"; |
| + DCHECK(-90 <= orientationDeg && orientationDeg <= 90) |
| + << "Unexpected touch orientation angle"; |
| + if (orientationDeg >= 0) { |
| + touch.radiusX = major_radius; |
| + touch.radiusY = minor_radius; |
| + touch.rotationAngle = orientationDeg; |
| + } else { |
| + touch.radiusX = minor_radius; |
| + touch.radiusY = major_radius; |
| + touch.rotationAngle = orientationDeg + 90; |
| + } |
| + |
| touch.force = event.GetPressure(pointer_index); |
| return touch; |