flutter_flutter/tools/debugger/focus_rules.cc
Elliot Glaysher cf51d90a37 Revert "Remove aura and make a pure mojo::View version of the aura::Window FocusController."
This reverts commit bb29e4293b6e60ee721b5be17f9fa9f4989a1981.

This is a speculative revert due to android waterfall bots failing.

BUG=431047
TBR=ojan@chromium.org,sky@chromium.org

Review URL: https://codereview.chromium.org/718573002
2014-11-10 16:28:49 -08:00

62 lines
1.8 KiB
C++

// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "sky/tools/debugger/focus_rules.h"
namespace sky {
namespace debugger {
FocusRules::FocusRules(mojo::WindowManagerApp* window_manager_app,
mojo::View* content)
: content_(content),
window_manager_app_(window_manager_app) {
}
FocusRules::~FocusRules() {
}
bool FocusRules::IsToplevelWindow(aura::Window* window) const {
return mojo::WindowManagerApp::GetViewForWindow(window)->parent() == content_;
}
bool FocusRules::CanActivateWindow(aura::Window* window) const {
return mojo::WindowManagerApp::GetViewForWindow(window)->parent() == content_;
}
bool FocusRules::CanFocusWindow(aura::Window* window) const {
return true;
}
aura::Window* FocusRules::GetToplevelWindow(aura::Window* window) const {
mojo::View* view = mojo::WindowManagerApp::GetViewForWindow(window);
while (view->parent() != content_) {
view = view->parent();
if (!view)
return NULL;
}
return window_manager_app_->GetWindowForViewId(view->id());
}
aura::Window* FocusRules::GetActivatableWindow(aura::Window* window) const {
return GetToplevelWindow(window);
}
aura::Window* FocusRules::GetFocusableWindow(aura::Window* window) const {
return window;
}
aura::Window* FocusRules::GetNextActivatableWindow(aura::Window* ignore) const {
aura::Window* activatable = GetActivatableWindow(ignore);
const aura::Window::Windows& children = activatable->parent()->children();
for (aura::Window::Windows::const_reverse_iterator it = children.rbegin();
it != children.rend(); ++it) {
if (*it != ignore)
return *it;
}
return NULL;
}
} // namespace debugger
} // namespace sky