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