Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: views/focus/focus_search.cc

Issue 7057014: Variety of tweaks to View API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/focus/focus_manager_unittest.cc ('k') | views/layout/box_layout.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 15 matching lines...) Expand all
26 26
27 if (!root_->has_children()) { 27 if (!root_->has_children()) {
28 NOTREACHED(); 28 NOTREACHED();
29 // Nothing to focus on here. 29 // Nothing to focus on here.
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->group();
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 =
41 reverse ? 41 reverse ?
42 root_->GetChildViewAt(root_->child_count() - 1) : 42 root_->GetChildViewAt(root_->child_count() - 1) :
43 root_->GetChildViewAt(0); 43 root_->GetChildViewAt(0);
44 // If there was no starting view, then the one we select is a potential 44 // If there was no starting view, then the one we select is a potential
45 // focus candidate. 45 // focus candidate.
46 check_starting_view = true; 46 check_starting_view = true;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 DCHECK(*focus_traversable_view); 90 DCHECK(*focus_traversable_view);
91 return NULL; 91 return NULL;
92 } 92 }
93 // Nothing found. 93 // Nothing found.
94 return NULL; 94 return NULL;
95 } 95 }
96 96
97 bool FocusSearch::IsViewFocusableCandidate(View* v, int skip_group_id) { 97 bool FocusSearch::IsViewFocusableCandidate(View* v, int skip_group_id) {
98 return IsFocusable(v) && 98 return IsFocusable(v) &&
99 (v->IsGroupFocusTraversable() || skip_group_id == -1 || 99 (v->IsGroupFocusTraversable() || skip_group_id == -1 ||
100 v->GetGroup() != skip_group_id); 100 v->group() != skip_group_id);
101 } 101 }
102 102
103 bool FocusSearch::IsFocusable(View* v) { 103 bool FocusSearch::IsFocusable(View* v) {
104 if (accessibility_mode_) 104 if (accessibility_mode_)
105 return v && v->IsAccessibilityFocusableInRootView(); 105 return v && v->IsAccessibilityFocusableInRootView();
106 106
107 return v && v->IsFocusableInRootView(); 107 return v && v->IsFocusableInRootView();
108 } 108 }
109 109
110 View* FocusSearch::FindSelectedViewForGroup(View* view) { 110 View* FocusSearch::FindSelectedViewForGroup(View* view) {
111 if (view->IsGroupFocusTraversable() || 111 if (view->IsGroupFocusTraversable() ||
112 view->GetGroup() == -1) // No group for that view. 112 view->group() == -1) // No group for that view.
113 return view; 113 return view;
114 114
115 View* selected_view = view->GetSelectedViewForGroup(view->GetGroup()); 115 View* selected_view = view->GetSelectedViewForGroup(view->group());
116 if (selected_view) 116 if (selected_view)
117 return selected_view; 117 return selected_view;
118 118
119 // No view selected for that group, default to the specified view. 119 // No view selected for that group, default to the specified view.
120 return view; 120 return view;
121 } 121 }
122 122
123 View* FocusSearch::GetParent(View* v) { 123 View* FocusSearch::GetParent(View* v) {
124 return root_->Contains(v) ? v->parent() : NULL; 124 return root_->Contains(v) ? v->parent() : NULL;
125 } 125 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 skip_group_id, 265 skip_group_id,
266 focus_traversable, 266 focus_traversable,
267 focus_traversable_view); 267 focus_traversable_view);
268 } 268 }
269 269
270 // We found nothing. 270 // We found nothing.
271 return NULL; 271 return NULL;
272 } 272 }
273 273
274 } // namespace views 274 } // namespace views
OLDNEW
« no previous file with comments | « views/focus/focus_manager_unittest.cc ('k') | views/layout/box_layout.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698