Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Unified Diff: content/browser/renderer_host/input/motion_event_web.cc

Issue 494833003: Completed webkit radiusX, radiusY and rotationAngle handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tweaked NaN checks Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/input/motion_event_web.cc
diff --git a/content/browser/renderer_host/input/motion_event_web.cc b/content/browser/renderer_host/input/motion_event_web.cc
index 6e53773a68e8c14f28d79d1a43e9cca1bab1a7d5..f20d70c730163bb340cfceae1d2db1a0d2215a28 100644
--- a/content/browser/renderer_host/input/motion_event_web.cc
+++ b/content/browser/renderer_host/input/motion_event_web.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/motion_event_web.h"
+#include <cmath>
+
#include "base/logging.h"
#include "content/common/input/web_touch_event_traits.h"
@@ -102,11 +107,32 @@ float MotionEventWeb::GetRawY(size_t pointer_index) const {
float MotionEventWeb::GetTouchMajor(size_t pointer_index) const {
DCHECK_LT(pointer_index, GetPointerCount());
- // TODO(jdduke): We should be a bit more careful about axes here.
return 2.f * std::max(event_.touches[pointer_index].radiusX,
event_.touches[pointer_index].radiusY);
}
+float MotionEventWeb::GetTouchMinor(size_t pointer_index) const {
+ DCHECK_LT(pointer_index, GetPointerCount());
+ return 2.f * std::min(event_.touches[pointer_index].radiusX,
+ event_.touches[pointer_index].radiusY);
+}
+
+float MotionEventWeb::GetOrientation(size_t pointer_index) const {
+ DCHECK_LT(pointer_index, GetPointerCount());
+
+ float rotation_angle_rad = event_.touches[pointer_index].rotationAngle
+ * M_PI / 180.f;
+ DCHECK(0 <= rotation_angle_rad && rotation_angle_rad <= M_PI_2)
+ << "Unexpected touch rotation angle";
+
+ if (event_.touches[pointer_index].radiusX
+ >= event_.touches[pointer_index].radiusY) {
jdduke (slow) 2014/08/29 16:45:08 Nit: I would make this a strict inequality, that w
mustaq 2014/08/29 16:53:00 Yeah, just discovered the default=90 value an hour
+ rotation_angle_rad -= (float) M_PI_2;
+ }
+
+ return rotation_angle_rad;
+}
+
float MotionEventWeb::GetPressure(size_t pointer_index) const {
return 0.f;
}

Powered by Google App Engine
This is Rietveld 408576698