OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_EVENTS_EVENT_TARGETER_H_ | 5 #ifndef UI_EVENTS_EVENT_TARGETER_H_ |
6 #define UI_EVENTS_EVENT_TARGETER_H_ | 6 #define UI_EVENTS_EVENT_TARGETER_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "ui/events/event.h" | 9 #include "ui/events/event.h" |
10 #include "ui/events/events_export.h" | 10 #include "ui/events/events_export.h" |
11 | 11 |
12 namespace ui { | 12 namespace ui { |
13 | 13 |
14 class Event; | 14 class Event; |
15 class EventTarget; | 15 class EventTarget; |
16 class LocatedEvent; | |
17 | 16 |
18 class EVENTS_EXPORT EventTargeter { | 17 class EVENTS_EXPORT EventTargeter { |
19 public: | 18 public: |
20 virtual ~EventTargeter(); | 19 virtual ~EventTargeter(); |
21 | 20 |
22 // Returns the target |event| should be dispatched to. If there is no such | 21 // Returns the target |event| should be dispatched to. If there is no such |
23 // target, return NULL. If |event| is a located event, the location of |event| | 22 // target, return NULL. If |event| is a located event, the location of |event| |
24 // is in the coordinate space of |root|. Furthermore, the targeter can mutate | 23 // is in the coordinate space of |root|. Furthermore, the targeter can mutate |
25 // the event (e.g., by changing the location of the event to be in the | 24 // the event (e.g., by changing the location of the event to be in the |
26 // returned target's coordinate space) so that it can be dispatched to the | 25 // returned target's coordinate space) so that it can be dispatched to the |
27 // target without any further modification. | 26 // target without any further modification. |
28 virtual EventTarget* FindTargetForEvent(EventTarget* root, | 27 virtual EventTarget* FindTargetForEvent(EventTarget* root, |
29 Event* event); | 28 Event* event); |
30 | 29 |
31 // Same as FindTargetForEvent(), but used for positional events. The location | |
32 // etc. of |event| are in |root|'s coordinate system. When finding the target | |
33 // for the event, the targeter can mutate the |event| (e.g. change the | |
34 // coordinate to be in the returned target's coordinate system) so that it can | |
35 // be dispatched to the target without any further modification. | |
36 // TODO(tdanderson|sadrul): This should not be in the public API of | |
37 // EventTargeter. | |
38 virtual EventTarget* FindTargetForLocatedEvent(EventTarget* root, | |
39 LocatedEvent* event); | |
40 | |
41 // Returns true if |target| or one of its descendants can be a target of | 30 // Returns true if |target| or one of its descendants can be a target of |
42 // |event|. This requires that |target| and its descendants are not | 31 // |event|. This requires that |target| and its descendants are not |
43 // prohibited from accepting the event, and that the event is within an | 32 // prohibited from accepting the event, and that the event is within an |
44 // actionable region of the target's bounds. Note that the location etc. of | 33 // actionable region of the target's bounds. Note that the location etc. of |
45 // |event| is in |target|'s parent's coordinate system. | 34 // |event| is in |target|'s parent's coordinate system. |
46 // TODO(tdanderson|sadrul): This function should be made non-virtual and | |
47 // non-public. | |
tdanderson
2015/05/07 01:01:26
I don't think SubtreeShouldBeExploredForEvent() be
varkha
2015/05/07 01:15:30
Yes, It should not be here, but that will require
| |
48 virtual bool SubtreeShouldBeExploredForEvent(EventTarget* target, | 35 virtual bool SubtreeShouldBeExploredForEvent(EventTarget* target, |
49 const LocatedEvent& event); | 36 const LocatedEvent& event); |
50 | 37 |
51 // Returns the next best target for |event| as compared to |previous_target|. | 38 // Returns the next best target for |event| as compared to |previous_target|. |
52 // |event| is in the local coordinate space of |previous_target|. | 39 // |event| is in the local coordinate space of |previous_target|. |
53 // Also mutates |event| so that it can be dispatched to the returned target | 40 // Also mutates |event| so that it can be dispatched to the returned target |
54 // (e.g., by changing |event|'s location to be in the returned target's | 41 // (e.g., by changing |event|'s location to be in the returned target's |
55 // coordinate space). | 42 // coordinate space). |
56 virtual EventTarget* FindNextBestTarget(EventTarget* previous_target, | 43 virtual EventTarget* FindNextBestTarget(EventTarget* previous_target, |
57 Event* event); | 44 Event* event); |
58 | |
59 protected: | |
60 // Returns false if neither |target| nor any of its descendants are allowed | |
61 // to accept |event| for reasons unrelated to the event's location or the | |
62 // target's bounds. For example, overrides of this function may consider | |
63 // attributes such as the visibility or enabledness of |target|. Note that | |
64 // the location etc. of |event| is in |target|'s parent's coordinate system. | |
65 virtual bool SubtreeCanAcceptEvent(EventTarget* target, | |
66 const LocatedEvent& event) const; | |
67 | |
68 // Returns whether the location of the event is in an actionable region of the | |
69 // target. Note that the location etc. of |event| is in the |target|'s | |
70 // parent's coordinate system. | |
71 virtual bool EventLocationInsideBounds(EventTarget* target, | |
72 const LocatedEvent& event) const; | |
73 }; | 45 }; |
74 | 46 |
75 } // namespace ui | 47 } // namespace ui |
76 | 48 |
77 #endif // UI_EVENTS_EVENT_TARGETER_H_ | 49 #endif // UI_EVENTS_EVENT_TARGETER_H_ |
OLD | NEW |