OLD | NEW |
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 #include "ui/views/view_targeter.h" | 5 #include "ui/views/view_targeter.h" |
6 | 6 |
7 #include "ui/events/event_target.h" | 7 #include "ui/events/event_target.h" |
8 #include "ui/views/focus/focus_manager.h" | 8 #include "ui/views/focus/focus_manager.h" |
9 #include "ui/views/view.h" | 9 #include "ui/views/view.h" |
10 #include "ui/views/view_targeter_delegate.h" | 10 #include "ui/views/view_targeter_delegate.h" |
11 | 11 |
12 namespace views { | 12 namespace views { |
13 | 13 |
14 ViewTargeter::ViewTargeter(ViewTargeterDelegate* delegate) | 14 ViewTargeter::ViewTargeter(ViewTargeterDelegate* delegate) |
15 : delegate_(delegate) { | 15 : delegate_(delegate) { |
16 } | 16 } |
17 | 17 |
18 ViewTargeter::~ViewTargeter() {} | 18 ViewTargeter::~ViewTargeter() {} |
19 | 19 |
20 bool ViewTargeter::DoesIntersectRect(const View* target, | 20 bool ViewTargeter::DoesIntersectRect(const View* target, |
21 const gfx::Rect& rect) const { | 21 const gfx::Rect& rect) const { |
22 DCHECK(delegate_); | 22 DCHECK(delegate_); |
23 return delegate_->DoesIntersectRect(target, rect); | 23 return delegate_->DoesIntersectRect(target, rect); |
24 } | 24 } |
25 | 25 |
26 gfx::RectF ViewTargeter::BoundsForEvent(const ui::LocatedEvent& event) const { | 26 gfx::RectF ViewTargeter::BoundsForEvent(const ui::LocatedEvent& event) const { |
27 gfx::RectF event_bounds(event.location_f(), gfx::SizeF(1, 1)); | 27 gfx::RectF event_bounds(event.location_f(), gfx::SizeF(1, 1)); |
28 if (event.IsGestureEvent()) { | 28 if (event.IsGestureEvent()) { |
29 const ui::GestureEvent& gesture = | 29 const ui::GestureEvent& gesture = *(event.AsGestureEvent()); |
30 static_cast<const ui::GestureEvent&>(event); | |
31 event_bounds = gesture.details().bounding_box_f(); | 30 event_bounds = gesture.details().bounding_box_f(); |
32 } | 31 } |
33 | 32 |
34 return event_bounds; | 33 return event_bounds; |
35 } | 34 } |
36 | 35 |
37 ui::EventTarget* ViewTargeter::FindTargetForEvent(ui::EventTarget* root, | 36 ui::EventTarget* ViewTargeter::FindTargetForEvent(ui::EventTarget* root, |
38 ui::Event* event) { | 37 ui::Event* event) { |
39 View* view = static_cast<View*>(root); | 38 View* view = static_cast<View*>(root); |
40 if (event->IsKeyEvent()) | 39 if (event->IsKeyEvent()) |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 return view->HitTestRect(rect_in_view_coords); | 79 return view->HitTestRect(rect_in_view_coords); |
81 } | 80 } |
82 | 81 |
83 View* ViewTargeter::FindTargetForKeyEvent(View* view, const ui::KeyEvent& key) { | 82 View* ViewTargeter::FindTargetForKeyEvent(View* view, const ui::KeyEvent& key) { |
84 if (view->GetFocusManager()) | 83 if (view->GetFocusManager()) |
85 return view->GetFocusManager()->GetFocusedView(); | 84 return view->GetFocusManager()->GetFocusedView(); |
86 return NULL; | 85 return NULL; |
87 } | 86 } |
88 | 87 |
89 } // namespace aura | 88 } // namespace aura |
OLD | NEW |