OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/logging.h" | 5 #include "base/logging.h" |
6 #include "ui/views/focus/focus_manager.h" | 6 #include "ui/views/focus/focus_manager.h" |
7 #include "ui/views/focus/focus_search.h" | 7 #include "ui/views/focus/focus_search.h" |
8 #include "ui/views/view.h" | 8 #include "ui/views/view.h" |
| 9 #include "ui/views/widget/widget.h" |
9 | 10 |
10 namespace views { | 11 namespace views { |
11 | 12 |
12 FocusSearch::FocusSearch(View* root, bool cycle, bool accessibility_mode) | 13 FocusSearch::FocusSearch(View* root, bool cycle, bool accessibility_mode) |
13 : root_(root), | 14 : root_(root), |
14 cycle_(cycle), | 15 cycle_(cycle), |
15 accessibility_mode_(accessibility_mode) { | 16 accessibility_mode_(accessibility_mode) { |
| 17 #if defined(OS_MACOSX) |
| 18 // On Mac, only the platform level accessibility mode is used. No special |
| 19 // accessibility mode should be applicable for a FocusTraversable. |
| 20 accessibility_mode_ = false; |
| 21 #endif |
16 } | 22 } |
17 | 23 |
18 View* FocusSearch::FindNextFocusableView(View* starting_view, | 24 View* FocusSearch::FindNextFocusableView(View* starting_view, |
19 bool reverse, | 25 bool reverse, |
20 Direction direction, | 26 Direction direction, |
21 bool check_starting_view, | 27 bool check_starting_view, |
22 FocusTraversable** focus_traversable, | 28 FocusTraversable** focus_traversable, |
23 View** focus_traversable_view) { | 29 View** focus_traversable_view) { |
24 *focus_traversable = NULL; | 30 *focus_traversable = NULL; |
25 *focus_traversable_view = NULL; | 31 *focus_traversable_view = NULL; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 return NULL; | 98 return NULL; |
93 } | 99 } |
94 | 100 |
95 bool FocusSearch::IsViewFocusableCandidate(View* v, int skip_group_id) { | 101 bool FocusSearch::IsViewFocusableCandidate(View* v, int skip_group_id) { |
96 return IsFocusable(v) && | 102 return IsFocusable(v) && |
97 (v->IsGroupFocusTraversable() || skip_group_id == -1 || | 103 (v->IsGroupFocusTraversable() || skip_group_id == -1 || |
98 v->GetGroup() != skip_group_id); | 104 v->GetGroup() != skip_group_id); |
99 } | 105 } |
100 | 106 |
101 bool FocusSearch::IsFocusable(View* v) { | 107 bool FocusSearch::IsFocusable(View* v) { |
102 if (accessibility_mode_) | 108 DCHECK(root_); |
| 109 if (accessibility_mode_ || |
| 110 root_->GetWidget()->GetFocusManager()->keyboard_accessible()) |
103 return v && v->IsAccessibilityFocusable(); | 111 return v && v->IsAccessibilityFocusable(); |
104 return v && v->IsFocusable(); | 112 return v && v->IsFocusable(); |
105 } | 113 } |
106 | 114 |
107 View* FocusSearch::FindSelectedViewForGroup(View* view) { | 115 View* FocusSearch::FindSelectedViewForGroup(View* view) { |
108 if (view->IsGroupFocusTraversable() || | 116 if (view->IsGroupFocusTraversable() || |
109 view->GetGroup() == -1) // No group for that view. | 117 view->GetGroup() == -1) // No group for that view. |
110 return view; | 118 return view; |
111 | 119 |
112 View* selected_view = view->GetSelectedViewForGroup(view->GetGroup()); | 120 View* selected_view = view->GetSelectedViewForGroup(view->GetGroup()); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 skip_group_id, | 274 skip_group_id, |
267 focus_traversable, | 275 focus_traversable, |
268 focus_traversable_view); | 276 focus_traversable_view); |
269 } | 277 } |
270 | 278 |
271 // We found nothing. | 279 // We found nothing. |
272 return NULL; | 280 return NULL; |
273 } | 281 } |
274 | 282 |
275 } // namespace views | 283 } // namespace views |
OLD | NEW |