Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(424)

Side by Side Diff: content/browser/renderer_host/input/synthetic_gesture_target_android.cc

Issue 119323007: Add timestamps to synthesized events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove target variables in pinch; fix computation of total duration. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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, long 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 } 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
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,
75 static_cast<long>(web_touch.timeStampSeconds * 1000.0));
74 } 76 }
75 77
76 SyntheticGestureParams::GestureSourceType 78 SyntheticGestureParams::GestureSourceType
77 SyntheticGestureTargetAndroid::GetDefaultSyntheticGestureSourceType() const { 79 SyntheticGestureTargetAndroid::GetDefaultSyntheticGestureSourceType() const {
78 return SyntheticGestureParams::TOUCH_INPUT; 80 return SyntheticGestureParams::TOUCH_INPUT;
79 } 81 }
80 82
81 bool SyntheticGestureTargetAndroid::SupportsSyntheticGestureSourceType( 83 bool SyntheticGestureTargetAndroid::SupportsSyntheticGestureSourceType(
82 SyntheticGestureParams::GestureSourceType gesture_source_type) const { 84 SyntheticGestureParams::GestureSourceType gesture_source_type) const {
83 return gesture_source_type == SyntheticGestureParams::TOUCH_INPUT; 85 return gesture_source_type == SyntheticGestureParams::TOUCH_INPUT;
84 } 86 }
85 87
86 int SyntheticGestureTargetAndroid::GetTouchSlopInDips() const { 88 int SyntheticGestureTargetAndroid::GetTouchSlopInDips() const {
87 float device_scale_factor = 89 float device_scale_factor =
88 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().device_scale_factor(); 90 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().device_scale_factor();
89 return gfx::ViewConfiguration::GetTouchSlopInPixels() / device_scale_factor; 91 return gfx::ViewConfiguration::GetTouchSlopInPixels() / device_scale_factor;
90 } 92 }
91 93
92 } // namespace content 94 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698