Chromium Code Reviews| Index: ui/views/view.cc |
| diff --git a/ui/views/view.cc b/ui/views/view.cc |
| index 431ba349077e1dec04cacc066b4e67d263e96a2a..39f6e55fc45b9cc3c8d05ce46c215e756cfd380a 100644 |
| --- a/ui/views/view.cc |
| +++ b/ui/views/view.cc |
| @@ -1199,12 +1199,21 @@ void View::SetNextFocusableView(View* view) { |
| next_focusable_view_ = view; |
| } |
| -void View::SetFocusable(bool focusable) { |
| - if (focusable_ == focusable) |
| - return; |
| - |
| - focusable_ = focusable; |
| - AdvanceFocusIfNecessary(); |
| +void View::SetFocusBehavior(FocusBehavior focus_behavior) { |
| + switch (focus_behavior) { |
| + case FocusBehavior::ALWAYS: |
| + SetFocusable(true); |
| + SetAccessibilityFocusable(true); |
| + break; |
| + case FocusBehavior::NEVER: |
| + SetFocusable(false); |
| + SetAccessibilityFocusable(false); |
| + break; |
| + case FocusBehavior::ACCESSIBLE_ONLY: |
| + SetFocusable(false); |
| + SetAccessibilityFocusable(true); |
| + break; |
| + } |
| } |
| bool View::IsFocusable() const { |
| @@ -1215,14 +1224,6 @@ bool View::IsAccessibilityFocusable() const { |
| return (focusable_ || accessibility_focusable_) && enabled_ && IsDrawn(); |
| } |
| -void View::SetAccessibilityFocusable(bool accessibility_focusable) { |
| - if (accessibility_focusable_ == accessibility_focusable) |
| - return; |
| - |
| - accessibility_focusable_ = accessibility_focusable; |
| - AdvanceFocusIfNecessary(); |
| -} |
| - |
| FocusManager* View::GetFocusManager() { |
| Widget* widget = GetWidget(); |
| return widget ? widget->GetFocusManager() : NULL; |
| @@ -1235,7 +1236,7 @@ const FocusManager* View::GetFocusManager() const { |
| void View::RequestFocus() { |
| FocusManager* focus_manager = GetFocusManager(); |
| - if (focus_manager && IsFocusable()) |
| + if (focus_manager && IsAccessibilityFocusable()) |
|
karandeepb
2016/04/18 11:29:02
Does changing IsFocusable to IsAccessibilityFocusa
|
| focus_manager->SetFocusedView(this); |
| } |
| @@ -2311,6 +2312,22 @@ void View::UnregisterAccelerators(bool leave_data_intact) { |
| // Focus ----------------------------------------------------------------------- |
| +void View::SetFocusable(bool focusable) { |
| + if (focusable_ == focusable) |
| + return; |
| + |
| + focusable_ = focusable; |
| + AdvanceFocusIfNecessary(); |
| +} |
| + |
| +void View::SetAccessibilityFocusable(bool accessibility_focusable) { |
| + if (accessibility_focusable_ == accessibility_focusable) |
| + return; |
| + |
| + accessibility_focusable_ = accessibility_focusable; |
| + AdvanceFocusIfNecessary(); |
| +} |
| + |
| void View::InitFocusSiblings(View* v, int index) { |
| int count = child_count(); |