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

Side by Side Diff: ui/views/view_targeter.h

Issue 401933002: Move views event targeting into ViewTargeterDelegate::TargetForRect() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_VIEWS_VIEW_TARGETER_H_ 5 #ifndef UI_VIEWS_VIEW_TARGETER_H_
6 #define UI_VIEWS_VIEW_TARGETER_H_ 6 #define UI_VIEWS_VIEW_TARGETER_H_
7 7
8 #include "ui/events/event_targeter.h" 8 #include "ui/events/event_targeter.h"
9 #include "ui/views/views_export.h" 9 #include "ui/views/views_export.h"
10 10
11 namespace views { 11 namespace views {
12 12
13 class View; 13 class View;
14 class ViewTargeterDelegate; 14 class ViewTargeterDelegate;
15 15
16 // Contains the logic used to determine the View to which an 16 // Contains the logic used to determine the View to which an
17 // event should be dispatched. A ViewTargeter (or one of its 17 // event should be dispatched. A ViewTargeter (or one of its
18 // derived classes) is installed on a View to specify the 18 // derived classes) is installed on a View to specify the
19 // targeting behaviour to be used for the subtree rooted at 19 // targeting behaviour to be used for the subtree rooted at
20 // that View. 20 // that View.
21 // TODO(tdanderson): Remove overrides of all EventHandler methods except for
22 // FindTargetForEvent() and FindNextBestTarget().
21 class VIEWS_EXPORT ViewTargeter : public ui::EventTargeter { 23 class VIEWS_EXPORT ViewTargeter : public ui::EventTargeter {
22 public: 24 public:
23 explicit ViewTargeter(ViewTargeterDelegate* delegate); 25 explicit ViewTargeter(ViewTargeterDelegate* delegate);
24 virtual ~ViewTargeter(); 26 virtual ~ViewTargeter();
25 27
26 // A call-through to DoesIntersectRect() on |delegate_|. 28 // A call-through to DoesIntersectRect() on |delegate_|.
27 bool DoesIntersectRect(const View* target, const gfx::Rect& rect) const; 29 bool DoesIntersectRect(const View* target, const gfx::Rect& rect) const;
28 30
31 // A call-through to TargetForRect() on |delegate_|.
32 View* TargetForRect(View* root, const gfx::Rect& rect) const;
33
29 protected: 34 protected:
30 // Returns the location of |event| represented as a rect. If |event| is 35 // Returns the location of |event| represented as a rect. If |event| is
31 // a gesture event, its bounding box is returned. Otherwise, a 1x1 rect 36 // a gesture event, its bounding box is returned. Otherwise, a 1x1 rect
32 // having its origin at the location of |event| is returned. 37 // having its origin at the location of |event| is returned.
33 gfx::RectF BoundsForEvent(const ui::LocatedEvent& event) const; 38 gfx::RectF BoundsForEvent(const ui::LocatedEvent& event) const;
34 39
35 // ui::EventTargeter: 40 // ui::EventTargeter:
36 virtual ui::EventTarget* FindTargetForEvent(ui::EventTarget* root, 41 virtual ui::EventTarget* FindTargetForEvent(ui::EventTarget* root,
37 ui::Event* event) OVERRIDE; 42 ui::Event* event) OVERRIDE;
38 virtual ui::EventTarget* FindNextBestTarget(ui::EventTarget* previous_target, 43 virtual ui::EventTarget* FindNextBestTarget(ui::EventTarget* previous_target,
(...skipping 11 matching lines...) Expand all
50 // ViewTargeter does not own the |delegate_|, but |delegate_| must 55 // ViewTargeter does not own the |delegate_|, but |delegate_| must
51 // outlive the targeter. 56 // outlive the targeter.
52 ViewTargeterDelegate* delegate_; 57 ViewTargeterDelegate* delegate_;
53 58
54 DISALLOW_COPY_AND_ASSIGN(ViewTargeter); 59 DISALLOW_COPY_AND_ASSIGN(ViewTargeter);
55 }; 60 };
56 61
57 } // namespace views 62 } // namespace views
58 63
59 #endif // UI_VIEWS_VIEW_TARGETER_H_ 64 #endif // UI_VIEWS_VIEW_TARGETER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698