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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 #include "jni/DragEvent_jni.h" | 54 #include "jni/DragEvent_jni.h" |
55 #include "third_party/WebKit/public/web/WebInputEvent.h" | 55 #include "third_party/WebKit/public/web/WebInputEvent.h" |
56 #include "ui/android/view_android.h" | 56 #include "ui/android/view_android.h" |
57 #include "ui/android/window_android.h" | 57 #include "ui/android/window_android.h" |
58 #include "ui/base/clipboard/clipboard.h" | 58 #include "ui/base/clipboard/clipboard.h" |
59 #include "ui/base/ui_base_switches_util.h" | 59 #include "ui/base/ui_base_switches_util.h" |
60 #include "ui/events/android/motion_event_android.h" | 60 #include "ui/events/android/motion_event_android.h" |
61 #include "ui/events/blink/blink_event_util.h" | 61 #include "ui/events/blink/blink_event_util.h" |
62 #include "ui/events/blink/web_input_event_traits.h" | 62 #include "ui/events/blink/web_input_event_traits.h" |
63 #include "ui/events/event_utils.h" | 63 #include "ui/events/event_utils.h" |
| 64 #include "ui/events/gesture_detection/motion_event.h" |
64 #include "ui/gfx/android/java_bitmap.h" | 65 #include "ui/gfx/android/java_bitmap.h" |
65 #include "ui/gfx/geometry/point_conversions.h" | 66 #include "ui/gfx/geometry/point_conversions.h" |
66 #include "ui/gfx/geometry/size_conversions.h" | 67 #include "ui/gfx/geometry/size_conversions.h" |
67 #include "ui/gfx/geometry/size_f.h" | 68 #include "ui/gfx/geometry/size_f.h" |
68 | 69 |
69 using base::android::AttachCurrentThread; | 70 using base::android::AttachCurrentThread; |
70 using base::android::ConvertJavaStringToUTF16; | 71 using base::android::ConvertJavaStringToUTF16; |
71 using base::android::ConvertJavaStringToUTF8; | 72 using base::android::ConvertJavaStringToUTF8; |
72 using base::android::ConvertUTF16ToJavaString; | 73 using base::android::ConvertUTF16ToJavaString; |
73 using base::android::ConvertUTF8ToJavaString; | 74 using base::android::ConvertUTF8ToJavaString; |
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 motion_event, | 928 motion_event, |
928 time_ms, | 929 time_ms, |
929 android_action, | 930 android_action, |
930 pointer_count, | 931 pointer_count, |
931 history_size, | 932 history_size, |
932 action_index, | 933 action_index, |
933 android_button_state, | 934 android_button_state, |
934 android_meta_state, | 935 android_meta_state, |
935 raw_pos_x - pos_x_0, | 936 raw_pos_x - pos_x_0, |
936 raw_pos_y - pos_y_0, | 937 raw_pos_y - pos_y_0, |
937 pointer0, | 938 &pointer0, |
938 pointer1); | 939 &pointer1); |
939 | 940 |
940 return is_touch_handle_event ? rwhv->OnTouchHandleEvent(event) | 941 return is_touch_handle_event ? rwhv->OnTouchHandleEvent(event) |
941 : rwhv->OnTouchEvent(event); | 942 : rwhv->OnTouchEvent(event); |
942 } | 943 } |
943 | 944 |
944 jboolean ContentViewCoreImpl::SendMouseMoveEvent( | 945 jboolean ContentViewCoreImpl::SendMouseEvent( |
945 JNIEnv* env, | 946 JNIEnv* env, |
946 const JavaParamRef<jobject>& obj, | 947 const JavaParamRef<jobject>& obj, |
947 jlong time_ms, | 948 jlong time_ms, |
| 949 jint android_action, |
948 jfloat x, | 950 jfloat x, |
949 jfloat y, | 951 jfloat y, |
950 jint tool_type) { | 952 jint pointer_id, |
| 953 jfloat pressure, |
| 954 jfloat orientation, |
| 955 jfloat tilt, |
| 956 jint android_changed_button, |
| 957 jint android_button_state, |
| 958 jint android_meta_state, |
| 959 jint android_tool_type) { |
| 960 |
951 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); | 961 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); |
952 if (!rwhv) | 962 if (!rwhv) |
953 return false; | 963 return false; |
954 | 964 |
955 blink::WebMouseEvent event = WebMouseEventBuilder::Build( | 965 // Construct a motion_event object minimally, only to convert the raw |
956 WebInputEvent::MouseMove, | 966 // parameters to ui::MotionEvent values. Since we used only the cached values |
957 blink::WebMouseEvent::Button::NoButton, | 967 // at index=0, it is okay to even pass a null event to the constructor. |
958 time_ms / 1000.0, x / dpi_scale(), y / dpi_scale(), 0, 1, | 968 ui::MotionEventAndroid::Pointer pointer0( |
959 ui::ToWebPointerType(static_cast<ui::MotionEvent::ToolType>(tool_type))); | 969 pointer_id, x, y, 0.0f /* touch_major */, 0.0f /* touch_minor */, |
| 970 orientation, tilt, android_tool_type); |
960 | 971 |
961 rwhv->SendMouseEvent(event); | 972 ui::MotionEventAndroid motion_event(1.f / dpi_scale(), |
| 973 env, |
| 974 nullptr /* event */, |
| 975 time_ms, |
| 976 android_action, |
| 977 1 /* pointer_count */, |
| 978 0 /* history_size */, |
| 979 0 /* action_index */, |
| 980 android_button_state, |
| 981 android_meta_state, |
| 982 0 /* raw_offset_x_pixels */, |
| 983 0 /* raw_offset_y_pixels */, |
| 984 &pointer0, |
| 985 nullptr); |
| 986 |
| 987 // Note: This relies on identical button enum values in MotionEvent and |
| 988 // MotionEventAndroid. |
| 989 rwhv->SendMouseEvent(motion_event, android_changed_button); |
| 990 |
962 return true; | 991 return true; |
963 } | 992 } |
964 | 993 |
965 jboolean ContentViewCoreImpl::SendMouseWheelEvent( | 994 jboolean ContentViewCoreImpl::SendMouseWheelEvent( |
966 JNIEnv* env, | 995 JNIEnv* env, |
967 const JavaParamRef<jobject>& obj, | 996 const JavaParamRef<jobject>& obj, |
968 jlong time_ms, | 997 jlong time_ms, |
969 jfloat x, | 998 jfloat x, |
970 jfloat y, | 999 jfloat y, |
971 jfloat ticks_x, | 1000 jfloat ticks_x, |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1567 return ScopedJavaLocalRef<jobject>(); | 1596 return ScopedJavaLocalRef<jobject>(); |
1568 | 1597 |
1569 return view->GetJavaObject(); | 1598 return view->GetJavaObject(); |
1570 } | 1599 } |
1571 | 1600 |
1572 bool RegisterContentViewCore(JNIEnv* env) { | 1601 bool RegisterContentViewCore(JNIEnv* env) { |
1573 return RegisterNativesImpl(env); | 1602 return RegisterNativesImpl(env); |
1574 } | 1603 } |
1575 | 1604 |
1576 } // namespace content | 1605 } // namespace content |
OLD | NEW |