summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authordmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-23 15:48:26 +0000
committerdmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-23 15:48:26 +0000
commit08100efefac6f4cf861f9b294a6cdebb7171c380 (patch)
treef882304043ee02983ddcc606a2f916f87e72546c /views
parent517d2fe72fd3e3ea3022279aab7e391be75804cf (diff)
downloadchromium_src-08100efefac6f4cf861f9b294a6cdebb7171c380.zip
chromium_src-08100efefac6f4cf861f9b294a6cdebb7171c380.tar.gz
chromium_src-08100efefac6f4cf861f9b294a6cdebb7171c380.tar.bz2
Fix regression that stopped properly restoring focus to tab contents.
The bug in r51262 was that native_tab_contents_container_win overrides RequestFocus, so it can't be *reliably* focused just using SetFocus. This is a simple, straightforward fix that should be merged for M6. Afterwards, I think a better solution for the dev channel would be to get rid of the hacky RequestFocus overrides and add a View::HasNativeFocus method so that FocusManager can tell when it thinks a view already has focus, but the native focus might need to be set again. Thoughts? BUG=48917 BUG=49061 TEST=none Review URL: http://codereview.chromium.org/3013023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53471 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/focus/focus_manager.cc19
1 files changed, 16 insertions, 3 deletions
diff --git a/views/focus/focus_manager.cc b/views/focus/focus_manager.cc
index ee70d5b..5a94c95 100644
--- a/views/focus/focus_manager.cc
+++ b/views/focus/focus_manager.cc
@@ -361,9 +361,22 @@ void FocusManager::RestoreFocusedView() {
View* view = view_storage->RetrieveView(stored_focused_view_storage_id_);
if (view) {
- if (ContainsView(view) && (view->IsFocusableInRootView() ||
- view->IsAccessibilityFocusableInRootView())) {
- SetFocusedViewWithReason(view, kReasonFocusRestore);
+ if (ContainsView(view)) {
+ if (!view->IsFocusableInRootView() &&
+ view->IsAccessibilityFocusableInRootView()) {
+ // RequestFocus would fail, but we want to restore focus to controls
+ // that had focus in accessibility mode.
+ SetFocusedViewWithReason(view, kReasonFocusRestore);
+ } else {
+ // This usually just sets the focus if this view is focusable, but
+ // let the view override RequestFocus if necessary.
+ view->RequestFocus();
+
+ // If it succeeded, the reason would be incorrect; set it to
+ // focus restore.
+ if (focused_view_ == view)
+ focus_change_reason_ = kReasonFocusRestore;
+ }
}
} else {
// Clearing the focus will focus the root window, so we still get key