Chromium Code Reviews| Index: ash/wm/ash_focus_rules.cc |
| =================================================================== |
| --- ash/wm/ash_focus_rules.cc (revision 172961) |
| +++ ash/wm/ash_focus_rules.cc (working copy) |
| @@ -104,7 +104,7 @@ |
| aura::Window* ignore) const { |
| DCHECK(ignore); |
| - size_t current_container_index = 0; |
| + size_t 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(); |
| @@ -113,20 +113,25 @@ |
| for (size_t i = 0; ignore && i < arraysize(kWindowContainerIds); 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 (size_t i = starting_container_index; |
| + !window && i < arraysize(kWindowContainerIds); |
| + i++) { |
| + window = GetTopmostWindowToActivateForContainerIndex(i, ignore); |
| + } |
| + if (!window) { |
| + for (size_t i = starting_container_index - 1; |
|
sky
2012/12/13 21:38:06
If starting_container_index == 0 this is going to
Ben Goodger (Google)
2012/12/13 21:47:23
Done.
|
| + !window && i < arraysize(kWindowContainerIds); |
| + i--) { |
| + window = GetTopmostWindowToActivateForContainerIndex(i, ignore); |
| } |
| } |
| return window; |
| @@ -135,6 +140,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 { |