diff options
author | tdanderson@chromium.org <tdanderson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-03 19:59:25 +0000 |
---|---|---|
committer | tdanderson@chromium.org <tdanderson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-03 19:59:25 +0000 |
commit | 3ebcdf15906e2cd2e99593eea2085413d7783673 (patch) | |
tree | 899bb8878f0aa6f08299c9f9775f9df8d02bf866 /ui/views/view_targeter.h | |
parent | f7a1e75b15a808160fce0688e9bbdc4e1a423800 (diff) | |
download | chromium_src-3ebcdf15906e2cd2e99593eea2085413d7783673.zip chromium_src-3ebcdf15906e2cd2e99593eea2085413d7783673.tar.gz chromium_src-3ebcdf15906e2cd2e99593eea2085413d7783673.tar.bz2 |
Call into ViewTargeter from View::HitTestRect()
Add a ViewTargeterDelegate member to ViewTargeter, which
is a weak pointer back to the View on which the targeter
is installed. Make RootView subclass ViewTargeterDelegate
so that it can be installed as the delegate on its
ViewTargeter.
Change the default implementation of View::HitTestRect()
to call into the ViewTargeter installed on |this| (or
instead on the ViewTargeter installed on the root view
if |this| does not have its own targeter installed).
This will allow all custom hit-testing logic to be moved
out of View::HitTestRect() overrides and into
ViewTargeterDelegate::DoesIntersectRect() overrides
instead.
BUG=388838
TBR=sky@chromium.org
TEST=ViewTargeterTest.DoesIntersectRect augmented, all existing tests involving hit testing
Review URL: https://codereview.chromium.org/360383002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@281314 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/view_targeter.h')
-rw-r--r-- | ui/views/view_targeter.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/ui/views/view_targeter.h b/ui/views/view_targeter.h index 8273a8a..9aa585b 100644 --- a/ui/views/view_targeter.h +++ b/ui/views/view_targeter.h @@ -11,6 +11,7 @@ namespace views { class View; +class ViewTargeterDelegate; // Contains the logic used to determine the View to which an // event should be dispatched. A ViewTargeter (or one of its @@ -19,9 +20,12 @@ class View; // that View. class VIEWS_EXPORT ViewTargeter : public ui::EventTargeter { public: - ViewTargeter(); + explicit ViewTargeter(ViewTargeterDelegate* delegate); virtual ~ViewTargeter(); + // A call-through to DoesIntersectRect() on |delegate_|. + bool DoesIntersectRect(const View* target, const gfx::Rect& rect) const; + protected: // Returns the location of |event| represented as a rect. If |event| is // a gesture event, its bounding box is returned. Otherwise, a 1x1 rect @@ -43,6 +47,10 @@ class VIEWS_EXPORT ViewTargeter : public ui::EventTargeter { private: View* FindTargetForKeyEvent(View* view, const ui::KeyEvent& key); + // ViewTargeter does not own the |delegate_|, but |delegate_| must + // outlive the targeter. + ViewTargeterDelegate* delegate_; + DISALLOW_COPY_AND_ASSIGN(ViewTargeter); }; |