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

Side by Side Diff: content/browser/renderer_host/input/motion_event_web.cc

Issue 531133002: Revert of Completed webkit radiusX, radiusY and rotationAngle handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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.
6 #define _USE_MATH_DEFINES
7
8 #include "content/browser/renderer_host/input/motion_event_web.h" 5 #include "content/browser/renderer_host/input/motion_event_web.h"
9 6
10 #include <cmath>
11
12 #include "base/logging.h" 7 #include "base/logging.h"
13 #include "content/common/input/web_touch_event_traits.h" 8 #include "content/common/input/web_touch_event_traits.h"
14 9
15 using blink::WebInputEvent; 10 using blink::WebInputEvent;
16 using blink::WebTouchEvent; 11 using blink::WebTouchEvent;
17 using blink::WebTouchPoint; 12 using blink::WebTouchPoint;
18 13
19 namespace content { 14 namespace content {
20 namespace { 15 namespace {
21 16
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 return event_.touches[pointer_index].screenPosition.x; 95 return event_.touches[pointer_index].screenPosition.x;
101 } 96 }
102 97
103 float MotionEventWeb::GetRawY(size_t pointer_index) const { 98 float MotionEventWeb::GetRawY(size_t pointer_index) const {
104 DCHECK_LT(pointer_index, GetPointerCount()); 99 DCHECK_LT(pointer_index, GetPointerCount());
105 return event_.touches[pointer_index].screenPosition.y; 100 return event_.touches[pointer_index].screenPosition.y;
106 } 101 }
107 102
108 float MotionEventWeb::GetTouchMajor(size_t pointer_index) const { 103 float MotionEventWeb::GetTouchMajor(size_t pointer_index) const {
109 DCHECK_LT(pointer_index, GetPointerCount()); 104 DCHECK_LT(pointer_index, GetPointerCount());
105 // TODO(jdduke): We should be a bit more careful about axes here.
110 return 2.f * std::max(event_.touches[pointer_index].radiusX, 106 return 2.f * std::max(event_.touches[pointer_index].radiusX,
111 event_.touches[pointer_index].radiusY); 107 event_.touches[pointer_index].radiusY);
112 } 108 }
113 109
114 float MotionEventWeb::GetTouchMinor(size_t pointer_index) const {
115 DCHECK_LT(pointer_index, GetPointerCount());
116 return 2.f * std::min(event_.touches[pointer_index].radiusX,
117 event_.touches[pointer_index].radiusY);
118 }
119
120 float MotionEventWeb::GetOrientation(size_t pointer_index) const {
121 DCHECK_LT(pointer_index, GetPointerCount());
122
123 float rotation_angle_rad = event_.touches[pointer_index].rotationAngle
124 * M_PI / 180.f;
125 DCHECK(0 <= rotation_angle_rad && rotation_angle_rad <= M_PI_2)
126 << "Unexpected touch rotation angle";
127
128 if (event_.touches[pointer_index].radiusX
129 > event_.touches[pointer_index].radiusY) {
130 // The case radiusX == radiusY is omitted from here on purpose: for circles,
131 // we want to pass the angle (which could be any value in such cases but
132 // always seem to be set to zero) unchanged.
133 rotation_angle_rad -= (float) M_PI_2;
134 }
135
136 return rotation_angle_rad;
137 }
138
139 float MotionEventWeb::GetPressure(size_t pointer_index) const { 110 float MotionEventWeb::GetPressure(size_t pointer_index) const {
140 return 0.f; 111 return 0.f;
141 } 112 }
142 113
143 base::TimeTicks MotionEventWeb::GetEventTime() const { 114 base::TimeTicks MotionEventWeb::GetEventTime() const {
144 return base::TimeTicks() + 115 return base::TimeTicks() +
145 base::TimeDelta::FromMicroseconds(event_.timeStampSeconds * 116 base::TimeDelta::FromMicroseconds(event_.timeStampSeconds *
146 base::Time::kMicrosecondsPerSecond); 117 base::Time::kMicrosecondsPerSecond);
147 } 118 }
148 119
(...skipping 17 matching lines...) Expand all
166 WebTouchEvent cancel_event(event_); 137 WebTouchEvent cancel_event(event_);
167 WebTouchEventTraits::ResetTypeAndTouchStates( 138 WebTouchEventTraits::ResetTypeAndTouchStates(
168 blink::WebInputEvent::TouchCancel, 139 blink::WebInputEvent::TouchCancel,
169 // TODO(rbyers): Shouldn't we use a fresh timestamp? 140 // TODO(rbyers): Shouldn't we use a fresh timestamp?
170 event_.timeStampSeconds, 141 event_.timeStampSeconds,
171 &cancel_event); 142 &cancel_event);
172 return scoped_ptr<MotionEvent>(new MotionEventWeb(cancel_event)); 143 return scoped_ptr<MotionEvent>(new MotionEventWeb(cancel_event));
173 } 144 }
174 145
175 } // namespace content 146 } // namespace content
OLDNEW
« 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