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

Unified Diff: ui/android/view_android.h

Issue 2708613002: Add EventForwarder for routing touch events (Closed)
Patch Set: EventHandler 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 side-by-side diff with in-line comments
Download patch
Index: ui/android/view_android.h
diff --git a/ui/android/view_android.h b/ui/android/view_android.h
index 0abd77cdc40d55152a13aa423e46c79d90082f0c..84e4b167f03f04b7db6f178a06b76b7e8847645b 100644
--- a/ui/android/view_android.h
+++ b/ui/android/view_android.h
@@ -20,6 +20,9 @@ class Layer;
namespace ui {
+class EventHandler;
+class MotionEventAndroid;
+class ViewClient;
class WindowAndroid;
// A simple container for a UI layer.
@@ -56,9 +59,7 @@ class UI_ANDROID_EXPORT ViewAndroid {
// Default copy/assign disabled by move constructor.
};
- // A ViewAndroid may have its own delegate or otherwise will
- // use the next available parent's delegate.
- ViewAndroid(const base::android::JavaRef<jobject>& delegate);
+ explicit ViewAndroid(ViewClient* view_client);
ViewAndroid();
virtual ~ViewAndroid();
@@ -83,7 +84,11 @@ class UI_ANDROID_EXPORT ViewAndroid {
void SetDelegate(const base::android::JavaRef<jobject>& delegate);
- // Adds this view as a child of another view.
+ // Creates |EventHandler| for a view tree below (not including) WindowAndroid.
+ // Only one instance per the view tree is allowed at its top VA.
+ EventHandler* CreateEventHandler();
+
+ // Adds a child to this view.
void AddChild(ViewAndroid* child);
// Detaches this view from its parent.
@@ -106,12 +111,23 @@ class UI_ANDROID_EXPORT ViewAndroid {
// This may return null.
base::android::ScopedJavaLocalRef<jobject> GetContainerView();
+ bool OnTouchEvent(const MotionEventAndroid& event,
+ bool is_touch_handle_event);
+ bool OnMouseEvent(const MotionEventAndroid& event, int action_button);
+
+ // Virtual for testing.
+ virtual float GetDipScale();
+
protected:
ViewAndroid* parent_;
private:
void RemoveChild(ViewAndroid* child);
+ bool has_event_handler() const { return !!event_handler_; }
+
+ static bool ViewTreeHasEventHandler(ViewAndroid* view);
+
// Returns the Java delegate for this view. This is used to delegate work
// up to the embedding view (or the embedder that can deal with the
// implementation details).
@@ -121,7 +137,12 @@ class UI_ANDROID_EXPORT ViewAndroid {
std::list<ViewAndroid*> children_;
scoped_refptr<cc::Layer> layer_;
JavaObjectWeakGlobalRef delegate_;
- gfx::Vector2dF content_offset_; // in CSS pixel
+
+ ViewClient* const client_;
+
+ gfx::Vector2dF content_offset_; // in CSS pixel.
+ std::unique_ptr<EventHandler> event_handler_;
+ float dip_scale_;
DISALLOW_COPY_AND_ASSIGN(ViewAndroid);
};

Powered by Google App Engine
This is Rietveld 408576698