| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "content/browser/renderer_host/input/synthetic_gesture_target_android.h
" | 5 #include "content/browser/renderer_host/input/synthetic_gesture_target_android.h
" |
| 6 | 6 |
| 7 #include "content/browser/android/content_view_core_impl.h" | 7 #include "content/browser/android/content_view_core_impl.h" |
| 8 #include "content/browser/renderer_host/render_widget_host_impl.h" | 8 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 9 #include "jni/MotionEventSynthesizer_jni.h" | 9 #include "jni/MotionEventSynthesizer_jni.h" |
| 10 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 10 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 static_cast<int>(action), pointer_count, | 48 static_cast<int>(action), pointer_count, |
| 49 time_in_ms); | 49 time_in_ms); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void SyntheticGestureTargetAndroid::DispatchWebTouchEventToPlatform( | 52 void SyntheticGestureTargetAndroid::DispatchWebTouchEventToPlatform( |
| 53 const blink::WebTouchEvent& web_touch, const ui::LatencyInfo&) { | 53 const blink::WebTouchEvent& web_touch, const ui::LatencyInfo&) { |
| 54 JNIEnv* env = base::android::AttachCurrentThread(); | 54 JNIEnv* env = base::android::AttachCurrentThread(); |
| 55 | 55 |
| 56 SyntheticGestureTargetAndroid::Action action = | 56 SyntheticGestureTargetAndroid::Action action = |
| 57 SyntheticGestureTargetAndroid::ActionInvalid; | 57 SyntheticGestureTargetAndroid::ActionInvalid; |
| 58 switch (web_touch.type) { | 58 switch (web_touch.type()) { |
| 59 case blink::WebInputEvent::TouchStart: | 59 case blink::WebInputEvent::TouchStart: |
| 60 action = SyntheticGestureTargetAndroid::ActionStart; | 60 action = SyntheticGestureTargetAndroid::ActionStart; |
| 61 break; | 61 break; |
| 62 case blink::WebInputEvent::TouchMove: | 62 case blink::WebInputEvent::TouchMove: |
| 63 action = SyntheticGestureTargetAndroid::ActionMove; | 63 action = SyntheticGestureTargetAndroid::ActionMove; |
| 64 break; | 64 break; |
| 65 case blink::WebInputEvent::TouchCancel: | 65 case blink::WebInputEvent::TouchCancel: |
| 66 action = SyntheticGestureTargetAndroid::ActionCancel; | 66 action = SyntheticGestureTargetAndroid::ActionCancel; |
| 67 break; | 67 break; |
| 68 case blink::WebInputEvent::TouchEnd: | 68 case blink::WebInputEvent::TouchEnd: |
| 69 action = SyntheticGestureTargetAndroid::ActionEnd; | 69 action = SyntheticGestureTargetAndroid::ActionEnd; |
| 70 break; | 70 break; |
| 71 default: | 71 default: |
| 72 NOTREACHED(); | 72 NOTREACHED(); |
| 73 } | 73 } |
| 74 const unsigned num_touches = web_touch.touchesLength; | 74 const unsigned num_touches = web_touch.touchesLength; |
| 75 for (unsigned i = 0; i < num_touches; ++i) { | 75 for (unsigned i = 0; i < num_touches; ++i) { |
| 76 const blink::WebTouchPoint* point = &web_touch.touches[i]; | 76 const blink::WebTouchPoint* point = &web_touch.touches[i]; |
| 77 TouchSetPointer(env, i, point->position.x, point->position.y, point->id); | 77 TouchSetPointer(env, i, point->position.x, point->position.y, point->id); |
| 78 } | 78 } |
| 79 | 79 |
| 80 TouchInject(env, action, num_touches, | 80 TouchInject(env, action, num_touches, |
| 81 static_cast<int64_t>(web_touch.timeStampSeconds * 1000.0)); | 81 static_cast<int64_t>(web_touch.timeStampSeconds() * 1000.0)); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void SyntheticGestureTargetAndroid::DispatchWebMouseWheelEventToPlatform( | 84 void SyntheticGestureTargetAndroid::DispatchWebMouseWheelEventToPlatform( |
| 85 const blink::WebMouseWheelEvent& web_wheel, const ui::LatencyInfo&) { | 85 const blink::WebMouseWheelEvent& web_wheel, const ui::LatencyInfo&) { |
| 86 JNIEnv* env = base::android::AttachCurrentThread(); | 86 JNIEnv* env = base::android::AttachCurrentThread(); |
| 87 TouchSetScrollDeltas(env, web_wheel.x, web_wheel.y, web_wheel.deltaX, | 87 TouchSetScrollDeltas(env, web_wheel.x, web_wheel.y, web_wheel.deltaX, |
| 88 web_wheel.deltaY); | 88 web_wheel.deltaY); |
| 89 Java_MotionEventSynthesizer_inject( | 89 Java_MotionEventSynthesizer_inject( |
| 90 env, touch_event_synthesizer_, | 90 env, touch_event_synthesizer_, |
| 91 static_cast<int>(SyntheticGestureTargetAndroid::ActionScroll), 1, | 91 static_cast<int>(SyntheticGestureTargetAndroid::ActionScroll), 1, |
| 92 static_cast<int64_t>(web_wheel.timeStampSeconds * 1000.0)); | 92 static_cast<int64_t>(web_wheel.timeStampSeconds() * 1000.0)); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void SyntheticGestureTargetAndroid::DispatchWebMouseEventToPlatform( | 95 void SyntheticGestureTargetAndroid::DispatchWebMouseEventToPlatform( |
| 96 const blink::WebMouseEvent& web_mouse, const ui::LatencyInfo&) { | 96 const blink::WebMouseEvent& web_mouse, const ui::LatencyInfo&) { |
| 97 CHECK(false); | 97 CHECK(false); |
| 98 } | 98 } |
| 99 | 99 |
| 100 SyntheticGestureParams::GestureSourceType | 100 SyntheticGestureParams::GestureSourceType |
| 101 SyntheticGestureTargetAndroid::GetDefaultSyntheticGestureSourceType() const { | 101 SyntheticGestureTargetAndroid::GetDefaultSyntheticGestureSourceType() const { |
| 102 return SyntheticGestureParams::TOUCH_INPUT; | 102 return SyntheticGestureParams::TOUCH_INPUT; |
| 103 } | 103 } |
| 104 | 104 |
| 105 float SyntheticGestureTargetAndroid::GetTouchSlopInDips() const { | 105 float SyntheticGestureTargetAndroid::GetTouchSlopInDips() const { |
| 106 // TODO(jdduke): Have all targets use the same ui::GestureConfiguration | 106 // TODO(jdduke): Have all targets use the same ui::GestureConfiguration |
| 107 // codepath. | 107 // codepath. |
| 108 return gfx::ViewConfiguration::GetTouchSlopInDips(); | 108 return gfx::ViewConfiguration::GetTouchSlopInDips(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 float SyntheticGestureTargetAndroid::GetMinScalingSpanInDips() const { | 111 float SyntheticGestureTargetAndroid::GetMinScalingSpanInDips() const { |
| 112 // TODO(jdduke): Have all targets use the same ui::GestureConfiguration | 112 // TODO(jdduke): Have all targets use the same ui::GestureConfiguration |
| 113 // codepath. | 113 // codepath. |
| 114 return gfx::ViewConfiguration::GetMinScalingSpanInDips(); | 114 return gfx::ViewConfiguration::GetMinScalingSpanInDips(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 } // namespace content | 117 } // namespace content |
| OLD | NEW |