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

Unified Diff: views/focus/focus_manager.cc

Issue 125062: Fix reversed focus traversal order issue. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 months 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 | « views/focus/focus_manager.h ('k') | views/focus/focus_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/focus/focus_manager.cc
===================================================================
--- views/focus/focus_manager.cc (revision 18328)
+++ views/focus/focus_manager.cc (working copy)
@@ -360,12 +360,19 @@
View* starting_view = NULL;
if (original_starting_view) {
- // If the starting view has a focus traversable, use it.
- // This is the case with WidgetWins for example.
- focus_traversable = original_starting_view->GetFocusTraversable();
+ if (!reverse) {
+ // If the starting view has a focus traversable, use it.
+ // This is the case with WidgetWins for example.
+ focus_traversable = original_starting_view->GetFocusTraversable();
- // Otherwise default to the root view.
- if (!focus_traversable) {
+ // Otherwise default to the root view.
+ if (!focus_traversable) {
+ focus_traversable = original_starting_view->GetRootView();
+ starting_view = original_starting_view;
+ }
+ } else {
+ // When you are going back, starting view's FocusTraversable should not be
+ // used.
focus_traversable = original_starting_view->GetRootView();
starting_view = original_starting_view;
}
@@ -374,8 +381,7 @@
}
// Traverse the FocusTraversable tree down to find the focusable view.
- View* v = FindFocusableView(focus_traversable, starting_view,
- reverse, dont_loop);
+ View* v = FindFocusableView(focus_traversable, starting_view, reverse);
if (v) {
return v;
} else {
@@ -386,15 +392,17 @@
while (parent_focus_traversable) {
FocusTraversable* new_focus_traversable = NULL;
View* new_starting_view = NULL;
- v = parent_focus_traversable ->FindNextFocusableView(
- starting_view, reverse, FocusTraversable::UP, dont_loop,
- &new_focus_traversable, &new_starting_view);
+ // When we are going backward, the parent view might gain the next focus.
+ bool check_starting_view = reverse;
+ v = parent_focus_traversable->FindNextFocusableView(
+ starting_view, reverse, FocusTraversable::UP,
+ check_starting_view, &new_focus_traversable, &new_starting_view);
if (new_focus_traversable) {
DCHECK(!v);
// There is a FocusTraversable, traverse it down.
- v = FindFocusableView(new_focus_traversable, NULL, reverse, dont_loop);
+ v = FindFocusableView(new_focus_traversable, NULL, reverse);
}
if (v)
@@ -563,14 +571,13 @@
// FocusTraversable hierarchy.
View* FocusManager::FindFocusableView(FocusTraversable* focus_traversable,
View* starting_view,
- bool reverse,
- bool dont_loop) {
+ bool reverse) {
FocusTraversable* new_focus_traversable = NULL;
View* new_starting_view = NULL;
View* v = focus_traversable->FindNextFocusableView(starting_view,
reverse,
FocusTraversable::DOWN,
- dont_loop,
+ false,
&new_focus_traversable,
&new_starting_view);
@@ -584,7 +591,7 @@
v = focus_traversable->FindNextFocusableView(starting_view,
reverse,
FocusTraversable::DOWN,
- dont_loop,
+ false,
&new_focus_traversable,
&new_starting_view);
}
« no previous file with comments | « views/focus/focus_manager.h ('k') | views/focus/focus_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698