Chromium Code Reviews| Index: ui/android/view_android.h |
| diff --git a/ui/android/view_android.h b/ui/android/view_android.h |
| index db49468b86b3b5150cc04b1797516bb4f896661b..3e15f0e5c94d473985f80655d5930cc2ea8510a4 100644 |
| --- a/ui/android/view_android.h |
| +++ b/ui/android/view_android.h |
| @@ -10,6 +10,7 @@ |
| #include "base/android/jni_weak_ref.h" |
| #include "base/memory/ref_counted.h" |
| #include "ui/android/ui_android_export.h" |
| +#include "ui/events/android/motion_event_android.h" |
| #include "ui/gfx/geometry/rect_f.h" |
| namespace cc { |
| @@ -18,10 +19,11 @@ class Layer; |
| namespace ui { |
| +class ViewClient; |
| class WindowAndroid; |
| // A simple container for a UI layer. |
| -// At the root of the hierarchy is a WindowAndroid, when attached. |
| +// At the root of the hierarchy is a ViewRoot, a subclass of ViewAndroid. |
| class UI_ANDROID_EXPORT ViewAndroid { |
| public: |
| // Stores an anchored view to delete itself at the end of its lifetime |
| @@ -54,9 +56,24 @@ 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); |
| + // Basic view bounds information. Used to decide whether the passed events |
| + // should be processed by the view. |
| + class Bounds { |
|
boliu
2017/01/17 16:17:28
there's gfx::Rect, don't need to create your own c
Jinsuk Kim
2017/01/17 23:32:48
Used it at first but switched to my own in order t
|
| + public: |
| + // Used for |width_ | or |height_| to indicate that the bounds is matched |
| + // with that of its parent. |
| + static const int kMatchParent = -1; |
| + |
| + void SetBounds(const gfx::Point& origin, int width, int height); |
| + bool IsInBounds(const MotionEventAndroid& event); |
| + |
| + private: |
| + gfx::Point origin_; |
| + int width_; |
| + int height_; |
| + }; |
| + |
| + explicit ViewAndroid(ViewClient* client); |
| ViewAndroid(); |
| virtual ~ViewAndroid(); |
| @@ -75,18 +92,28 @@ class UI_ANDROID_EXPORT ViewAndroid { |
| // if disconnected. |
| virtual WindowAndroid* GetWindowAndroid() const; |
| + // Returns |ViewRoot| of this hierarchy. |null| if the hierarchy isn't |
| + // attached to a |ViewRoot|. |
| + virtual ViewAndroid* GetViewRoot(); |
| + |
| // Used to return and set the layer for this view. May be |null|. |
| cc::Layer* GetLayer() const; |
| void SetLayer(scoped_refptr<cc::Layer> layer); |
| void SetDelegate(const base::android::JavaRef<jobject>& delegate); |
| - // Adds this view as a child of another view. |
| + // Adds a child to this view. |
| void AddChild(ViewAndroid* child); |
| // Detaches this view from its parent. |
| void RemoveFromParent(); |
| + // Set the bounds used to do hit testing against motion events. |
| + void SetBounds(const gfx::Point& origin, int width, int height); |
| + |
| + // Returns true if the event hits the area of this view defined by |bounds_|. |
| + bool IsInBounds(const MotionEventAndroid& event); |
| + |
| bool StartDragAndDrop(const base::android::JavaRef<jstring>& jtext, |
| const base::android::JavaRef<jobject>& jimage); |
| @@ -95,9 +122,17 @@ class UI_ANDROID_EXPORT ViewAndroid { |
| const gfx::RectF& bounds); |
| protected: |
| - ViewAndroid* parent_; |
| + // Internal implementation of ViewClient forwarding calls to the interface. |
| + bool OnTouchEventInternal(const MotionEventAndroid& event, |
| + bool is_touch_handle_event); |
| + |
| + // The child view at the front of the list receives event first. |
| + std::list<ViewAndroid*> children_; |
| private: |
| + // Returns true only if this is of type |ViewRoot|. |
| + bool IsViewRoot(); |
| + |
| void RemoveChild(ViewAndroid* child); |
| // Returns the Java delegate for this view. This is used to delegate work |
| @@ -106,9 +141,12 @@ class UI_ANDROID_EXPORT ViewAndroid { |
| const base::android::ScopedJavaLocalRef<jobject> |
| GetViewAndroidDelegate() const; |
| - std::list<ViewAndroid*> children_; |
| + ViewAndroid* parent_; |
| scoped_refptr<cc::Layer> layer_; |
| JavaObjectWeakGlobalRef delegate_; |
| + ViewClient* const client_; |
| + Bounds bounds_; |
| + |
| gfx::Vector2dF content_offset_; // in CSS pixel |
| DISALLOW_COPY_AND_ASSIGN(ViewAndroid); |