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/TouchEventSynthesizer_jni.h" | 9 #include "jni/TouchEventSynthesizer_jni.h" |
10 #include "third_party/WebKit/public/web/WebInputEvent.h" | 10 #include "third_party/WebKit/public/web/WebInputEvent.h" |
(...skipping 19 matching lines...) Expand all Loading... | |
30 return RegisterNativesImpl(env); | 30 return RegisterNativesImpl(env); |
31 } | 31 } |
32 | 32 |
33 void SyntheticGestureTargetAndroid::TouchSetPointer( | 33 void SyntheticGestureTargetAndroid::TouchSetPointer( |
34 JNIEnv* env, int index, int x, int y, int id) { | 34 JNIEnv* env, int index, int x, int y, int id) { |
35 Java_TouchEventSynthesizer_setPointer(env, touch_event_synthesizer_.obj(), | 35 Java_TouchEventSynthesizer_setPointer(env, touch_event_synthesizer_.obj(), |
36 index, x, y, id); | 36 index, x, y, id); |
37 } | 37 } |
38 | 38 |
39 void SyntheticGestureTargetAndroid::TouchInject( | 39 void SyntheticGestureTargetAndroid::TouchInject( |
40 JNIEnv* env, Action action, int pointer_count) { | 40 JNIEnv* env, Action action, int pointer_count, double timestamp_in_s) { |
jdduke (slow)
2014/01/03 18:24:30
As noted later, let's make this arg |long time_in_
Dominik Grewe
2014/01/06 11:46:07
Done.
| |
41 Java_TouchEventSynthesizer_inject(env, touch_event_synthesizer_.obj(), | 41 Java_TouchEventSynthesizer_inject(env, touch_event_synthesizer_.obj(), |
42 static_cast<int>(action), pointer_count); | 42 static_cast<int>(action), pointer_count, |
43 timestamp_in_s); | |
43 } | 44 } |
44 | 45 |
45 void SyntheticGestureTargetAndroid::DispatchWebTouchEventToPlatform( | 46 void SyntheticGestureTargetAndroid::DispatchWebTouchEventToPlatform( |
46 const blink::WebTouchEvent& web_touch, const ui::LatencyInfo&) { | 47 const blink::WebTouchEvent& web_touch, const ui::LatencyInfo&) { |
47 JNIEnv* env = base::android::AttachCurrentThread(); | 48 JNIEnv* env = base::android::AttachCurrentThread(); |
48 | 49 |
49 SyntheticGestureTargetAndroid::Action action = | 50 SyntheticGestureTargetAndroid::Action action = |
50 SyntheticGestureTargetAndroid::ActionInvalid; | 51 SyntheticGestureTargetAndroid::ActionInvalid; |
51 switch (web_touch.type) { | 52 switch (web_touch.type) { |
52 case blink::WebInputEvent::TouchStart: | 53 case blink::WebInputEvent::TouchStart: |
(...skipping 10 matching lines...) Expand all Loading... | |
63 break; | 64 break; |
64 default: | 65 default: |
65 NOTREACHED(); | 66 NOTREACHED(); |
66 } | 67 } |
67 const unsigned num_touches = web_touch.touchesLength; | 68 const unsigned num_touches = web_touch.touchesLength; |
68 for (unsigned i = 0; i < num_touches; ++i) { | 69 for (unsigned i = 0; i < num_touches; ++i) { |
69 const blink::WebTouchPoint* point = &web_touch.touches[i]; | 70 const blink::WebTouchPoint* point = &web_touch.touches[i]; |
70 TouchSetPointer(env, i, point->position.x, point->position.y, point->id); | 71 TouchSetPointer(env, i, point->position.x, point->position.y, point->id); |
71 } | 72 } |
72 | 73 |
73 TouchInject(env, action, num_touches); | 74 TouchInject(env, action, num_touches, web_touch.timeStampSeconds); |
74 } | 75 } |
75 | 76 |
76 SyntheticGestureParams::GestureSourceType | 77 SyntheticGestureParams::GestureSourceType |
77 SyntheticGestureTargetAndroid::GetDefaultSyntheticGestureSourceType() const { | 78 SyntheticGestureTargetAndroid::GetDefaultSyntheticGestureSourceType() const { |
78 return SyntheticGestureParams::TOUCH_INPUT; | 79 return SyntheticGestureParams::TOUCH_INPUT; |
79 } | 80 } |
80 | 81 |
81 bool SyntheticGestureTargetAndroid::SupportsSyntheticGestureSourceType( | 82 bool SyntheticGestureTargetAndroid::SupportsSyntheticGestureSourceType( |
82 SyntheticGestureParams::GestureSourceType gesture_source_type) const { | 83 SyntheticGestureParams::GestureSourceType gesture_source_type) const { |
83 return gesture_source_type == SyntheticGestureParams::TOUCH_INPUT; | 84 return gesture_source_type == SyntheticGestureParams::TOUCH_INPUT; |
84 } | 85 } |
85 | 86 |
86 int SyntheticGestureTargetAndroid::GetTouchSlopInDips() const { | 87 int SyntheticGestureTargetAndroid::GetTouchSlopInDips() const { |
87 float device_scale_factor = | 88 float device_scale_factor = |
88 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().device_scale_factor(); | 89 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().device_scale_factor(); |
89 return gfx::ViewConfiguration::GetTouchSlopInPixels() / device_scale_factor; | 90 return gfx::ViewConfiguration::GetTouchSlopInPixels() / device_scale_factor; |
90 } | 91 } |
91 | 92 |
92 } // namespace content | 93 } // namespace content |
OLD | NEW |