summaryrefslogtreecommitdiffstats
path: root/views/focus/focus_manager.cc
diff options
context:
space:
mode:
authordmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-18 13:53:37 +0000
committerdmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-18 13:53:37 +0000
commit83548a4b7d23ca252944fa1dabfbe85bf5742157 (patch)
tree1c76116c200885db472e61b0778a8e22e0ca052c /views/focus/focus_manager.cc
parent7869f47d58149dc27a2e42de61d32f459c04d241 (diff)
downloadchromium_src-83548a4b7d23ca252944fa1dabfbe85bf5742157.zip
chromium_src-83548a4b7d23ca252944fa1dabfbe85bf5742157.tar.gz
chromium_src-83548a4b7d23ca252944fa1dabfbe85bf5742157.tar.bz2
Improve toolbar keyboard accessibility.
Design doc: https://docs.google.com/a/google.com/Doc?docid=0ATICCjR-gNReY2djdjkyNnNfNzl4ZnpiODQ2Mg&hl=en BUG=40745 BUG=36728 BUG=36222 TEST=New test added to focus_manager_unittest.cc Review URL: http://codereview.chromium.org/2737010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50234 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/focus/focus_manager.cc')
-rw-r--r--views/focus/focus_manager.cc72
1 files changed, 45 insertions, 27 deletions
diff --git a/views/focus/focus_manager.cc b/views/focus/focus_manager.cc
index f637e09..9646bb8 100644
--- a/views/focus/focus_manager.cc
+++ b/views/focus/focus_manager.cc
@@ -15,6 +15,7 @@
#include "base/keyboard_codes.h"
#include "base/logging.h"
#include "views/accelerator.h"
+#include "views/focus/focus_search.h"
#include "views/focus/view_storage.h"
#include "views/view.h"
#include "views/widget/root_view.h"
@@ -122,7 +123,7 @@ bool FocusManager::OnKeyEvent(const KeyEvent& event) {
} else if (index >= static_cast<int>(views.size())) {
index = 0;
}
- views[index]->RequestFocus();
+ SetFocusedView(views[index]);
return false;
}
@@ -183,7 +184,7 @@ void FocusManager::AdvanceFocus(bool reverse) {
// first element on the page.
if (v) {
v->AboutToRequestFocusFromTabTraversal(reverse);
- v->RequestFocus();
+ SetFocusedView(v);
}
}
@@ -197,21 +198,36 @@ View* FocusManager::GetNextFocusableView(View* original_starting_view,
View* starting_view = NULL;
if (original_starting_view) {
- 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();
+ // Search up the containment hierarchy to see if a view is acting as
+ // a pane, and wants to implement its own focus traversable to keep
+ // the focus trapped within that pane.
+ View* pane_search = original_starting_view;
+ while (pane_search) {
+ focus_traversable = pane_search->GetPaneFocusTraversable();
+ if (focus_traversable) {
+ starting_view = original_starting_view;
+ break;
+ }
+ pane_search = pane_search->GetParent();
+ }
- // Otherwise default to the root view.
- if (!focus_traversable) {
+ if (!focus_traversable) {
+ 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) {
+ 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;
}
- } 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;
}
} else {
focus_traversable = widget_->GetRootView();
@@ -231,8 +247,8 @@ View* FocusManager::GetNextFocusableView(View* original_starting_view,
View* new_starting_view = NULL;
// 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,
+ v = parent_focus_traversable->GetFocusSearch()->FindNextFocusableView(
+ starting_view, reverse, FocusSearch::UP,
check_starting_view, &new_focus_traversable, &new_starting_view);
if (new_focus_traversable) {
@@ -368,12 +384,13 @@ View* FocusManager::FindFocusableView(FocusTraversable* focus_traversable,
bool reverse) {
FocusTraversable* new_focus_traversable = NULL;
View* new_starting_view = NULL;
- View* v = focus_traversable->FindNextFocusableView(starting_view,
- reverse,
- FocusTraversable::DOWN,
- false,
- &new_focus_traversable,
- &new_starting_view);
+ View* v = focus_traversable->GetFocusSearch()->FindNextFocusableView(
+ starting_view,
+ reverse,
+ FocusSearch::DOWN,
+ false,
+ &new_focus_traversable,
+ &new_starting_view);
// Let's go down the FocusTraversable tree as much as we can.
while (new_focus_traversable) {
@@ -382,12 +399,13 @@ View* FocusManager::FindFocusableView(FocusTraversable* focus_traversable,
starting_view = new_starting_view;
new_focus_traversable = NULL;
starting_view = NULL;
- v = focus_traversable->FindNextFocusableView(starting_view,
- reverse,
- FocusTraversable::DOWN,
- false,
- &new_focus_traversable,
- &new_starting_view);
+ v = focus_traversable->GetFocusSearch()->FindNextFocusableView(
+ starting_view,
+ reverse,
+ FocusSearch::DOWN,
+ false,
+ &new_focus_traversable,
+ &new_starting_view);
}
return v;
}