summaryrefslogtreecommitdiffstats
path: root/views/focus
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-21 18:48:14 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-21 18:48:14 +0000
commit6a6a790f78f858263a1295e11671c850b1094538 (patch)
treed64e421b5aecfa87c33cb17ad6d6b3eef889bd0d /views/focus
parent57ffb39face8a6eac9fd0075c73c4278d83ea6c6 (diff)
downloadchromium_src-6a6a790f78f858263a1295e11671c850b1094538.zip
chromium_src-6a6a790f78f858263a1295e11671c850b1094538.tar.gz
chromium_src-6a6a790f78f858263a1295e11671c850b1094538.tar.bz2
touch: Fix switching focus among fields in webpages.
If Tab is pressed, then the RootView needs to process it first, because the focus-manager will move the focus to the next focusable view, without letting the currently focused view process it (which means, for example, tab-ing to move focus between fields/links in a RenderWidgetHostViewViews won't work). For all other keys, let the focus manager process it first so that the keyboard accelerators can be triggered. BUG=pressing tab in a textfield in a touch-build doesn't move focus out of it. TEST=see bug Review URL: http://codereview.chromium.org/6016002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69846 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/focus')
-rw-r--r--views/focus/accelerator_handler_touch.cc28
1 files changed, 18 insertions, 10 deletions
diff --git a/views/focus/accelerator_handler_touch.cc b/views/focus/accelerator_handler_touch.cc
index dc880b8..54a2b32 100644
--- a/views/focus/accelerator_handler_touch.cc
+++ b/views/focus/accelerator_handler_touch.cc
@@ -153,20 +153,28 @@ bool DispatchXEvent(XEvent* xev) {
if (RootView* root = FindRootViewForGdkWindow(gwind)) {
switch (xev->type) {
- case KeyPress:
- case KeyRelease: {
+ case KeyPress: {
+ // If Tab is pressed, then the RootView needs to process it first,
+ // because the focus-manager will move the focus to the next focusable
+ // view, without letting the currently focused view process it (which
+ // means, for example, tab-ing to move focus between fields/links in a
+ // RenderWidgetHostViewViews won't work). For all other keys, let the
+ // focus manager process it first so that the keyboard accelerators can
+ // be triggered.
KeyEvent keyev(xev);
-
- // If it's a keypress, check to see if it triggers an accelerator.
- if (xev->type == KeyPress) {
- FocusManager* focus_manager = root->GetFocusManager();
- if (focus_manager && !focus_manager->OnKeyEvent(keyev))
- return true;
+ FocusManager* focus_manager = root->GetFocusManager();
+ if (FocusManager::IsTabTraversalKeyEvent(keyev)) {
+ return root->ProcessKeyEvent(keyev) ||
+ (focus_manager && !focus_manager->OnKeyEvent(keyev));
+ } else {
+ return (focus_manager && !focus_manager->OnKeyEvent(keyev)) ||
+ root->ProcessKeyEvent(keyev);
}
-
- return root->ProcessKeyEvent(keyev);
}
+ case KeyRelease:
+ return root->ProcessKeyEvent(KeyEvent(xev));
+
case ButtonPress:
case ButtonRelease: {
if (xev->xbutton.button == 4 || xev->xbutton.button == 5) {