From 08100efefac6f4cf861f9b294a6cdebb7171c380 Mon Sep 17 00:00:00 2001 From: "dmazzoni@chromium.org" Date: Fri, 23 Jul 2010 15:48:26 +0000 Subject: 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 --- views/focus/focus_manager.cc | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'views') 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 -- cgit v1.1