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

Unified Diff: ui/views/view.h

Issue 22891016: Add support for rect-based event targeting in views (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tests added Created 7 years, 2 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/views/view.h
diff --git a/ui/views/view.h b/ui/views/view.h
index d6158534bfde399184b68eb10278b4aba6af363e..29c8c271e2db96e2ada1dd525b8a6319268e2f6a 100644
--- a/ui/views/view.h
+++ b/ui/views/view.h
@@ -559,12 +559,20 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
static bool get_use_acceleration_when_possible();
// Input ---------------------------------------------------------------------
- // The points (and mouse locations) in the following functions are in the
- // view's coordinates, except for a RootView.
+ // The points, rects, mouse locations, and touch locations in the following
+ // functions are in the view's coordinates, except for a RootView.
- // Returns the deepest visible descendant that contains the specified point
- // and supports event handling.
- virtual View* GetEventHandlerForPoint(const gfx::Point& point);
+ // Convenience functions which calls into GetEventHandler() with
+ // a 1x1 rect centered at |point|.
+ View* GetEventHandlerForPoint(const gfx::Point& point);
+
+ // If point-based targeting should be used, return the deepest visible
+ // descendant that contains the center point of |rect|.
+ // If rect-based targeting (i.e., fuzzing) should be used, return the
+ // closest visible descendant having at least kRectTargetOverlap of
+ // its area covered by |rect|. If no such descendant exists, return the
+ // deepest visible descendant that contains the center point of |rect|.
+ virtual View* GetEventHandlerForRect(const gfx::Rect& rect);
// Returns the deepest visible descendant that contains the specified point
// and supports tooltips. If the view does not contain the point, returns
@@ -1118,6 +1126,16 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
// Input ---------------------------------------------------------------------
+ // Specifies the source of the region used in a hit test.
+ // HIT_TEST_SOURCE_MOUSE indicates the hit test is being performed with a
+ // single point and HIT_TEST_SOURCE_TOUCH indicates the hit test is being
+ // performed with a rect larger than a single point. This value can be used,
+ // for example, to add extra padding or change the shape of the hit test mask.
+ enum HitTestSource {
+ HIT_TEST_SOURCE_MOUSE,
+ HIT_TEST_SOURCE_TOUCH
+ };
+
// Called by HitTestRect() to see if this View has a custom hit test mask. If
// the return value is true, GetHitTestMask() will be called to obtain the
// mask. Default value is false, in which case the View will hit-test against
@@ -1126,7 +1144,8 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
// Called by HitTestRect() to retrieve a mask for hit-testing against.
// Subclasses override to provide custom shaped hit test regions.
- virtual void GetHitTestMask(gfx::Path* mask) const;
+ virtual void GetHitTestMask(gfx::Path* mask,
+ HitTestSource source = HIT_TEST_SOURCE_MOUSE) const;
virtual DragInfo* GetDragInfo();

Powered by Google App Engine
This is Rietveld 408576698