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

Side by Side Diff: content/browser/android/content_view_core_impl.cc

Issue 2708613002: Add EventForwarder for routing touch events (Closed)
Patch Set: - Created 3 years, 10 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
OLDNEW
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 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 JNIEnv* env, 887 JNIEnv* env,
888 const JavaParamRef<jobject>& obj, 888 const JavaParamRef<jobject>& obj,
889 jint orientation) { 889 jint orientation) {
890 if (device_orientation_ != orientation) { 890 if (device_orientation_ != orientation) {
891 base::RecordAction(base::UserMetricsAction("ScreenOrientationChange")); 891 base::RecordAction(base::UserMetricsAction("ScreenOrientationChange"));
892 device_orientation_ = orientation; 892 device_orientation_ = orientation;
893 SendOrientationChangeEventInternal(); 893 SendOrientationChangeEventInternal();
894 } 894 }
895 } 895 }
896 896
897 jboolean ContentViewCoreImpl::OnTouchEvent(
898 JNIEnv* env,
899 const JavaParamRef<jobject>& obj,
900 const JavaParamRef<jobject>& motion_event,
901 jlong time_ms,
902 jint android_action,
903 jint pointer_count,
904 jint history_size,
905 jint action_index,
906 jfloat pos_x_0,
907 jfloat pos_y_0,
908 jfloat pos_x_1,
909 jfloat pos_y_1,
910 jint pointer_id_0,
911 jint pointer_id_1,
912 jfloat touch_major_0,
913 jfloat touch_major_1,
914 jfloat touch_minor_0,
915 jfloat touch_minor_1,
916 jfloat orientation_0,
917 jfloat orientation_1,
918 jfloat tilt_0,
919 jfloat tilt_1,
920 jfloat raw_pos_x,
921 jfloat raw_pos_y,
922 jint android_tool_type_0,
923 jint android_tool_type_1,
924 jint android_button_state,
925 jint android_meta_state,
926 jboolean is_touch_handle_event) {
927 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
928 // Avoid synthesizing a touch event if it cannot be forwarded.
929 if (!rwhv)
930 return false;
931
932 MotionEventAndroid::Pointer pointer0(pointer_id_0,
933 pos_x_0,
934 pos_y_0,
935 touch_major_0,
936 touch_minor_0,
937 orientation_0,
938 tilt_0,
939 android_tool_type_0);
940 MotionEventAndroid::Pointer pointer1(pointer_id_1,
941 pos_x_1,
942 pos_y_1,
943 touch_major_1,
944 touch_minor_1,
945 orientation_1,
946 tilt_1,
947 android_tool_type_1);
948 MotionEventAndroid event(1.f / dpi_scale(),
949 env,
950 motion_event,
951 time_ms,
952 android_action,
953 pointer_count,
954 history_size,
955 action_index,
956 android_button_state,
957 android_meta_state,
958 raw_pos_x - pos_x_0,
959 raw_pos_y - pos_y_0,
960 &pointer0,
961 &pointer1);
962
963 RecordToolTypeForActionDown(event);
964
965 return is_touch_handle_event ? rwhv->OnTouchHandleEvent(event)
966 : rwhv->OnTouchEvent(event);
967 }
968
969 jboolean ContentViewCoreImpl::SendMouseEvent( 897 jboolean ContentViewCoreImpl::SendMouseEvent(
970 JNIEnv* env, 898 JNIEnv* env,
971 const JavaParamRef<jobject>& obj, 899 const JavaParamRef<jobject>& obj,
972 jlong time_ms, 900 jlong time_ms,
973 jint android_action, 901 jint android_action,
974 jfloat x, 902 jfloat x,
975 jfloat y, 903 jfloat y,
976 jint pointer_id, 904 jint pointer_id,
977 jfloat pressure, 905 jfloat pressure,
978 jfloat orientation, 906 jfloat orientation,
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
1551 return ScopedJavaLocalRef<jobject>(); 1479 return ScopedJavaLocalRef<jobject>();
1552 1480
1553 return view->GetJavaObject(); 1481 return view->GetJavaObject();
1554 } 1482 }
1555 1483
1556 bool RegisterContentViewCore(JNIEnv* env) { 1484 bool RegisterContentViewCore(JNIEnv* env) {
1557 return RegisterNativesImpl(env); 1485 return RegisterNativesImpl(env);
1558 } 1486 }
1559 1487
1560 } // namespace content 1488 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698