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..a9c2e7df2ced845d35e80e8bc5fcfd64b9356e44 100644 |
--- a/content/browser/renderer_host/input/web_input_event_util.cc |
+++ b/content/browser/renderer_host/input/web_input_event_util.cc |
@@ -2,8 +2,13 @@ |
// 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. |
+#define _USE_MATH_DEFINES |
+ |
#include "content/browser/renderer_host/input/web_input_event_util.h" |
+#include <cmath> |
+ |
#include "base/strings/string_util.h" |
#include "content/common/input/web_touch_event_traits.h" |
#include "ui/events/gesture_detection/gesture_event_data.h" |
@@ -188,7 +193,37 @@ WebTouchPoint CreateWebTouchPoint(const MotionEvent& event, |
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; |
+ |
+ // A note on touch ellipse specifications: |
+ // |
+ // Android MotionEvent provides the major and minor axes of the touch ellipse, |
+ // as well as the orientation of the major axis clockwise from vertical, in |
+ // radians. See: |
+ // http://developer.android.com/reference/android/view/MotionEvent.html |
+ // |
+ // The proposed extension to W3C Touch Events specifies the touch ellipse |
+ // using two radii along x- & y-axes and a positive acute rotation angle in |
+ // degrees, where the x-axis makes the specified angle with vertical. See: |
jdduke (slow)
2014/08/28 18:23:50
"the specified angle with the vertical": Where did
mustaq
2014/08/28 21:56:02
My bad! This misunderstanding caused the remaining
|
+ // http://dvcs.w3.org/hg/webevents/raw-file/default/touchevents.html |
+ |
+ float major_radius = event.GetTouchMajor(pointer_index) / 2.f; |
+ float minor_radius = event.GetTouchMinor(pointer_index) / 2.f; |
+ float orientation_deg = event.GetOrientation(pointer_index) * 180.f / M_PI; |
+ 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 <= orientation_deg && orientation_deg <= 90) |
+ << "Unexpected touch orientation angle"; |
+ if (orientation_deg >= 0) { |
+ touch.radiusX = major_radius; |
+ touch.radiusY = minor_radius; |
+ touch.rotationAngle = orientation_deg; |
+ } else { |
+ touch.radiusX = minor_radius; |
+ touch.radiusY = major_radius; |
+ touch.rotationAngle = orientation_deg + 90; |
+ } |
+ |
touch.force = event.GetPressure(pointer_index); |
return touch; |