Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "mojo/services/window_manager/basic_focus_rules.h" | |
| 6 | |
| 7 #include "base/macros.h" | |
| 8 #include "mojo/services/public/cpp/view_manager/view.h" | |
| 9 #include "mojo/services/window_manager/window_manager_app.h" | |
| 10 | |
| 11 namespace mojo { | |
| 12 | |
| 13 BasicFocusRules::BasicFocusRules(mojo::WindowManagerApp* window_manager_app, | |
| 14 mojo::View* window_container) | |
| 15 : window_container_(window_container), | |
| 16 window_manager_app_(window_manager_app) {} | |
| 17 | |
| 18 BasicFocusRules::~BasicFocusRules() {} | |
| 19 | |
| 20 bool BasicFocusRules::IsToplevelView(mojo::View* view) const { | |
| 21 return view->parent() == window_container_; | |
| 22 } | |
| 23 | |
| 24 bool BasicFocusRules::CanActivateView(mojo::View* view) const { | |
| 25 return view->parent() == window_container_; | |
|
sky
2014/11/10 20:45:30
Don't you want to check visibility/drawn in any of
Elliot Glaysher
2014/11/10 22:18:49
You do, but right now this is a straight port of t
| |
| 26 } | |
| 27 | |
| 28 bool BasicFocusRules::CanFocusView(mojo::View* view) const { | |
| 29 return true; | |
| 30 } | |
| 31 | |
| 32 mojo::View* BasicFocusRules::GetToplevelView(mojo::View* view) const { | |
| 33 while (view->parent() != window_container_) { | |
| 34 view = view->parent(); | |
| 35 // Unparented hierarchy, there is no "top level" window. | |
| 36 if (!view) | |
| 37 return NULL; | |
|
sky
2014/11/10 20:45:30
nullptr every where.
| |
| 38 } | |
| 39 | |
| 40 return view; | |
| 41 } | |
| 42 | |
| 43 mojo::View* BasicFocusRules::GetActivatableView(mojo::View* view) const { | |
| 44 return GetToplevelView(view); | |
| 45 } | |
| 46 | |
| 47 mojo::View* BasicFocusRules::GetFocusableView(mojo::View* view) const { | |
| 48 return view; | |
| 49 } | |
| 50 | |
| 51 mojo::View* BasicFocusRules::GetNextActivatableView( | |
| 52 mojo::View* activatable) const { | |
| 53 const mojo::View::Children& children = activatable->parent()->children(); | |
| 54 for (mojo::View::Children::const_reverse_iterator it = children.rbegin(); | |
| 55 it != children.rend(); ++it) { | |
| 56 if (*it != activatable) | |
| 57 return *it; | |
| 58 } | |
| 59 return NULL; | |
| 60 } | |
| 61 | |
| 62 } // namespace mojo | |
| OLD | NEW |