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

Side by Side Diff: ui/android/view_root.cc

Issue 2645353004: ViewRoot class for event forwarding on Android (Closed)
Patch Set: fix tests 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/android/view_root.h"
6
7 #include "jni/ViewRoot_jni.h"
8
9 namespace ui {
10
11 using base::android::JavaParamRef;
12
13 ViewRoot::ViewRoot(jlong window_android_ptr) {
14 WindowAndroid* window_android =
15 reinterpret_cast<WindowAndroid*>(window_android_ptr);
16 window_ = window_android;
17
18 // ViewRoot simply accepts all events and lets the hit testing
19 // start from its children.
20 SetBounds(gfx::Point(), Bounds::kMatchParent, Bounds::kMatchParent);
21 }
22
23 void ViewRoot::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) {
24 delete this;
25 }
26
27 ViewAndroid* ViewRoot::GetViewRoot() {
28 return this;
29 }
30
31 WindowAndroid* ViewRoot::GetWindowAndroid() const {
32 return window_;
33 }
34
35 void ViewRoot::MoveToFront(ViewAndroid* child) {
36 DCHECK(child);
37 auto it = std::find(children_.begin(), children_.end(), child);
38 DCHECK(it != children_.end());
39
40 if (it != children_.begin())
41 children_.splice(children_.begin(), children_, it);
42 }
43
44 jboolean ViewRoot::OnTouchEvent(JNIEnv* env,
45 const JavaParamRef<jobject>& obj,
46 const JavaParamRef<jobject>& motion_event,
47 jlong time_ms,
48 jint android_action,
49 jint pointer_count,
50 jint history_size,
51 jint action_index,
52 jfloat pos_x_0,
53 jfloat pos_y_0,
54 jfloat pos_x_1,
55 jfloat pos_y_1,
56 jint pointer_id_0,
57 jint pointer_id_1,
58 jfloat touch_major_0,
59 jfloat touch_major_1,
60 jfloat touch_minor_0,
61 jfloat touch_minor_1,
62 jfloat orientation_0,
63 jfloat orientation_1,
64 jfloat tilt_0,
65 jfloat tilt_1,
66 jfloat raw_pos_x,
67 jfloat raw_pos_y,
68 jint android_tool_type_0,
69 jint android_tool_type_1,
70 jint android_button_state,
71 jint android_meta_state,
72 jboolean is_touch_handle_event) {
73 MotionEventData event(GetDipScale(),
74 motion_event.obj(),
75 time_ms,
76 android_action,
77 pointer_count,
78 history_size,
79 action_index,
80 pos_x_0,
81 pos_y_0,
82 pos_x_1,
83 pos_y_1,
84 pointer_id_0,
85 pointer_id_1,
86 touch_major_0,
87 touch_major_1,
88 touch_minor_0,
89 touch_minor_1,
90 orientation_0,
91 orientation_1,
92 tilt_0,
93 tilt_1,
94 raw_pos_x,
95 raw_pos_y,
96 android_tool_type_0,
97 android_tool_type_1,
98 android_button_state,
99 android_meta_state,
100 is_touch_handle_event);
101 return OnTouchEventInternal(event);
102 }
103
104 // static
105 jlong Init(JNIEnv* env,
106 const JavaParamRef<jobject>& obj,
107 jlong window_android_ptr) {
108 return reinterpret_cast<intptr_t>(new ViewRoot(window_android_ptr));
109 }
110
111 bool RegisterViewRoot(JNIEnv* env) {
112 return RegisterNativesImpl(env);
113 }
114
115 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698