Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ui / events / event_targeter.h
blobdead49f1367a1923b2c5fa8eb9770c1374063057
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
3 // found in the LICENSE file.
5 #ifndef UI_EVENTS_EVENT_TARGETER_H_
6 #define UI_EVENTS_EVENT_TARGETER_H_
8 #include "base/compiler_specific.h"
9 #include "ui/events/event.h"
10 #include "ui/events/events_export.h"
12 namespace ui {
14 class Event;
15 class EventTarget;
16 class LocatedEvent;
18 class EVENTS_EXPORT EventTargeter {
19 public:
20 virtual ~EventTargeter();
22 // Returns the target |event| should be dispatched to. If there is no such
23 // target, this should return NULL.
24 virtual EventTarget* FindTargetForEvent(EventTarget* root,
25 Event* event);
27 // Same as FindTargetForEvent(), but used for positional events. The location
28 // etc. of |event| are in |root|'s coordinate system. When finding the target
29 // for the event, the targeter can mutate the |event| (e.g. change the
30 // coordinate to be in the returned target's coordinate system) so that it can
31 // be dispatched to the target without any farther modification.
32 virtual EventTarget* FindTargetForLocatedEvent(EventTarget* root,
33 LocatedEvent* event);
35 // Returns true if |target| or one of its descendants can be a target of
36 // |event|. This requires that |target| and its descendants are not
37 // prohibited from accepting the event, and that the event is within an
38 // actionable region of the target's bounds. Note that the location etc. of
39 // |event| is in |target|'s parent's coordinate system.
40 // TODO(tdanderson|sadrul): This function should be made non-virtual and
41 // non-public.
42 virtual bool SubtreeShouldBeExploredForEvent(EventTarget* target,
43 const LocatedEvent& event);
45 // Returns the next best target for |event| as compared to |previous_target|.
46 // Also mutates |event| so that it can be dispatched to the returned target
47 // (e.g., by changing |event|'s location to be in the returned target's
48 // coordinate space).
49 virtual EventTarget* FindNextBestTarget(EventTarget* previous_target,
50 Event* event);
52 protected:
53 // Returns false if neither |target| nor any of its descendants are allowed
54 // to accept |event| for reasons unrelated to the event's location or the
55 // target's bounds. For example, overrides of this function may consider
56 // attributes such as the visibility or enabledness of |target|. Note that
57 // the location etc. of |event| is in |target|'s parent's coordinate system.
58 virtual bool SubtreeCanAcceptEvent(EventTarget* target,
59 const LocatedEvent& event) const;
61 // Returns whether the location of the event is in an actionable region of the
62 // target. Note that the location etc. of |event| is in the |target|'s
63 // parent's coordinate system.
64 virtual bool EventLocationInsideBounds(EventTarget* target,
65 const LocatedEvent& event) const;
68 } // namespace ui
70 #endif // UI_EVENTS_EVENT_TARGETER_H_