| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "views/focus/focus_manager.h" | 6 #include "views/focus/focus_manager.h" |
| 7 #include "views/focus/focus_search.h" | 7 #include "views/focus/focus_search.h" |
| 8 #include "views/view.h" | 8 #include "views/view.h" |
| 9 | 9 |
| 10 namespace views { | 10 namespace views { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 return NULL; | 30 return NULL; |
| 31 } | 31 } |
| 32 | 32 |
| 33 View* initial_starting_view = starting_view; | 33 View* initial_starting_view = starting_view; |
| 34 int starting_view_group = -1; | 34 int starting_view_group = -1; |
| 35 if (starting_view) | 35 if (starting_view) |
| 36 starting_view_group = starting_view->GetGroup(); | 36 starting_view_group = starting_view->GetGroup(); |
| 37 | 37 |
| 38 if (!starting_view) { | 38 if (!starting_view) { |
| 39 // Default to the first/last child | 39 // Default to the first/last child |
| 40 starting_view = | 40 starting_view = reverse ? root_->child_at(root_->child_count() - 1) : |
| 41 reverse ? | 41 root_->child_at(0); |
| 42 root_->GetChildViewAt(root_->child_count() - 1) : | |
| 43 root_->GetChildViewAt(0); | |
| 44 // If there was no starting view, then the one we select is a potential | 42 // If there was no starting view, then the one we select is a potential |
| 45 // focus candidate. | 43 // focus candidate. |
| 46 check_starting_view = true; | 44 check_starting_view = true; |
| 47 } else { | 45 } else { |
| 48 // The starting view should be a direct or indirect child of the root. | 46 // The starting view should be a direct or indirect child of the root. |
| 49 DCHECK(root_->Contains(starting_view)); | 47 DCHECK(root_->Contains(starting_view)); |
| 50 } | 48 } |
| 51 | 49 |
| 52 View* v = NULL; | 50 View* v = NULL; |
| 53 if (!reverse) { | 51 if (!reverse) { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 *focus_traversable = starting_view->GetFocusTraversable(); | 150 *focus_traversable = starting_view->GetFocusTraversable(); |
| 153 if (*focus_traversable) { | 151 if (*focus_traversable) { |
| 154 *focus_traversable_view = starting_view; | 152 *focus_traversable_view = starting_view; |
| 155 return NULL; | 153 return NULL; |
| 156 } | 154 } |
| 157 } | 155 } |
| 158 | 156 |
| 159 // First let's try the left child. | 157 // First let's try the left child. |
| 160 if (can_go_down) { | 158 if (can_go_down) { |
| 161 if (starting_view->has_children()) { | 159 if (starting_view->has_children()) { |
| 162 View* v = FindNextFocusableViewImpl(starting_view->GetChildViewAt(0), | 160 View* v = FindNextFocusableViewImpl(starting_view->child_at(0), |
| 163 true, false, true, skip_group_id, | 161 true, false, true, skip_group_id, |
| 164 focus_traversable, | 162 focus_traversable, |
| 165 focus_traversable_view); | 163 focus_traversable_view); |
| 166 if (v || *focus_traversable) | 164 if (v || *focus_traversable) |
| 167 return v; | 165 return v; |
| 168 } | 166 } |
| 169 } | 167 } |
| 170 | 168 |
| 171 // Then try the right sibling. | 169 // Then try the right sibling. |
| 172 View* sibling = starting_view->GetNextFocusableView(); | 170 View* sibling = starting_view->GetNextFocusableView(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 // Before we go into the direct children, we have to check if this view has | 216 // Before we go into the direct children, we have to check if this view has |
| 219 // a FocusTraversable. | 217 // a FocusTraversable. |
| 220 *focus_traversable = starting_view->GetFocusTraversable(); | 218 *focus_traversable = starting_view->GetFocusTraversable(); |
| 221 if (*focus_traversable) { | 219 if (*focus_traversable) { |
| 222 *focus_traversable_view = starting_view; | 220 *focus_traversable_view = starting_view; |
| 223 return NULL; | 221 return NULL; |
| 224 } | 222 } |
| 225 | 223 |
| 226 if (starting_view->has_children()) { | 224 if (starting_view->has_children()) { |
| 227 View* view = | 225 View* view = |
| 228 starting_view->GetChildViewAt(starting_view->child_count() - 1); | 226 starting_view->child_at(starting_view->child_count() - 1); |
| 229 View* v = FindPreviousFocusableViewImpl(view, true, false, true, | 227 View* v = FindPreviousFocusableViewImpl(view, true, false, true, |
| 230 skip_group_id, | 228 skip_group_id, |
| 231 focus_traversable, | 229 focus_traversable, |
| 232 focus_traversable_view); | 230 focus_traversable_view); |
| 233 if (v || *focus_traversable) | 231 if (v || *focus_traversable) |
| 234 return v; | 232 return v; |
| 235 } | 233 } |
| 236 } | 234 } |
| 237 | 235 |
| 238 // Then look at this view. Here, we do not need to see if the view has | 236 // Then look at this view. Here, we do not need to see if the view has |
| (...skipping 26 matching lines...) Expand all Loading... |
| 265 skip_group_id, | 263 skip_group_id, |
| 266 focus_traversable, | 264 focus_traversable, |
| 267 focus_traversable_view); | 265 focus_traversable_view); |
| 268 } | 266 } |
| 269 | 267 |
| 270 // We found nothing. | 268 // We found nothing. |
| 271 return NULL; | 269 return NULL; |
| 272 } | 270 } |
| 273 | 271 |
| 274 } // namespace views | 272 } // namespace views |
| OLD | NEW |