Update V8 to version 4.7.21.
[chromium-blink-merge.git] / ui / aura / window_targeter.h
blob048d8ad2e472aca897fccab4dfb8c125180d45ab
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_AURA_WINDOW_TARGETER_H_
6 #define UI_AURA_WINDOW_TARGETER_H_
8 #include "base/macros.h"
9 #include "ui/aura/aura_export.h"
10 #include "ui/events/event_targeter.h"
12 namespace ui {
13 class KeyEvent;
14 class LocatedEvent;
15 } // namespace ui
17 namespace aura {
19 class Window;
21 class AURA_EXPORT WindowTargeter : public ui::EventTargeter {
22 public:
23 WindowTargeter();
24 ~WindowTargeter() override;
26 // Returns true if |window| or one of its descendants can be a target of
27 // |event|. This requires that |window| and its descendants are not
28 // prohibited from accepting the event, and that the event is within an
29 // actionable region of the target's bounds. Note that the location etc. of
30 // |event| is in |window|'s parent's coordinate system.
31 virtual bool SubtreeShouldBeExploredForEvent(Window* window,
32 const ui::LocatedEvent& event);
34 protected:
35 // Same as FindTargetForEvent(), but used for positional events. The location
36 // etc. of |event| are in |root|'s coordinate system. When finding the target
37 // for the event, the targeter can mutate the |event| (e.g. change the
38 // coordinate to be in the returned target's coordinate system) so that it can
39 // be dispatched to the target without any further modification.
40 virtual Window* FindTargetForLocatedEvent(Window* window,
41 ui::LocatedEvent* event);
43 // Returns false if neither |window| nor any of its descendants are allowed
44 // to accept |event| for reasons unrelated to the event's location or the
45 // target's bounds. For example, overrides of this function may consider
46 // attributes such as the visibility or enabledness of |window|. Note that
47 // the location etc. of |event| is in |window|'s parent's coordinate system.
48 virtual bool SubtreeCanAcceptEvent(Window* window,
49 const ui::LocatedEvent& event) const;
51 // Returns whether the location of the event is in an actionable region of the
52 // target. Note that the location etc. of |event| is in the |window|'s
53 // parent's coordinate system.
54 virtual bool EventLocationInsideBounds(Window* target,
55 const ui::LocatedEvent& event) const;
57 // ui::EventTargeter:
58 ui::EventTarget* FindTargetForEvent(ui::EventTarget* root,
59 ui::Event* event) override;
60 ui::EventTarget* FindNextBestTarget(ui::EventTarget* previous_target,
61 ui::Event* event) override;
63 private:
64 Window* FindTargetForKeyEvent(Window* root_window, const ui::KeyEvent& event);
65 Window* FindTargetForNonKeyEvent(Window* root_window, ui::Event* event);
66 Window* FindTargetInRootWindow(Window* root_window,
67 const ui::LocatedEvent& event);
68 Window* FindTargetForLocatedEventRecursively(Window* root_window,
69 ui::LocatedEvent* event);
71 DISALLOW_COPY_AND_ASSIGN(WindowTargeter);
74 } // namespace aura
76 #endif // UI_AURA_WINDOW_TARGETER_H_