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

Unified Diff: ash/wm/ash_focus_rules.cc

Issue 11519040: More unittests passing with new focus controller. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/wm/ash_focus_rules.h ('k') | ash/wm/panel_layout_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/ash_focus_rules.cc
===================================================================
--- ash/wm/ash_focus_rules.cc (revision 172961)
+++ ash/wm/ash_focus_rules.cc (working copy)
@@ -104,30 +104,30 @@
aura::Window* ignore) const {
DCHECK(ignore);
- size_t current_container_index = 0;
+ int starting_container_index = 0;
// If the container of the window losing focus is in the list, start from that
// container.
aura::RootWindow* root = ignore->GetRootWindow();
if (!root)
root = Shell::GetActiveRootWindow();
- for (size_t i = 0; ignore && i < arraysize(kWindowContainerIds); i++) {
+ int container_count = static_cast<int>(arraysize(kWindowContainerIds));
+ for (int i = 0; ignore && i < container_count; i++) {
aura::Window* container = Shell::GetContainer(root, kWindowContainerIds[i]);
if (container && container->Contains(ignore)) {
- current_container_index = i;
+ starting_container_index = i;
break;
}
}
- // Look for windows to focus in that container and below.
+ // Look for windows to focus in |ignore|'s container. If none are found, we
+ // look in all the containers in front of |ignore|'s container, then all
+ // behind.
aura::Window* window = NULL;
- for (; !window && current_container_index < arraysize(kWindowContainerIds);
- current_container_index++) {
- aura::Window::Windows containers =
- Shell::GetAllContainers(kWindowContainerIds[current_container_index]);
- for (aura::Window::Windows::const_iterator iter = containers.begin();
- iter != containers.end() && !window; ++iter) {
- window = GetTopmostWindowToActivateInContainer((*iter), ignore);
- }
+ for (int i = starting_container_index; !window && i < container_count; i++)
+ window = GetTopmostWindowToActivateForContainerIndex(i, ignore);
+ if (!window && starting_container_index > 0) {
+ for (int i = starting_container_index - 1; !window && i >= 0; i--)
+ window = GetTopmostWindowToActivateForContainerIndex(i, ignore);
}
return window;
}
@@ -135,6 +135,19 @@
////////////////////////////////////////////////////////////////////////////////
// AshFocusRules, private:
+aura::Window* AshFocusRules::GetTopmostWindowToActivateForContainerIndex(
+ int index,
+ aura::Window* ignore) const {
+ aura::Window* window = NULL;
+ aura::Window::Windows containers =
+ Shell::GetAllContainers(kWindowContainerIds[index]);
+ for (aura::Window::Windows::const_iterator iter = containers.begin();
+ iter != containers.end() && !window; ++iter) {
+ window = GetTopmostWindowToActivateInContainer((*iter), ignore);
+ }
+ return window;
+}
+
aura::Window* AshFocusRules::GetTopmostWindowToActivateInContainer(
aura::Window* container,
aura::Window* ignore) const {
« no previous file with comments | « ash/wm/ash_focus_rules.h ('k') | ash/wm/panel_layout_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698