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

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

Issue 6452011: Rework tree APIs to reflect Google style and more const-correctness.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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/external_focus_tracker.cc ('k') | views/focus/focus_search.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 "views/focus/focus_manager.h" 5 #include "views/focus/focus_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 10
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 } 119 }
120 #endif 120 #endif
121 121
122 // Intercept arrow key messages to switch between grouped views. 122 // Intercept arrow key messages to switch between grouped views.
123 ui::KeyboardCode key_code = event.GetKeyCode(); 123 ui::KeyboardCode key_code = event.GetKeyCode();
124 if (focused_view_ && focused_view_->GetGroup() != -1 && 124 if (focused_view_ && focused_view_->GetGroup() != -1 &&
125 (key_code == ui::VKEY_UP || key_code == ui::VKEY_DOWN || 125 (key_code == ui::VKEY_UP || key_code == ui::VKEY_DOWN ||
126 key_code == ui::VKEY_LEFT || key_code == ui::VKEY_RIGHT)) { 126 key_code == ui::VKEY_LEFT || key_code == ui::VKEY_RIGHT)) {
127 bool next = (key_code == ui::VKEY_RIGHT || key_code == ui::VKEY_DOWN); 127 bool next = (key_code == ui::VKEY_RIGHT || key_code == ui::VKEY_DOWN);
128 std::vector<View*> views; 128 std::vector<View*> views;
129 focused_view_->GetParent()->GetViewsWithGroup(focused_view_->GetGroup(), 129 focused_view_->parent()->GetViewsWithGroup(focused_view_->GetGroup(),
130 &views); 130 &views);
131 std::vector<View*>::const_iterator iter = std::find(views.begin(), 131 std::vector<View*>::const_iterator iter = std::find(views.begin(),
132 views.end(), 132 views.end(),
133 focused_view_); 133 focused_view_);
134 DCHECK(iter != views.end()); 134 DCHECK(iter != views.end());
135 int index = static_cast<int>(iter - views.begin()); 135 int index = static_cast<int>(iter - views.begin());
136 index += next ? 1 : -1; 136 index += next ? 1 : -1;
137 if (index < 0) { 137 if (index < 0) {
138 index = static_cast<int>(views.size()) - 1; 138 index = static_cast<int>(views.size()) - 1;
139 } else if (index >= static_cast<int>(views.size())) { 139 } else if (index >= static_cast<int>(views.size())) {
140 index = 0; 140 index = 0;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 // Search up the containment hierarchy to see if a view is acting as 217 // Search up the containment hierarchy to see if a view is acting as
218 // a pane, and wants to implement its own focus traversable to keep 218 // a pane, and wants to implement its own focus traversable to keep
219 // the focus trapped within that pane. 219 // the focus trapped within that pane.
220 View* pane_search = original_starting_view; 220 View* pane_search = original_starting_view;
221 while (pane_search) { 221 while (pane_search) {
222 focus_traversable = pane_search->GetPaneFocusTraversable(); 222 focus_traversable = pane_search->GetPaneFocusTraversable();
223 if (focus_traversable) { 223 if (focus_traversable) {
224 starting_view = original_starting_view; 224 starting_view = original_starting_view;
225 break; 225 break;
226 } 226 }
227 pane_search = pane_search->GetParent(); 227 pane_search = pane_search->parent();
228 } 228 }
229 229
230 if (!focus_traversable) { 230 if (!focus_traversable) {
231 if (!reverse) { 231 if (!reverse) {
232 // If the starting view has a focus traversable, use it. 232 // If the starting view has a focus traversable, use it.
233 // This is the case with WidgetWins for example. 233 // This is the case with WidgetWins for example.
234 focus_traversable = original_starting_view->GetFocusTraversable(); 234 focus_traversable = original_starting_view->GetFocusTraversable();
235 235
236 // Otherwise default to the root view. 236 // Otherwise default to the root view.
237 if (!focus_traversable) { 237 if (!focus_traversable) {
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 std::find(focus_change_listeners_.begin(), focus_change_listeners_.end(), 530 std::find(focus_change_listeners_.begin(), focus_change_listeners_.end(),
531 listener); 531 listener);
532 if (place == focus_change_listeners_.end()) { 532 if (place == focus_change_listeners_.end()) {
533 NOTREACHED() << "Removing a listener that isn't registered."; 533 NOTREACHED() << "Removing a listener that isn't registered.";
534 return; 534 return;
535 } 535 }
536 focus_change_listeners_.erase(place); 536 focus_change_listeners_.erase(place);
537 } 537 }
538 538
539 } // namespace views 539 } // namespace views
OLDNEW
« no previous file with comments | « views/focus/external_focus_tracker.cc ('k') | views/focus/focus_search.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698