Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 // A ViewTargeter is installed on a derived class of View that wishes to use |
|
sadrul
2014/07/29 18:06:50
's/derived class of//'
You should be able to inst
tdanderson
2014/07/29 19:40:45
Yep, this was careless wording on my part. Fixed.
| |
| 17 // event should be dispatched. A ViewTargeter (or one of its | 17 // the custom hit-testing or event-targeting behaviour defined by |delegate|. |
| 18 // derived classes) is installed on a View to specify the | |
| 19 // targeting behaviour to be used for the subtree rooted at | |
| 20 // that View. | |
| 21 // TODO(tdanderson): Remove overrides of all EventHandler methods except for | |
| 22 // FindTargetForEvent() and FindNextBestTarget(). | |
| 23 class VIEWS_EXPORT ViewTargeter : public ui::EventTargeter { | 18 class VIEWS_EXPORT ViewTargeter : public ui::EventTargeter { |
| 24 public: | 19 public: |
| 25 explicit ViewTargeter(ViewTargeterDelegate* delegate); | 20 explicit ViewTargeter(ViewTargeterDelegate* delegate); |
| 26 virtual ~ViewTargeter(); | 21 virtual ~ViewTargeter(); |
| 27 | 22 |
| 28 // A call-through to DoesIntersectRect() on |delegate_|. | 23 // A call-through to DoesIntersectRect() on |delegate_|. |
| 29 bool DoesIntersectRect(const View* target, const gfx::Rect& rect) const; | 24 bool DoesIntersectRect(const View* target, const gfx::Rect& rect) const; |
| 30 | 25 |
| 31 // A call-through to TargetForRect() on |delegate_|. | 26 // A call-through to TargetForRect() on |delegate_|. |
| 32 View* TargetForRect(View* root, const gfx::Rect& rect) const; | 27 View* TargetForRect(View* root, const gfx::Rect& rect) const; |
| 33 | 28 |
| 34 protected: | 29 protected: |
| 35 // Returns the location of |event| represented as a rect. If |event| is | |
| 36 // a gesture event, its bounding box is returned. Otherwise, a 1x1 rect | |
| 37 // having its origin at the location of |event| is returned. | |
| 38 gfx::RectF BoundsForEvent(const ui::LocatedEvent& event) const; | |
| 39 | |
| 40 // ui::EventTargeter: | 30 // ui::EventTargeter: |
| 41 virtual ui::EventTarget* FindTargetForEvent(ui::EventTarget* root, | 31 virtual ui::EventTarget* FindTargetForEvent(ui::EventTarget* root, |
| 42 ui::Event* event) OVERRIDE; | 32 ui::Event* event) OVERRIDE; |
| 43 virtual ui::EventTarget* FindNextBestTarget(ui::EventTarget* previous_target, | 33 virtual ui::EventTarget* FindNextBestTarget(ui::EventTarget* previous_target, |
| 44 ui::Event* event) OVERRIDE; | 34 ui::Event* event) OVERRIDE; |
| 45 virtual bool SubtreeCanAcceptEvent( | |
|
sadrul
2014/07/29 18:06:50
How about keeping these with NOTREACHED()?
tdanderson
2014/07/29 19:40:45
Sure, seems reasonable. We can remove them entirel
| |
| 46 ui::EventTarget* target, | |
| 47 const ui::LocatedEvent& event) const OVERRIDE; | |
| 48 virtual bool EventLocationInsideBounds( | |
| 49 ui::EventTarget* target, | |
| 50 const ui::LocatedEvent& event) const OVERRIDE; | |
| 51 | 35 |
| 52 private: | 36 private: |
| 53 View* FindTargetForKeyEvent(View* view, const ui::KeyEvent& key); | 37 View* FindTargetForKeyEvent(View* root, const ui::KeyEvent& key); |
| 38 View* FindTargetForScrollEvent(View* root, const ui::ScrollEvent& scroll); | |
| 54 | 39 |
| 55 // ViewTargeter does not own the |delegate_|, but |delegate_| must | 40 // ViewTargeter does not own the |delegate_|, but |delegate_| must |
| 56 // outlive the targeter. | 41 // outlive the targeter. |
| 57 ViewTargeterDelegate* delegate_; | 42 ViewTargeterDelegate* delegate_; |
| 58 | 43 |
| 59 DISALLOW_COPY_AND_ASSIGN(ViewTargeter); | 44 DISALLOW_COPY_AND_ASSIGN(ViewTargeter); |
| 60 }; | 45 }; |
| 61 | 46 |
| 62 } // namespace views | 47 } // namespace views |
| 63 | 48 |
| 64 #endif // UI_VIEWS_VIEW_TARGETER_H_ | 49 #endif // UI_VIEWS_VIEW_TARGETER_H_ |
| OLD | NEW |