OLD | NEW |
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. | 5 // MSVC++ requires this to be set before any other includes to get M_PI. |
6 #define _USE_MATH_DEFINES | 6 #define _USE_MATH_DEFINES |
7 | 7 |
8 #include "content/browser/renderer_host/input/motion_event_web.h" | 8 #include "content/browser/renderer_host/input/motion_event_web.h" |
9 | 9 |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 rotation_angle_rad -= (float) M_PI_2; | 142 rotation_angle_rad -= (float) M_PI_2; |
143 } | 143 } |
144 | 144 |
145 return rotation_angle_rad; | 145 return rotation_angle_rad; |
146 } | 146 } |
147 | 147 |
148 float MotionEventWeb::GetPressure(size_t pointer_index) const { | 148 float MotionEventWeb::GetPressure(size_t pointer_index) const { |
149 return 0.f; | 149 return 0.f; |
150 } | 150 } |
151 | 151 |
| 152 // TODO(e_hakkinen): Remove either this and GetTiltOrientation or GetTiltX and |
| 153 // GetTiltY. |
| 154 float MotionEventWeb::GetTilt(size_t pointer_index) const { |
| 155 DCHECK_LT(pointer_index, GetPointerCount()); |
| 156 // TODO(e_hakkinen): Remove one of these. |
| 157 return event_.touches[pointer_index].tiltRad; |
| 158 return event_.touches[pointer_index].tilt * M_PI / 180.f; |
| 159 } |
| 160 |
| 161 // TODO(e_hakkinen): Remove either this and GetTilt or GetTiltX and GetTiltY. |
| 162 float MotionEventWeb::GetTiltOrientation(size_t pointer_index) const { |
| 163 DCHECK_LT(pointer_index, GetPointerCount()); |
| 164 // TODO(e_hakkinen): Remove one of these. |
| 165 return event_.touches[pointer_index].tiltOrientationRad; |
| 166 return event_.touches[pointer_index].tiltOrientation * M_PI / 180.f; |
| 167 } |
| 168 |
| 169 // TODO(e_hakkinen): Remove either this and GetTiltY or GetTilt and |
| 170 // GetTiltOrientation. |
| 171 float MotionEventWeb::GetTiltX(size_t pointer_index) const { |
| 172 DCHECK_LT(pointer_index, GetPointerCount()); |
| 173 return event_.touches[pointer_index].tiltX * M_PI / 180.f; |
| 174 } |
| 175 |
| 176 // TODO(e_hakkinen): Remove either this and GetTiltX or GetTilt and |
| 177 // GetTiltOrientation. |
| 178 float MotionEventWeb::GetTiltY(size_t pointer_index) const { |
| 179 DCHECK_LT(pointer_index, GetPointerCount()); |
| 180 return event_.touches[pointer_index].tiltY * M_PI / 180.f; |
| 181 } |
| 182 |
152 base::TimeTicks MotionEventWeb::GetEventTime() const { | 183 base::TimeTicks MotionEventWeb::GetEventTime() const { |
153 return base::TimeTicks() + | 184 return base::TimeTicks() + |
154 base::TimeDelta::FromMicroseconds(event_.timeStampSeconds * | 185 base::TimeDelta::FromMicroseconds(event_.timeStampSeconds * |
155 base::Time::kMicrosecondsPerSecond); | 186 base::Time::kMicrosecondsPerSecond); |
156 } | 187 } |
157 | 188 |
158 ui::MotionEvent::ToolType MotionEventWeb::GetToolType( | 189 ui::MotionEvent::ToolType MotionEventWeb::GetToolType( |
159 size_t pointer_index) const { | 190 size_t pointer_index) const { |
160 // TODO(jdduke): Plumb tool type from the platform event, crbug.com/404128. | 191 // TODO(jdduke): Plumb tool type from the platform event, crbug.com/404128. |
161 DCHECK_LT(pointer_index, GetPointerCount()); | 192 DCHECK_LT(pointer_index, GetPointerCount()); |
162 return TOOL_TYPE_UNKNOWN; | 193 return TOOL_TYPE_UNKNOWN; |
163 } | 194 } |
164 | 195 |
165 int MotionEventWeb::GetButtonState() const { | 196 int MotionEventWeb::GetButtonState() const { |
166 return 0; | 197 return 0; |
167 } | 198 } |
168 | 199 |
169 int MotionEventWeb::GetFlags() const { | 200 int MotionEventWeb::GetFlags() const { |
170 return WebEventModifiersToEventFlags(event_.modifiers); | 201 return WebEventModifiersToEventFlags(event_.modifiers); |
171 } | 202 } |
172 | 203 |
173 } // namespace content | 204 } // namespace content |
OLD | NEW |