summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-13 17:26:23 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-13 17:26:23 +0000
commite2bdba765ef03280231c5df670f42d73a69263af (patch)
treef51a8fd2d926bdf108a08fbb113adadb9624d0fb /chrome
parent927b5f60bdfdae856bc01d0cf56aa57d6f2fe5b4 (diff)
downloadchromium_src-e2bdba765ef03280231c5df670f42d73a69263af.zip
chromium_src-e2bdba765ef03280231c5df670f42d73a69263af.tar.gz
chromium_src-e2bdba765ef03280231c5df670f42d73a69263af.tar.bz2
Fix some focus traversal issues:
* When we're on the only focusable view, AdvanceFocus() should just focus us again. * When only one focusable view exists, FindLastFocusableView() should return it, not NULL. Also the code here was longer than it needed to be. Review URL: http://codereview.chromium.org/20347 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9759 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/views/focus_manager.cc20
1 files changed, 9 insertions, 11 deletions
diff --git a/chrome/views/focus_manager.cc b/chrome/views/focus_manager.cc
index 6f73045..27e396a 100644
--- a/chrome/views/focus_manager.cc
+++ b/chrome/views/focus_manager.cc
@@ -469,7 +469,12 @@ bool FocusManager::ContainsView(View* view) {
void FocusManager::AdvanceFocus(bool reverse) {
View* v = GetNextFocusableView(focused_view_, reverse, false);
- if (v && (v != focused_view_)) {
+ // 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
+ // fullscreen mode), we need to run this block in order to cycle around to the
+ // first element on the page.
+ if (v) {
v->AboutToRequestFocusFromTabTraversal(reverse);
v->RequestFocus();
}
@@ -553,18 +558,11 @@ View* FocusManager::GetNextFocusableView(View* original_starting_view,
}
View* FocusManager::FindLastFocusableView() {
- // For now we'll just walk the entire focus loop until we reach the end.
-
- // Let's start at whatever focused view we are at.
- View* starting_view = focused_view_;
-
- // Now advance until you reach the end.
+ // Just walk the entire focus loop from where we're at until we reach the end.
View* new_focused = NULL;
- View* last_focused = NULL;
- while (new_focused = GetNextFocusableView(starting_view, false, true)) {
+ View* last_focused = focused_view_;
+ while (new_focused = GetNextFocusableView(last_focused, false, true))
last_focused = new_focused;
- starting_view = new_focused;
- }
return last_focused;
}