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

Unified Diff: ui/views/corewm/base_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 | « ui/views/bubble/bubble_delegate.cc ('k') | ui/views/corewm/focus_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/corewm/base_focus_rules.cc
===================================================================
--- ui/views/corewm/base_focus_rules.cc (revision 172961)
+++ ui/views/corewm/base_focus_rules.cc (working copy)
@@ -69,6 +69,12 @@
return false;
}
+ // A window must be focusable to be activatable. We don't call
+ // CanFocusWindow() from here because it will call back to us via
+ // GetActivatableWindow().
+ if (!window->CanFocus())
+ return false;
+
// The window cannot be blocked by a modal transient.
return !GetModalTransient(window);
}
@@ -106,6 +112,14 @@
if (CanActivateWindow(child))
return child;
+ // CanActivateWindow() above will return false if |child| is blocked by a
+ // modal transient. In this case the modal is or contains the activatable
+ // window. We recurse because the modal may itself be blocked by a modal
+ // transient.
+ aura::Window* modal_transient = GetModalTransient(child);
+ if (modal_transient)
+ return GetActivatableWindow(modal_transient);
+
if (child->transient_parent())
return GetActivatableWindow(child->transient_parent());
@@ -122,8 +136,15 @@
// |window| may be in a hierarchy that is non-activatable, in which case we
// need to cut over to the activatable hierarchy.
aura::Window* activatable = GetActivatableWindow(window);
- if (!activatable)
- return GetFocusedWindow(window);
+ if (!activatable) {
+ // There may not be a related activatable hierarchy to cut over to, in which
+ // case we try an unrelated one.
+ aura::Window* toplevel = GetToplevelWindow(window);
+ if (toplevel)
+ activatable = GetNextActivatableWindow(toplevel);
+ if (!activatable)
+ return NULL;
+ }
if (!activatable->Contains(window)) {
// If there's already a child window focused in the activatable hierarchy,
« no previous file with comments | « ui/views/bubble/bubble_delegate.cc ('k') | ui/views/corewm/focus_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698