Add a FrameHostMsg_BeginNavigation IPC
[chromium-blink-merge.git] / ui / views / view_targeter.h
blob9aa585b401214c1f3c1594f1bc23fb94c9132d11
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
3 // found in the LICENSE file.
5 #ifndef UI_VIEWS_VIEW_TARGETER_H_
6 #define UI_VIEWS_VIEW_TARGETER_H_
8 #include "ui/events/event_targeter.h"
9 #include "ui/views/views_export.h"
11 namespace views {
13 class View;
14 class ViewTargeterDelegate;
16 // Contains the logic used to determine the View to which an
17 // event should be dispatched. A ViewTargeter (or one of its
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 class VIEWS_EXPORT ViewTargeter : public ui::EventTargeter {
22 public:
23 explicit ViewTargeter(ViewTargeterDelegate* delegate);
24 virtual ~ViewTargeter();
26 // A call-through to DoesIntersectRect() on |delegate_|.
27 bool DoesIntersectRect(const View* target, const gfx::Rect& rect) const;
29 protected:
30 // Returns the location of |event| represented as a rect. If |event| is
31 // a gesture event, its bounding box is returned. Otherwise, a 1x1 rect
32 // having its origin at the location of |event| is returned.
33 gfx::RectF BoundsForEvent(const ui::LocatedEvent& event) const;
35 // ui::EventTargeter:
36 virtual ui::EventTarget* FindTargetForEvent(ui::EventTarget* root,
37 ui::Event* event) OVERRIDE;
38 virtual ui::EventTarget* FindNextBestTarget(ui::EventTarget* previous_target,
39 ui::Event* event) OVERRIDE;
40 virtual bool SubtreeCanAcceptEvent(
41 ui::EventTarget* target,
42 const ui::LocatedEvent& event) const OVERRIDE;
43 virtual bool EventLocationInsideBounds(
44 ui::EventTarget* target,
45 const ui::LocatedEvent& event) const OVERRIDE;
47 private:
48 View* FindTargetForKeyEvent(View* view, const ui::KeyEvent& key);
50 // ViewTargeter does not own the |delegate_|, but |delegate_| must
51 // outlive the targeter.
52 ViewTargeterDelegate* delegate_;
54 DISALLOW_COPY_AND_ASSIGN(ViewTargeter);
57 } // namespace views
59 #endif // UI_VIEWS_VIEW_TARGETER_H_