| 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 "sky/tools/debugger/focus_rules.h" | |
| 6 | |
| 7 namespace sky { | |
| 8 namespace debugger { | |
| 9 | |
| 10 FocusRules::FocusRules(mojo::WindowManagerApp* window_manager_app, | |
| 11 mojo::View* content) | |
| 12 : content_(content), | |
| 13 window_manager_app_(window_manager_app) { | |
| 14 } | |
| 15 | |
| 16 FocusRules::~FocusRules() { | |
| 17 } | |
| 18 | |
| 19 bool FocusRules::IsToplevelWindow(aura::Window* window) const { | |
| 20 return mojo::WindowManagerApp::GetViewForWindow(window)->parent() == content_; | |
| 21 } | |
| 22 | |
| 23 bool FocusRules::CanActivateWindow(aura::Window* window) const { | |
| 24 return mojo::WindowManagerApp::GetViewForWindow(window)->parent() == content_; | |
| 25 } | |
| 26 | |
| 27 bool FocusRules::CanFocusWindow(aura::Window* window) const { | |
| 28 return true; | |
| 29 } | |
| 30 | |
| 31 aura::Window* FocusRules::GetToplevelWindow(aura::Window* window) const { | |
| 32 mojo::View* view = mojo::WindowManagerApp::GetViewForWindow(window); | |
| 33 while (view->parent() != content_) { | |
| 34 view = view->parent(); | |
| 35 if (!view) | |
| 36 return NULL; | |
| 37 } | |
| 38 return window_manager_app_->GetWindowForViewId(view->id()); | |
| 39 } | |
| 40 | |
| 41 aura::Window* FocusRules::GetActivatableWindow(aura::Window* window) const { | |
| 42 return GetToplevelWindow(window); | |
| 43 } | |
| 44 | |
| 45 aura::Window* FocusRules::GetFocusableWindow(aura::Window* window) const { | |
| 46 return window; | |
| 47 } | |
| 48 | |
| 49 aura::Window* FocusRules::GetNextActivatableWindow(aura::Window* ignore) const { | |
| 50 aura::Window* activatable = GetActivatableWindow(ignore); | |
| 51 const aura::Window::Windows& children = activatable->parent()->children(); | |
| 52 for (aura::Window::Windows::const_reverse_iterator it = children.rbegin(); | |
| 53 it != children.rend(); ++it) { | |
| 54 if (*it != ignore) | |
| 55 return *it; | |
| 56 } | |
| 57 return NULL; | |
| 58 } | |
| 59 | |
| 60 } // namespace debugger | |
| 61 } // namespace sky | |
| OLD | NEW |