Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: ui/views/view_targeter.cc

Issue 401933002: Move views event targeting into ViewTargeterDelegate::TargetForRect() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments addressed Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/view_targeter.h ('k') | ui/views/view_targeter_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 DCHECK(delegate_);
16 } 17 }
17 18
18 ViewTargeter::~ViewTargeter() {} 19 ViewTargeter::~ViewTargeter() {}
19 20
20 bool ViewTargeter::DoesIntersectRect(const View* target, 21 bool ViewTargeter::DoesIntersectRect(const View* target,
21 const gfx::Rect& rect) const { 22 const gfx::Rect& rect) const {
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 return delegate_->TargetForRect(root, rect);
28 }
29
26 gfx::RectF ViewTargeter::BoundsForEvent(const ui::LocatedEvent& event) const { 30 gfx::RectF ViewTargeter::BoundsForEvent(const ui::LocatedEvent& event) const {
27 gfx::RectF event_bounds(event.location_f(), gfx::SizeF(1, 1)); 31 gfx::RectF event_bounds(event.location_f(), gfx::SizeF(1, 1));
28 if (event.IsGestureEvent()) { 32 if (event.IsGestureEvent()) {
29 const ui::GestureEvent& gesture = *(event.AsGestureEvent()); 33 const ui::GestureEvent& gesture = *(event.AsGestureEvent());
30 event_bounds = gesture.details().bounding_box_f(); 34 event_bounds = gesture.details().bounding_box_f();
31 } 35 }
32 36
33 return event_bounds; 37 return event_bounds;
34 } 38 }
35 39
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 return view->HitTestRect(rect_in_view_coords); 83 return view->HitTestRect(rect_in_view_coords);
80 } 84 }
81 85
82 View* ViewTargeter::FindTargetForKeyEvent(View* view, const ui::KeyEvent& key) { 86 View* ViewTargeter::FindTargetForKeyEvent(View* view, const ui::KeyEvent& key) {
83 if (view->GetFocusManager()) 87 if (view->GetFocusManager())
84 return view->GetFocusManager()->GetFocusedView(); 88 return view->GetFocusManager()->GetFocusedView();
85 return NULL; 89 return NULL;
86 } 90 }
87 91
88 } // namespace aura 92 } // namespace aura
OLDNEW
« no previous file with comments | « ui/views/view_targeter.h ('k') | ui/views/view_targeter_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698