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

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

Issue 1119423003: Refactors away method implementations in ui::EventTargeter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactors ui::EventTargeter (rebased) Created 5 years, 6 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
« no previous file with comments | « ui/views/test/event_generator_delegate_mac.mm ('k') | ui/views/view_targeter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/macros.h"
8 #include "ui/events/event_targeter.h" 9 #include "ui/events/event_targeter.h"
9 #include "ui/views/views_export.h" 10 #include "ui/views/views_export.h"
10 11
12 namespace gfx {
13 class Rect;
14 } // namespace gfx
15
16 namespace ui {
17 class GestureEvent;
18 class KeyEvent;
19 class ScrollEvent;
20 } // namespace ui
21
11 namespace views { 22 namespace views {
12 23
13 namespace internal { 24 namespace internal {
14 class RootView; 25 class RootView;
15 } // namespace internal 26 } // namespace internal
16 27
17 class View; 28 class View;
18 class ViewTargeterDelegate; 29 class ViewTargeterDelegate;
19 30
20 // A ViewTargeter is installed on a View that wishes to use the custom 31 // A ViewTargeter is installed on a View that wishes to use the custom
21 // hit-testing or event-targeting behaviour defined by |delegate|. 32 // hit-testing or event-targeting behaviour defined by |delegate|.
22 class VIEWS_EXPORT ViewTargeter : public ui::EventTargeter { 33 class VIEWS_EXPORT ViewTargeter : public ui::EventTargeter {
23 public: 34 public:
24 explicit ViewTargeter(ViewTargeterDelegate* delegate); 35 explicit ViewTargeter(ViewTargeterDelegate* delegate);
25 ~ViewTargeter() override; 36 ~ViewTargeter() override;
26 37
27 // A call-through to DoesIntersectRect() on |delegate_|. 38 // A call-through to DoesIntersectRect() on |delegate_|.
28 bool DoesIntersectRect(const View* target, const gfx::Rect& rect) const; 39 bool DoesIntersectRect(const View* target, const gfx::Rect& rect) const;
29 40
30 // A call-through to TargetForRect() on |delegate_|. 41 // A call-through to TargetForRect() on |delegate_|.
31 View* TargetForRect(View* root, const gfx::Rect& rect) const; 42 View* TargetForRect(View* root, const gfx::Rect& rect) const;
32 43
33 protected: 44 protected:
34 // ui::EventTargeter: 45 // ui::EventTargeter:
35 ui::EventTarget* FindTargetForEvent(ui::EventTarget* root, 46 ui::EventTarget* FindTargetForEvent(ui::EventTarget* root,
36 ui::Event* event) override; 47 ui::Event* event) override;
37 ui::EventTarget* FindNextBestTarget(ui::EventTarget* previous_target, 48 ui::EventTarget* FindNextBestTarget(ui::EventTarget* previous_target,
38 ui::Event* event) override; 49 ui::Event* event) override;
39 bool SubtreeCanAcceptEvent(ui::EventTarget* target,
40 const ui::LocatedEvent& event) const override;
41 bool EventLocationInsideBounds(ui::EventTarget* target,
42 const ui::LocatedEvent& event) const override;
43 50
44 private: 51 private:
45 View* FindTargetForKeyEvent(View* root, const ui::KeyEvent& key); 52 View* FindTargetForKeyEvent(View* root, const ui::KeyEvent& key);
46 View* FindTargetForScrollEvent(View* root, const ui::ScrollEvent& scroll); 53 View* FindTargetForScrollEvent(View* root, const ui::ScrollEvent& scroll);
47 54
48 virtual View* FindTargetForGestureEvent(View* root, 55 virtual View* FindTargetForGestureEvent(View* root,
49 const ui::GestureEvent& gesture); 56 const ui::GestureEvent& gesture);
50 virtual ui::EventTarget* FindNextBestTargetForGestureEvent( 57 virtual ui::EventTarget* FindNextBestTargetForGestureEvent(
51 ui::EventTarget* previous_target, 58 ui::EventTarget* previous_target,
52 const ui::GestureEvent& gesture); 59 const ui::GestureEvent& gesture);
53 60
54 // ViewTargeter does not own the |delegate_|, but |delegate_| must 61 // ViewTargeter does not own the |delegate_|, but |delegate_| must
55 // outlive the targeter. 62 // outlive the targeter.
56 ViewTargeterDelegate* delegate_; 63 ViewTargeterDelegate* delegate_;
57 64
58 DISALLOW_COPY_AND_ASSIGN(ViewTargeter); 65 DISALLOW_COPY_AND_ASSIGN(ViewTargeter);
59 }; 66 };
60 67
61 } // namespace views 68 } // namespace views
62 69
63 #endif // UI_VIEWS_VIEW_TARGETER_H_ 70 #endif // UI_VIEWS_VIEW_TARGETER_H_
OLDNEW
« no previous file with comments | « ui/views/test/event_generator_delegate_mac.mm ('k') | ui/views/view_targeter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698