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

Unified Diff: ui/views/focus/focus_manager.cc

Issue 23475012: Fixes focus traversal bug (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Better docs Created 7 years, 4 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
Index: ui/views/focus/focus_manager.cc
diff --git a/ui/views/focus/focus_manager.cc b/ui/views/focus/focus_manager.cc
index a2b88b0ae3194f3b76708753b9e78b07223b9ed5..faf55effaea24cfdaf37611f3b026f76117b9124 100644
--- a/ui/views/focus/focus_manager.cc
+++ b/ui/views/focus/focus_manager.cc
@@ -139,7 +139,7 @@ bool FocusManager::ContainsView(View* view) {
}
void FocusManager::AdvanceFocus(bool reverse) {
- View* v = GetNextFocusableView(focused_view_, reverse, false);
+ View* v = GetNextFocusableView(focused_view_, NULL, reverse, false);
// Note: Do not skip this next block when v == focused_view_. If the user
// tabs past the last focusable element in a webpage, we'll get here, and if
// the TabContentsContainerView is the only focusable view (possible in
@@ -219,6 +219,7 @@ bool FocusManager::RotatePaneFocus(Direction direction,
}
View* FocusManager::GetNextFocusableView(View* original_starting_view,
+ Widget* starting_widget,
bool reverse,
bool dont_loop) {
FocusTraversable* focus_traversable = NULL;
@@ -262,7 +263,8 @@ View* FocusManager::GetNextFocusableView(View* original_starting_view,
}
}
} else {
- focus_traversable = widget_->GetFocusTraversable();
+ Widget* widget = starting_widget ? starting_widget : widget_;
+ focus_traversable = widget->GetFocusTraversable();
}
// Traverse the FocusTraversable tree down to find the focusable view.
@@ -304,8 +306,11 @@ View* FocusManager::GetNextFocusableView(View* original_starting_view,
if (!dont_loop && original_starting_view) {
// Easy, just clear the selection and press tab again.
// By calling with NULL as the starting view, we'll start from the
- // top_root_view.
- return GetNextFocusableView(NULL, reverse, true);
+ // root of |original_starting_view|s widget. We use
+ // |original_starting_view|s widget as it may differ from |widget_| and
+ // in general we only want to wrap within a widget.
+ return GetNextFocusableView(NULL, original_starting_view->GetWidget(),
+ reverse, true);
}
}
return NULL;

Powered by Google App Engine
This is Rietveld 408576698