Chromium Code Reviews| Index: ui/views/view.h |
| diff --git a/ui/views/view.h b/ui/views/view.h |
| index 3d0a8b544145fc23a7a42aae5830e89e928c8c9a..ec9d7069a1528508fd89b50661801dfd6286bc40 100644 |
| --- a/ui/views/view.h |
| +++ b/ui/views/view.h |
| @@ -449,6 +449,16 @@ class VIEWS_EXPORT View : public ui::LayerDelegate, |
| const View* target, |
| gfx::Point* point); |
| + // Convert |rect| from the coordinate system of |source| to the coordinate |
| + // system of |target|. |
| + // |
| + // |source| and |target| must be in the same widget, but doesn't need to be in |
| + // the same view hierarchy. |
| + // |source| can be NULL in which case it means the screen coordinate system. |
| + static void ConvertRectToTarget(const View* source, |
| + const View* target, |
| + gfx::Rect* rect); |
| + |
| // Convert a point from a View's coordinate system to that of its Widget. |
| static void ConvertPointToWidget(const View* src, gfx::Point* point); |
| @@ -549,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 kViewsFuzzingOverlap 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 |
| @@ -960,6 +978,22 @@ class VIEWS_EXPORT View : public ui::LayerDelegate, |
| virtual int GetLineScrollIncrement(ScrollView* scroll_view, |
| bool is_horizontal, bool is_positive); |
| + // Views fuzzing ------------------------------------------------------------- |
| + // Helper functions used by the views fuzzing algorithm. |
| + |
| + // Returns true if |rect| is 1x1. |
| + static bool UsePointBasedTargeting(const gfx::Rect& rect); |
|
sky
2013/10/04 17:03:49
Other than UsePointBasedTargeting does any of this
tdanderson
2013/10/07 21:35:21
Moved these into ui/views/rect_based_targeting_uti
|
| + |
| + // Returns the percentage of |rect_1|'s area that is covered by |rect_2|. |
| + static float PercentCoveredBy(const gfx::Rect& rect_1, |
| + const gfx::Rect& rect_2); |
| + |
| + // Returns the square of the distance from |point| to the center line of |
| + // |target_rect|. The center line of a rectangle is obtained by repeatedly |
| + // stripping away 1px borders around the rectangle until a line remains. |
| + static int DistanceSquaredFromCenterLineToPoint(const gfx::Point& point, |
| + const gfx::Rect& target_rect); |
| + |
| protected: |
| // Used to track a drag. RootView passes this into |
| // ProcessMousePressed/Dragged. |
| @@ -1306,10 +1340,21 @@ class VIEWS_EXPORT View : public ui::LayerDelegate, |
| // Convert a point in the ancestor's coordinate system to the view's |
| // coordinate system using necessary transformations. Returns whether the |
| - // point was successfully from the ancestor's coordinate system to the view's |
| - // coordinate system. |
| + // point was successfully converted from the ancestor's coordinate system |
| + // to the view's coordinate system. |
| bool ConvertPointFromAncestor(const View* ancestor, gfx::Point* point) const; |
| + // Convert a rect in the view's coordinate to an ancestor view's coordinate |
| + // system using necessary transformations. Returns whether the rect was |
| + // successfully converted to the ancestor's coordinate system. |
| + bool ConvertRectForAncestor(const View* ancestor, gfx::Rect* rect) const; |
| + |
| + // Convert a rect in the ancestor's coordinate system to the view's |
| + // coordinate system using necessary transformations. Returns whether the |
| + // rect was successfully converted from the ancestor's coordinate system |
| + // to the view's coordinate system. |
| + bool ConvertRectFromAncestor(const View* ancestor, gfx::Rect* rect) const; |
| + |
| // Accelerated painting ------------------------------------------------------ |
| // Creates the layer and related fields for this view. |