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

Unified Diff: ui/android/view_android.h

Issue 2708613002: Add EventForwarder for routing touch events (Closed)
Patch Set: comments 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..8d67e2bb6bd601f038dffde9dc91127229f3ae4a 100644
--- a/ui/android/view_android.h
+++ b/ui/android/view_android.h
@@ -20,7 +20,10 @@ class Layer;
namespace ui {
+class EventHandler;
+class ViewClient;
class WindowAndroid;
+struct MotionEventData;
// A simple container for a UI layer.
// At the root of the hierarchy is a WindowAndroid, when attached.
@@ -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,12 +84,19 @@ 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.
void RemoveFromParent();
+ // Set the layout relative to parent. Used to do hit testing against events.
+ void SetLayout(int x, int y, int width, int height, bool match_parent);
+
bool StartDragAndDrop(const base::android::JavaRef<jstring>& jtext,
const base::android::JavaRef<jobject>& jimage);
@@ -106,12 +114,26 @@ class UI_ANDROID_EXPORT ViewAndroid {
// This may return null.
base::android::ScopedJavaLocalRef<jobject> GetContainerView();
+ bool OnTouchEvent(const MotionEventData& event);
+ bool OnMouseEvent(const MotionEventData& event);
+
+ // Virtual for testing.
+ virtual float GetDipScale();
+
protected:
ViewAndroid* parent_;
private:
+ // Returns the root of this ViewAndroid hierarchy from which events starts
+ // trickling down. Note that it may not be the actual top of the tree.
+ ViewAndroid* GetViewRoot();
+
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 +143,17 @@ 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_;
+
+ // Basic view layout information. Used to do hit testing deciding whether
+ // the passed events should be processed by the view.
+ gfx::Point origin_; // In parent's coordinate space.
+ gfx::Size size_;
+ bool match_parent_; // Bounds matches that of the parent if true.
+
+ gfx::Vector2dF content_offset_; // in CSS pixel.
+ std::unique_ptr<EventHandler> event_handler_;
DISALLOW_COPY_AND_ASSIGN(ViewAndroid);
};

Powered by Google App Engine
This is Rietveld 408576698