Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Unified Diff: ui/views/focus/focus_manager.cc

Issue 1973073003: Views: Change View::RequestFocus to respect keyboard accessibility. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add RequestFocus test Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/tabs/tab_unittest.cc ('k') | ui/views/focus/focus_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/focus/focus_manager.cc
diff --git a/ui/views/focus/focus_manager.cc b/ui/views/focus/focus_manager.cc
index 436daf0c04f11bf7ec761fead33d15356acec9ff..bd6b0dc19fe4749a958afe41f8c49dd158ed446a 100644
--- a/ui/views/focus/focus_manager.cc
+++ b/ui/views/focus/focus_manager.cc
@@ -387,16 +387,23 @@ void FocusManager::StoreFocusedView(bool clear_native_focus) {
bool FocusManager::RestoreFocusedView() {
View* view = GetStoredFocusView();
- if (view && ContainsView(view)) {
- // This usually just sets the focus if this view is accessibility
- // 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;
-
+ if (view) {
karandeepb 2016/05/13 09:05:31 This is the same as the code before https://codere
+ if (ContainsView(view)) {
+ if (!view->IsFocusable() && view->IsAccessibilityFocusable()) {
+ // 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;
+ }
+ }
// The |keyboard_accessible_| mode may have changed while the widget was
// inactive.
AdvanceFocusIfNecessary();
« no previous file with comments | « chrome/browser/ui/views/tabs/tab_unittest.cc ('k') | ui/views/focus/focus_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698