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

Side by Side Diff: ui/android/view_android.h

Issue 2896993002: Route OnDragEvent through ViewAndroid tree (Closed)
Patch Set: +ui/base Created 3 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef UI_ANDROID_VIEW_ANDROID_H_ 5 #ifndef UI_ANDROID_VIEW_ANDROID_H_
6 #define UI_ANDROID_VIEW_ANDROID_H_ 6 #define UI_ANDROID_VIEW_ANDROID_H_
7 7
8 #include <list> 8 #include <list>
9 9
10 #include "base/android/jni_weak_ref.h" 10 #include "base/android/jni_weak_ref.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "ui/android/ui_android_export.h" 13 #include "ui/android/ui_android_export.h"
14 #include "ui/gfx/geometry/rect_f.h" 14 #include "ui/gfx/geometry/rect_f.h"
15 15
16 namespace cc { 16 namespace cc {
17 class Layer; 17 class Layer;
18 } 18 }
19 19
20 namespace ui { 20 namespace ui {
21 class DragEventAndroid;
21 class EventForwarder; 22 class EventForwarder;
22 class MotionEventAndroid; 23 class MotionEventAndroid;
23 class ViewClient; 24 class ViewClient;
24 class WindowAndroid; 25 class WindowAndroid;
25 26
26 // A simple container for a UI layer. 27 // A simple container for a UI layer.
27 // At the root of the hierarchy is a WindowAndroid, when attached. 28 // At the root of the hierarchy is a WindowAndroid, when attached.
28 // Dispatches input/view events coming from Java layer. Hit testing against 29 // Dispatches input/view events coming from Java layer. Hit testing against
29 // those events is implemented so that the |ViewClient| will be invoked 30 // those events is implemented so that the |ViewClient| will be invoked
30 // when the event got hit on the area defined by |layout_params_|. 31 // when the event got hit on the area defined by |layout_params_|.
(...skipping 25 matching lines...) Expand all
56 // TODO(jinsukkim): Following weak refs can be cast to strong refs which 57 // TODO(jinsukkim): Following weak refs can be cast to strong refs which
57 // cannot be garbage-collected and leak memory. Rewrite not to use them. 58 // cannot be garbage-collected and leak memory. Rewrite not to use them.
58 // see comments in crrev.com/2103243002. 59 // see comments in crrev.com/2103243002.
59 JavaObjectWeakGlobalRef view_; 60 JavaObjectWeakGlobalRef view_;
60 JavaObjectWeakGlobalRef delegate_; 61 JavaObjectWeakGlobalRef delegate_;
61 62
62 // Default copy/assign disabled by move constructor. 63 // Default copy/assign disabled by move constructor.
63 }; 64 };
64 65
65 // Layout parameters used to set the view's position and size. 66 // Layout parameters used to set the view's position and size.
66 // Position is in parent's coordinate space. 67 // Position is in parent's coordinate space, and all the values
68 // are in CSS pixel.
67 struct LayoutParams { 69 struct LayoutParams {
68 static LayoutParams MatchParent() { return {true, 0, 0, 0, 0}; } 70 static LayoutParams MatchParent() { return {true, 0, 0, 0, 0}; }
69 static LayoutParams Normal(int x, int y, int width, int height) { 71 static LayoutParams Normal(int x, int y, int width, int height) {
70 return {false, x, y, width, height}; 72 return {false, x, y, width, height};
71 }; 73 };
72 74
73 bool match_parent; // Bounds matches that of the parent if true. 75 bool match_parent; // Bounds matches that of the parent if true.
74 int x; 76 int x;
75 int y; 77 int y;
76 int width; 78 int width;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 153
152 float GetDipScale(); 154 float GetDipScale();
153 155
154 protected: 156 protected:
155 ViewAndroid* parent_; 157 ViewAndroid* parent_;
156 158
157 private: 159 private:
158 friend class EventForwarder; 160 friend class EventForwarder;
159 friend class ViewAndroidBoundsTest; 161 friend class ViewAndroidBoundsTest;
160 162
161 using ViewClientCallback = 163 bool OnDragEvent(const DragEventAndroid& event);
162 const base::Callback<bool(ViewClient*, const MotionEventAndroid&)>;
163
164 bool OnTouchEvent(const MotionEventAndroid& event, bool for_touch_handle); 164 bool OnTouchEvent(const MotionEventAndroid& event, bool for_touch_handle);
165 bool OnMouseEvent(const MotionEventAndroid& event); 165 bool OnMouseEvent(const MotionEventAndroid& event);
166 bool OnMouseWheelEvent(const MotionEventAndroid& event); 166 bool OnMouseWheelEvent(const MotionEventAndroid& event);
167 167
168 void RemoveChild(ViewAndroid* child); 168 void RemoveChild(ViewAndroid* child);
169 169
170 bool HitTest(ViewClientCallback send_to_client, 170 template <typename E>
171 const MotionEventAndroid& event); 171 using ViewClientCallback =
172 const base::Callback<bool(ViewClient*, const E&, const gfx::PointF&)>;
172 173
174 template <typename E>
175 bool HitTest(ViewClientCallback<E> send_to_client,
176 const E& event,
177 const gfx::PointF& point);
178
179 static bool SendDragEventToClient(ViewClient* client,
180 const DragEventAndroid& event,
181 const gfx::PointF& point);
173 static bool SendTouchEventToClient(bool for_touch_handle, 182 static bool SendTouchEventToClient(bool for_touch_handle,
174 ViewClient* client, 183 ViewClient* client,
175 const MotionEventAndroid& event); 184 const MotionEventAndroid& event,
185 const gfx::PointF& point);
176 static bool SendMouseEventToClient(ViewClient* client, 186 static bool SendMouseEventToClient(ViewClient* client,
177 const MotionEventAndroid& event); 187 const MotionEventAndroid& event,
188 const gfx::PointF& point);
178 static bool SendMouseWheelEventToClient(ViewClient* client, 189 static bool SendMouseWheelEventToClient(ViewClient* client,
179 const MotionEventAndroid& event); 190 const MotionEventAndroid& event,
191 const gfx::PointF& point);
180 192
181 bool has_event_forwarder() const { return !!event_forwarder_; } 193 bool has_event_forwarder() const { return !!event_forwarder_; }
182 194
183 // Checks if there is any event forwarder in any node up to root. 195 // Checks if there is any event forwarder in any node up to root.
184 static bool RootPathHasEventForwarder(ViewAndroid* view); 196 static bool RootPathHasEventForwarder(ViewAndroid* view);
185 197
186 // Checks if there is any event forwarder in the node paths down to 198 // Checks if there is any event forwarder in the node paths down to
187 // each leaf of subtree. 199 // each leaf of subtree.
188 static bool SubtreeHasEventForwarder(ViewAndroid* view); 200 static bool SubtreeHasEventForwarder(ViewAndroid* view);
189 201
(...skipping 17 matching lines...) Expand all
207 219
208 gfx::Vector2dF content_offset_; // in CSS pixel. 220 gfx::Vector2dF content_offset_; // in CSS pixel.
209 std::unique_ptr<EventForwarder> event_forwarder_; 221 std::unique_ptr<EventForwarder> event_forwarder_;
210 222
211 DISALLOW_COPY_AND_ASSIGN(ViewAndroid); 223 DISALLOW_COPY_AND_ASSIGN(ViewAndroid);
212 }; 224 };
213 225
214 } // namespace ui 226 } // namespace ui
215 227
216 #endif // UI_ANDROID_VIEW_ANDROID_H_ 228 #endif // UI_ANDROID_VIEW_ANDROID_H_
OLDNEW
« no previous file with comments | « ui/android/java/src/org/chromium/ui/base/EventForwarder.java ('k') | ui/android/view_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698