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