Chromium Code Reviews| Index: ui/android/event_handler.cc |
| diff --git a/ui/android/event_handler.cc b/ui/android/event_handler.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4243f182759b1695e2823a635b6b4003bb7e575d |
| --- /dev/null |
| +++ b/ui/android/event_handler.cc |
| @@ -0,0 +1,91 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ui/android/event_handler.h" |
| + |
| +#include "base/android/jni_android.h" |
| +#include "jni/EventHandler_jni.h" |
| +#include "ui/android/view_android.h" |
| +#include "ui/android/view_client.h" |
| +#include "ui/events/android/motion_event_android.h" |
| + |
| +namespace ui { |
| + |
| +using base::android::JavaParamRef; |
| +using base::android::ScopedJavaLocalRef; |
| + |
| +EventHandler* EventHandler::Create(ViewAndroid* view) { |
| + return new EventHandler(view); |
| +} |
| + |
| +EventHandler::EventHandler(ViewAndroid* view) : view_(view) {} |
| + |
| +ScopedJavaLocalRef<jobject> EventHandler::CreateJavaObject() { |
|
boliu
2017/03/02 20:58:14
should create only one java side for each native s
Jinsuk Kim
2017/03/03 06:29:21
Done.
|
| + return Java_EventHandler_create(base::android::AttachCurrentThread(), |
| + reinterpret_cast<intptr_t>(this)); |
| +} |
| + |
| +jboolean EventHandler::OnTouchEvent(JNIEnv* env, |
| + const JavaParamRef<jobject>& obj, |
| + const JavaParamRef<jobject>& motion_event, |
| + jlong time_ms, |
| + jint android_action, |
| + jint pointer_count, |
| + jint history_size, |
| + jint action_index, |
| + jfloat pos_x_0, |
| + jfloat pos_y_0, |
| + jfloat pos_x_1, |
| + jfloat pos_y_1, |
| + jint pointer_id_0, |
| + jint pointer_id_1, |
| + jfloat touch_major_0, |
| + jfloat touch_major_1, |
| + jfloat touch_minor_0, |
| + jfloat touch_minor_1, |
| + jfloat orientation_0, |
| + jfloat orientation_1, |
| + jfloat tilt_0, |
| + jfloat tilt_1, |
| + jfloat raw_pos_x, |
| + jfloat raw_pos_y, |
| + jint android_tool_type_0, |
| + jint android_tool_type_1, |
| + jint android_button_state, |
| + jint android_meta_state, |
| + jboolean is_touch_handle_event) { |
| + return view_->OnTouchEvent(MotionEventData::ForTouch( |
| + view_->GetDipScale(), motion_event.obj(), time_ms, android_action, |
| + pointer_count, history_size, action_index, pos_x_0, pos_y_0, pos_x_1, |
| + pos_y_1, pointer_id_0, pointer_id_1, touch_major_0, touch_major_1, |
| + touch_minor_0, touch_minor_1, orientation_0, orientation_1, tilt_0, |
| + tilt_1, raw_pos_x, raw_pos_y, android_tool_type_0, android_tool_type_1, |
| + android_button_state, android_meta_state, is_touch_handle_event)); |
| +} |
| + |
| +void EventHandler::OnMouseEvent(JNIEnv* env, |
| + const JavaParamRef<jobject>& obj, |
| + jlong time_ms, |
| + jint android_action, |
| + jfloat x, |
| + jfloat y, |
| + jint pointer_id, |
| + jfloat orientation, |
| + jfloat pressure, |
| + jfloat tilt, |
| + jint android_action_button, |
| + jint android_button_state, |
| + jint android_meta_state, |
| + jint android_tool_type) { |
| + view_->OnMouseEvent(MotionEventData::ForMouse( |
| + view_->GetDipScale(), time_ms, android_action, x, y, pointer_id, |
| + orientation, pressure, tilt, android_action_button, android_button_state, |
| + android_meta_state, android_tool_type)); |
| +} |
| + |
| +bool RegisterEventHandler(JNIEnv* env) { |
| + return RegisterNativesImpl(env); |
| +} |
| + |
| +} // namespace ui |