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) { |
sadrul
2014/07/18 22:17:33
Add DCHECK(delegate_) here, and remove the dchecks
tdanderson
2014/07/19 17:32:53
Done.
| |
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 View* ViewTargeter::TargetForRect(View* root, const gfx::Rect& rect) const { | |
27 DCHECK(delegate_); | |
28 return delegate_->TargetForRect(root, rect); | |
29 } | |
30 | |
26 gfx::RectF ViewTargeter::BoundsForEvent(const ui::LocatedEvent& event) const { | 31 gfx::RectF ViewTargeter::BoundsForEvent(const ui::LocatedEvent& event) const { |
27 gfx::RectF event_bounds(event.location_f(), gfx::SizeF(1, 1)); | 32 gfx::RectF event_bounds(event.location_f(), gfx::SizeF(1, 1)); |
28 if (event.IsGestureEvent()) { | 33 if (event.IsGestureEvent()) { |
29 const ui::GestureEvent& gesture = *(event.AsGestureEvent()); | 34 const ui::GestureEvent& gesture = *(event.AsGestureEvent()); |
30 event_bounds = gesture.details().bounding_box_f(); | 35 event_bounds = gesture.details().bounding_box_f(); |
31 } | 36 } |
32 | 37 |
33 return event_bounds; | 38 return event_bounds; |
34 } | 39 } |
35 | 40 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 return view->HitTestRect(rect_in_view_coords); | 84 return view->HitTestRect(rect_in_view_coords); |
80 } | 85 } |
81 | 86 |
82 View* ViewTargeter::FindTargetForKeyEvent(View* view, const ui::KeyEvent& key) { | 87 View* ViewTargeter::FindTargetForKeyEvent(View* view, const ui::KeyEvent& key) { |
83 if (view->GetFocusManager()) | 88 if (view->GetFocusManager()) |
84 return view->GetFocusManager()->GetFocusedView(); | 89 return view->GetFocusManager()->GetFocusedView(); |
85 return NULL; | 90 return NULL; |
86 } | 91 } |
87 | 92 |
88 } // namespace aura | 93 } // namespace aura |
OLD | NEW |