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/web/WebInputEvent.h" | 10 #include "third_party/WebKit/public/web/WebInputEvent.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 touch_event_synthesizer_(touch_event_synthesizer) { | 21 touch_event_synthesizer_(touch_event_synthesizer) { |
22 DCHECK(!touch_event_synthesizer_.is_null()); | 22 DCHECK(!touch_event_synthesizer_.is_null()); |
23 } | 23 } |
24 | 24 |
25 SyntheticGestureTargetAndroid::~SyntheticGestureTargetAndroid() { | 25 SyntheticGestureTargetAndroid::~SyntheticGestureTargetAndroid() { |
26 } | 26 } |
27 | 27 |
28 void SyntheticGestureTargetAndroid::TouchSetPointer( | 28 void SyntheticGestureTargetAndroid::TouchSetPointer( |
29 JNIEnv* env, int index, int x, int y, int id) { | 29 JNIEnv* env, int index, int x, int y, int id) { |
30 TRACE_EVENT0("input", "SyntheticGestureTargetAndroid::TouchSetPointer"); | 30 TRACE_EVENT0("input", "SyntheticGestureTargetAndroid::TouchSetPointer"); |
31 Java_MotionEventSynthesizer_setPointer(env, touch_event_synthesizer_.obj(), | 31 Java_MotionEventSynthesizer_setPointer(env, touch_event_synthesizer_, index, |
32 index, x, y, id); | 32 x, y, id); |
33 } | 33 } |
34 | 34 |
35 void SyntheticGestureTargetAndroid::TouchSetScrollDeltas( | 35 void SyntheticGestureTargetAndroid::TouchSetScrollDeltas( |
36 JNIEnv* env, int x, int y, int dx, int dy) { | 36 JNIEnv* env, int x, int y, int dx, int dy) { |
37 TRACE_EVENT0("input", "SyntheticGestureTargetAndroid::TouchSetPointer"); | 37 TRACE_EVENT0("input", "SyntheticGestureTargetAndroid::TouchSetPointer"); |
38 Java_MotionEventSynthesizer_setScrollDeltas( | 38 Java_MotionEventSynthesizer_setScrollDeltas(env, touch_event_synthesizer_, x, |
39 env, touch_event_synthesizer_.obj(), x, y, dx, dy); | 39 y, dx, dy); |
40 } | 40 } |
41 | 41 |
42 void SyntheticGestureTargetAndroid::TouchInject(JNIEnv* env, | 42 void SyntheticGestureTargetAndroid::TouchInject(JNIEnv* env, |
43 Action action, | 43 Action action, |
44 int pointer_count, | 44 int pointer_count, |
45 int64_t time_in_ms) { | 45 int64_t time_in_ms) { |
46 TRACE_EVENT0("input", "SyntheticGestureTargetAndroid::TouchInject"); | 46 TRACE_EVENT0("input", "SyntheticGestureTargetAndroid::TouchInject"); |
47 Java_MotionEventSynthesizer_inject(env, touch_event_synthesizer_.obj(), | 47 Java_MotionEventSynthesizer_inject(env, touch_event_synthesizer_, |
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: |
(...skipping 20 matching lines...) Expand all Loading... |
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_.obj(), | 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 |