Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: mojo/services/window_manager/basic_focus_rules.cc

Issue 710203006: Reland: Remove aura and make a pure mojo::View version of FocusController. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Remove the offending lines. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 // TODO(erg): This needs to check visibility, along with focus, and several
26 // other things (see wm::BaseFocusRules).
27 return view->parent() == window_container_;
28 }
29
30 bool BasicFocusRules::CanFocusView(mojo::View* view) const {
31 return true;
32 }
33
34 mojo::View* BasicFocusRules::GetToplevelView(mojo::View* view) const {
35 while (view->parent() != window_container_) {
36 view = view->parent();
37 // Unparented hierarchy, there is no "top level" window.
38 if (!view)
39 return nullptr;
40 }
41
42 return view;
43 }
44
45 mojo::View* BasicFocusRules::GetActivatableView(mojo::View* view) const {
46 return GetToplevelView(view);
47 }
48
49 mojo::View* BasicFocusRules::GetFocusableView(mojo::View* view) const {
50 return view;
51 }
52
53 mojo::View* BasicFocusRules::GetNextActivatableView(
54 mojo::View* activatable) const {
55 const mojo::View::Children& children = activatable->parent()->children();
56 for (mojo::View::Children::const_reverse_iterator it = children.rbegin();
57 it != children.rend(); ++it) {
58 if (*it != activatable)
59 return *it;
60 }
61 return nullptr;
62 }
63
64 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/window_manager/basic_focus_rules.h ('k') | mojo/services/window_manager/focus_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698