OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/android/content_view_core_impl.h" | 5 #include "content/browser/android/content_view_core_impl.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
(...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 } | 1059 } |
1060 | 1060 |
1061 void ContentViewCoreImpl::FlingCancel(JNIEnv* env, jobject obj, jlong time_ms) { | 1061 void ContentViewCoreImpl::FlingCancel(JNIEnv* env, jobject obj, jlong time_ms) { |
1062 WebGestureEvent event = MakeGestureEvent( | 1062 WebGestureEvent event = MakeGestureEvent( |
1063 WebInputEvent::GestureFlingCancel, time_ms, 0, 0); | 1063 WebInputEvent::GestureFlingCancel, time_ms, 0, 0); |
1064 event.data.flingCancel.preventBoosting = true; | 1064 event.data.flingCancel.preventBoosting = true; |
1065 | 1065 |
1066 SendGestureEvent(event); | 1066 SendGestureEvent(event); |
1067 } | 1067 } |
1068 | 1068 |
| 1069 void ContentViewCoreImpl::SmoothScrollStart(JNIEnv* env, |
| 1070 jobject obj, |
| 1071 jlong time_ms, |
| 1072 float start_x, |
| 1073 float start_y, |
| 1074 float dx, |
| 1075 float dy, |
| 1076 jlong duration_ms) { |
| 1077 WebGestureEvent event = MakeGestureEvent(WebInputEvent::GestureFlingStart, |
| 1078 time_ms, start_x, start_y); |
| 1079 event.data.flingStart.isSmoothScroll = true; |
| 1080 event.data.flingStart.dx = dx / dpi_scale(); |
| 1081 event.data.flingStart.dy = dy / dpi_scale(); |
| 1082 event.data.flingStart.durationMs = duration_ms; |
| 1083 event.data.flingStart.targetViewport = true; |
| 1084 |
| 1085 // Velocities are not used for computing the smooth scroll animation curve. |
| 1086 // But they are included here anyways because zero-velocity fling results in |
| 1087 // GestureScrollEnd immediately. |
| 1088 event.data.flingStart.velocityX = dx / dpi_scale() / time_ms * 1000; |
| 1089 event.data.flingStart.velocityY = dy / dpi_scale() / time_ms * 1000; |
| 1090 |
| 1091 SendGestureEvent(event); |
| 1092 } |
| 1093 |
1069 void ContentViewCoreImpl::SingleTap(JNIEnv* env, jobject obj, jlong time_ms, | 1094 void ContentViewCoreImpl::SingleTap(JNIEnv* env, jobject obj, jlong time_ms, |
1070 jfloat x, jfloat y) { | 1095 jfloat x, jfloat y) { |
1071 // Tap gestures should always be preceded by a TapDown, ensuring consistency | 1096 // Tap gestures should always be preceded by a TapDown, ensuring consistency |
1072 // with the touch-based gesture detection pipeline. | 1097 // with the touch-based gesture detection pipeline. |
1073 WebGestureEvent tap_down_event = MakeGestureEvent( | 1098 WebGestureEvent tap_down_event = MakeGestureEvent( |
1074 WebInputEvent::GestureTapDown, time_ms, x, y); | 1099 WebInputEvent::GestureTapDown, time_ms, x, y); |
1075 tap_down_event.data.tap.tapCount = 1; | 1100 tap_down_event.data.tap.tapCount = 1; |
1076 SendGestureEvent(tap_down_event); | 1101 SendGestureEvent(tap_down_event); |
1077 | 1102 |
1078 WebGestureEvent tap_event = MakeGestureEvent( | 1103 WebGestureEvent tap_event = MakeGestureEvent( |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1476 return NULL; | 1501 return NULL; |
1477 | 1502 |
1478 return view->GetJavaObject().Release(); | 1503 return view->GetJavaObject().Release(); |
1479 } | 1504 } |
1480 | 1505 |
1481 bool RegisterContentViewCore(JNIEnv* env) { | 1506 bool RegisterContentViewCore(JNIEnv* env) { |
1482 return RegisterNativesImpl(env); | 1507 return RegisterNativesImpl(env); |
1483 } | 1508 } |
1484 | 1509 |
1485 } // namespace content | 1510 } // namespace content |
OLD | NEW |