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 keyboard accessibility mode defined in FocusManager is |
| 19 // used. No special accessibility mode should be applicable for a |
| 20 // FocusTraversable. |
| 21 accessibility_mode_ = false; |
| 22 #endif |
16 } | 23 } |
17 | 24 |
18 View* FocusSearch::FindNextFocusableView(View* starting_view, | 25 View* FocusSearch::FindNextFocusableView(View* starting_view, |
19 bool reverse, | 26 bool reverse, |
20 Direction direction, | 27 Direction direction, |
21 bool check_starting_view, | 28 bool check_starting_view, |
22 FocusTraversable** focus_traversable, | 29 FocusTraversable** focus_traversable, |
23 View** focus_traversable_view) { | 30 View** focus_traversable_view) { |
24 *focus_traversable = NULL; | 31 *focus_traversable = NULL; |
25 *focus_traversable_view = NULL; | 32 *focus_traversable_view = NULL; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 return NULL; | 99 return NULL; |
93 } | 100 } |
94 | 101 |
95 bool FocusSearch::IsViewFocusableCandidate(View* v, int skip_group_id) { | 102 bool FocusSearch::IsViewFocusableCandidate(View* v, int skip_group_id) { |
96 return IsFocusable(v) && | 103 return IsFocusable(v) && |
97 (v->IsGroupFocusTraversable() || skip_group_id == -1 || | 104 (v->IsGroupFocusTraversable() || skip_group_id == -1 || |
98 v->GetGroup() != skip_group_id); | 105 v->GetGroup() != skip_group_id); |
99 } | 106 } |
100 | 107 |
101 bool FocusSearch::IsFocusable(View* v) { | 108 bool FocusSearch::IsFocusable(View* v) { |
102 if (accessibility_mode_) | 109 DCHECK(root_); |
| 110 // Sanity Check. Currently the FocusManager keyboard accessibility mode is |
| 111 // only used on Mac, for which |accessibility_mode_| is false. |
| 112 DCHECK(!(accessibility_mode_ && |
| 113 root_->GetWidget()->GetFocusManager()->keyboard_accessible())); |
| 114 if (accessibility_mode_ || |
| 115 root_->GetWidget()->GetFocusManager()->keyboard_accessible()) |
103 return v && v->IsAccessibilityFocusable(); | 116 return v && v->IsAccessibilityFocusable(); |
104 return v && v->IsFocusable(); | 117 return v && v->IsFocusable(); |
105 } | 118 } |
106 | 119 |
107 View* FocusSearch::FindSelectedViewForGroup(View* view) { | 120 View* FocusSearch::FindSelectedViewForGroup(View* view) { |
108 if (view->IsGroupFocusTraversable() || | 121 if (view->IsGroupFocusTraversable() || |
109 view->GetGroup() == -1) // No group for that view. | 122 view->GetGroup() == -1) // No group for that view. |
110 return view; | 123 return view; |
111 | 124 |
112 View* selected_view = view->GetSelectedViewForGroup(view->GetGroup()); | 125 View* selected_view = view->GetSelectedViewForGroup(view->GetGroup()); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 skip_group_id, | 279 skip_group_id, |
267 focus_traversable, | 280 focus_traversable, |
268 focus_traversable_view); | 281 focus_traversable_view); |
269 } | 282 } |
270 | 283 |
271 // We found nothing. | 284 // We found nothing. |
272 return NULL; | 285 return NULL; |
273 } | 286 } |
274 | 287 |
275 } // namespace views | 288 } // namespace views |
OLD | NEW |