OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/mus/view_locator.h" | 5 #include "components/mus/view_locator.h" |
6 | 6 |
7 #include "components/mus/server_view.h" | 7 #include "components/mus/server_view.h" |
8 | 8 |
9 namespace mus { | 9 namespace view_manager { |
10 | 10 |
11 const ServerView* FindDeepestVisibleView(const ServerView* view, | 11 const ServerView* FindDeepestVisibleView(const ServerView* view, |
12 const gfx::Point& location) { | 12 const gfx::Point& location) { |
13 for (const ServerView* child : view->GetChildren()) { | 13 for (const ServerView* child : view->GetChildren()) { |
14 if (!child->visible()) | 14 if (!child->visible()) |
15 continue; | 15 continue; |
16 | 16 |
17 // TODO(sky): support transform. | 17 // TODO(sky): support transform. |
18 const gfx::Point child_location(location.x() - child->bounds().x(), | 18 const gfx::Point child_location(location.x() - child->bounds().x(), |
19 location.y() - child->bounds().y()); | 19 location.y() - child->bounds().y()); |
20 if (child_location.x() >= 0 && child_location.y() >= 0 && | 20 if (child_location.x() >= 0 && child_location.y() >= 0 && |
21 child_location.x() < child->bounds().width() && | 21 child_location.x() < child->bounds().width() && |
22 child_location.y() < child->bounds().height()) { | 22 child_location.y() < child->bounds().height()) { |
23 return FindDeepestVisibleView(child, child_location); | 23 return FindDeepestVisibleView(child, child_location); |
24 } | 24 } |
25 } | 25 } |
26 return view; | 26 return view; |
27 } | 27 } |
28 | 28 |
29 ServerView* FindDeepestVisibleView(ServerView* view, | 29 ServerView* FindDeepestVisibleView(ServerView* view, |
30 const gfx::Point& location) { | 30 const gfx::Point& location) { |
31 return const_cast<ServerView*>( | 31 return const_cast<ServerView*>( |
32 FindDeepestVisibleView(const_cast<const ServerView*>(view), location)); | 32 FindDeepestVisibleView(const_cast<const ServerView*>(view), location)); |
33 } | 33 } |
34 | 34 |
35 } // namespace mus | 35 } // namespace view_manager |
OLD | NEW |