Chromium Code Reviews| Index: ui/views/focus/focus_manager.cc |
| diff --git a/ui/views/focus/focus_manager.cc b/ui/views/focus/focus_manager.cc |
| index c84c3152734d2de2994673aee76b89365884d19d..05209c8f31112749664585317019dac8e94a7cc9 100644 |
| --- a/ui/views/focus/focus_manager.cc |
| +++ b/ui/views/focus/focus_manager.cc |
| @@ -35,7 +35,8 @@ FocusManager::FocusManager(Widget* widget, FocusManagerDelegate* delegate) |
| accelerator_manager_(new ui::AcceleratorManager), |
| shortcut_handling_suspended_(false), |
| focus_change_reason_(kReasonDirectFocusChange), |
| - is_changing_focus_(false) { |
| + is_changing_focus_(false), |
| + keyboard_accessibility_(false) { |
| DCHECK(widget_); |
| stored_focused_view_storage_id_ = |
| ViewStorage::GetInstance()->CreateStorageID(); |
| @@ -297,6 +298,13 @@ View* FocusManager::GetNextFocusableView(View* original_starting_view, |
| return NULL; |
| } |
| +void FocusManager::SetKeyboardAccessibility(bool keyboard_accessibility) { |
| + keyboard_accessibility_ = keyboard_accessibility; |
|
tapted
2016/02/23 03:01:19
this should early-exit if there is no change
karandeepb
2016/03/15 02:19:50
Done.
|
| + // Disabling keyboard accessibility may cause the focused view to become not |
| + // focusable. Hence advance focus if necessary. |
| + AdvanceFocusIfNecessary(); |
| +} |
| + |
| void FocusManager::SetFocusedViewWithReason( |
| View* view, FocusChangeReason reason) { |
| if (focused_view_ == view) |
| @@ -341,9 +349,9 @@ void FocusManager::AdvanceFocusIfNecessary() { |
| // If widget is active and focused view is not focusable, advance focus or, |
| // if not possible, clear focus. |
| - if (focused_view_ && !focused_view_->IsAccessibilityFocusable()) { |
| + if (focused_view_ && !IsFocusable(focused_view_)) { |
| AdvanceFocus(false); |
| - if (focused_view_ && !focused_view_->IsAccessibilityFocusable()) |
| + if (focused_view_ && !IsFocusable(focused_view_)) |
| ClearFocus(); |
| } |
| } |
| @@ -393,9 +401,11 @@ bool FocusManager::RestoreFocusedView() { |
| focus_change_reason_ = kReasonFocusRestore; |
| } |
| } |
| - return true; |
| + // The keyboard_accessibility_ mode may have changed while the widget was |
| + // inactive. |
| + AdvanceFocusIfNecessary(); |
| } |
| - return false; |
| + return view == focused_view_; |
| } |
| void FocusManager::SetStoredFocusView(View* focus_view) { |
| @@ -542,4 +552,10 @@ bool FocusManager::ProcessArrowKeyTraversal(const ui::KeyEvent& event) { |
| return false; |
| } |
| +bool FocusManager::IsFocusable(View* v) { |
|
tapted
2016/02/23 03:01:19
v -> view
karandeepb
2016/03/15 02:19:50
Done.
|
| + if (keyboard_accessibility_) |
| + return v && v->IsAccessibilityFocusable(); |
|
tapted
2016/02/23 03:01:19
I think the null checks are redundant - perhaps DC
karandeepb
2016/03/15 02:19:50
Done.
|
| + return v && v->IsFocusable(); |
| +} |
| + |
| } // namespace views |