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, long time_in_ms) { | 40 JNIEnv* env, Action action, int pointer_count, int64 time_in_ms) { |
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 time_in_ms); | 43 time_in_ms); |
44 } | 44 } |
45 | 45 |
46 void SyntheticGestureTargetAndroid::DispatchWebTouchEventToPlatform( | 46 void SyntheticGestureTargetAndroid::DispatchWebTouchEventToPlatform( |
47 const blink::WebTouchEvent& web_touch, const ui::LatencyInfo&) { | 47 const blink::WebTouchEvent& web_touch, const ui::LatencyInfo&) { |
48 JNIEnv* env = base::android::AttachCurrentThread(); | 48 JNIEnv* env = base::android::AttachCurrentThread(); |
49 | 49 |
50 SyntheticGestureTargetAndroid::Action action = | 50 SyntheticGestureTargetAndroid::Action action = |
(...skipping 14 matching lines...) Expand all Loading... |
65 default: | 65 default: |
66 NOTREACHED(); | 66 NOTREACHED(); |
67 } | 67 } |
68 const unsigned num_touches = web_touch.touchesLength; | 68 const unsigned num_touches = web_touch.touchesLength; |
69 for (unsigned i = 0; i < num_touches; ++i) { | 69 for (unsigned i = 0; i < num_touches; ++i) { |
70 const blink::WebTouchPoint* point = &web_touch.touches[i]; | 70 const blink::WebTouchPoint* point = &web_touch.touches[i]; |
71 TouchSetPointer(env, i, point->position.x, point->position.y, point->id); | 71 TouchSetPointer(env, i, point->position.x, point->position.y, point->id); |
72 } | 72 } |
73 | 73 |
74 TouchInject(env, action, num_touches, | 74 TouchInject(env, action, num_touches, |
75 static_cast<long>(web_touch.timeStampSeconds * 1000.0)); | 75 static_cast<int64>(web_touch.timeStampSeconds * 1000.0)); |
76 } | 76 } |
77 | 77 |
78 SyntheticGestureParams::GestureSourceType | 78 SyntheticGestureParams::GestureSourceType |
79 SyntheticGestureTargetAndroid::GetDefaultSyntheticGestureSourceType() const { | 79 SyntheticGestureTargetAndroid::GetDefaultSyntheticGestureSourceType() const { |
80 return SyntheticGestureParams::TOUCH_INPUT; | 80 return SyntheticGestureParams::TOUCH_INPUT; |
81 } | 81 } |
82 | 82 |
83 bool SyntheticGestureTargetAndroid::SupportsSyntheticGestureSourceType( | 83 bool SyntheticGestureTargetAndroid::SupportsSyntheticGestureSourceType( |
84 SyntheticGestureParams::GestureSourceType gesture_source_type) const { | 84 SyntheticGestureParams::GestureSourceType gesture_source_type) const { |
85 return gesture_source_type == SyntheticGestureParams::TOUCH_INPUT; | 85 return gesture_source_type == SyntheticGestureParams::TOUCH_INPUT; |
86 } | 86 } |
87 | 87 |
88 int SyntheticGestureTargetAndroid::GetTouchSlopInDips() const { | 88 int SyntheticGestureTargetAndroid::GetTouchSlopInDips() const { |
89 float device_scale_factor = | 89 float device_scale_factor = |
90 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().device_scale_factor(); | 90 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().device_scale_factor(); |
91 return gfx::ViewConfiguration::GetTouchSlopInPixels() / device_scale_factor; | 91 return gfx::ViewConfiguration::GetTouchSlopInPixels() / device_scale_factor; |
92 } | 92 } |
93 | 93 |
94 } // namespace content | 94 } // namespace content |
OLD | NEW |