| 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> |
| 11 | 11 |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "content/common/input/web_touch_event_traits.h" | 13 #include "content/common/input/web_touch_event_traits.h" |
| 14 #include "ui/events/blink/blink_event_util.h" | 14 #include "ui/events/blink/blink_event_util.h" |
| 15 | 15 |
| 16 using blink::WebInputEvent; | 16 using blink::WebInputEvent; |
| 17 using blink::WebPointerProperties; | 17 using blink::WebPointerProperties; |
| 18 using blink::WebTouchEvent; | 18 using blink::WebTouchEvent; |
| 19 using blink::WebTouchPoint; | 19 using blink::WebTouchPoint; |
| 20 | 20 |
| 21 namespace content { | 21 namespace content { |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 ui::MotionEvent::Action GetActionFrom(const WebTouchEvent& event) { | 24 ui::MotionEvent::Action GetActionFrom(const WebTouchEvent& event) { |
| 25 DCHECK(event.touchesLength); | 25 DCHECK(event.touchesLength); |
| 26 switch (event.type) { | 26 switch (event.type()) { |
| 27 case WebInputEvent::TouchStart: | 27 case WebInputEvent::TouchStart: |
| 28 if (WebTouchEventTraits::AllTouchPointsHaveState( | 28 if (WebTouchEventTraits::AllTouchPointsHaveState( |
| 29 event, WebTouchPoint::StatePressed)) | 29 event, WebTouchPoint::StatePressed)) |
| 30 return ui::MotionEvent::ACTION_DOWN; | 30 return ui::MotionEvent::ACTION_DOWN; |
| 31 else | 31 else |
| 32 return ui::MotionEvent::ACTION_POINTER_DOWN; | 32 return ui::MotionEvent::ACTION_POINTER_DOWN; |
| 33 case WebInputEvent::TouchEnd: | 33 case WebInputEvent::TouchEnd: |
| 34 if (WebTouchEventTraits::AllTouchPointsHaveState( | 34 if (WebTouchEventTraits::AllTouchPointsHaveState( |
| 35 event, WebTouchPoint::StateReleased)) | 35 event, WebTouchPoint::StateReleased)) |
| 36 return ui::MotionEvent::ACTION_UP; | 36 return ui::MotionEvent::ACTION_UP; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 float r_x = tilt_x_r * tilt_y_z; | 181 float r_x = tilt_x_r * tilt_y_z; |
| 182 float r_y = tilt_y_r * tilt_x_z; | 182 float r_y = tilt_y_r * tilt_x_z; |
| 183 float r = sqrt(r_x * r_x + r_y * r_y); | 183 float r = sqrt(r_x * r_x + r_y * r_y); |
| 184 float z = tilt_x_z * tilt_y_z; | 184 float z = tilt_x_z * tilt_y_z; |
| 185 | 185 |
| 186 return atan2(r, z); | 186 return atan2(r, z); |
| 187 } | 187 } |
| 188 | 188 |
| 189 base::TimeTicks MotionEventWeb::GetEventTime() const { | 189 base::TimeTicks MotionEventWeb::GetEventTime() const { |
| 190 return base::TimeTicks() + | 190 return base::TimeTicks() + |
| 191 base::TimeDelta::FromMicroseconds(event_.timeStampSeconds * | 191 base::TimeDelta::FromMicroseconds(event_.timeStampSeconds() * |
| 192 base::Time::kMicrosecondsPerSecond); | 192 base::Time::kMicrosecondsPerSecond); |
| 193 } | 193 } |
| 194 | 194 |
| 195 ui::MotionEvent::ToolType MotionEventWeb::GetToolType( | 195 ui::MotionEvent::ToolType MotionEventWeb::GetToolType( |
| 196 size_t pointer_index) const { | 196 size_t pointer_index) const { |
| 197 DCHECK_LT(pointer_index, GetPointerCount()); | 197 DCHECK_LT(pointer_index, GetPointerCount()); |
| 198 | 198 |
| 199 const WebPointerProperties& pointer = event_.touches[pointer_index]; | 199 const WebPointerProperties& pointer = event_.touches[pointer_index]; |
| 200 | 200 |
| 201 switch (pointer.pointerType) { | 201 switch (pointer.pointerType) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 212 } | 212 } |
| 213 NOTREACHED() << "Unexpected pointerType"; | 213 NOTREACHED() << "Unexpected pointerType"; |
| 214 return TOOL_TYPE_UNKNOWN; | 214 return TOOL_TYPE_UNKNOWN; |
| 215 } | 215 } |
| 216 | 216 |
| 217 int MotionEventWeb::GetButtonState() const { | 217 int MotionEventWeb::GetButtonState() const { |
| 218 return 0; | 218 return 0; |
| 219 } | 219 } |
| 220 | 220 |
| 221 int MotionEventWeb::GetFlags() const { | 221 int MotionEventWeb::GetFlags() const { |
| 222 return ui::WebEventModifiersToEventFlags(event_.modifiers); | 222 return ui::WebEventModifiersToEventFlags(event_.modifiers()); |
| 223 } | 223 } |
| 224 | 224 |
| 225 } // namespace content | 225 } // namespace content |
| OLD | NEW |