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

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: 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..7ffdf5b432906716d69972ba7848ec6798f88e25 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,35 @@ 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) {
+ // The case radiusX == radiusY is omitted from here on purpose: for circles,
+ // we want to pass the angle (which could be any value in such cases but
+ // always seem to be set to zero) unchanged.
+ rotation_angle_rad -= (float) M_PI_2;
+ }
+
+ return rotation_angle_rad;
+}
+
float MotionEventWeb::GetPressure(size_t pointer_index) const {
return 0.f;
}
« no previous file with comments | « content/browser/renderer_host/input/motion_event_web.h ('k') | content/browser/renderer_host/input/web_input_event_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698