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 "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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 } | 118 } |
119 #else | 119 #else |
120 if (IsTabTraversalKeyEvent(event)) { | 120 if (IsTabTraversalKeyEvent(event)) { |
121 AdvanceFocus(event.IsShiftDown()); | 121 AdvanceFocus(event.IsShiftDown()); |
122 return false; | 122 return false; |
123 } | 123 } |
124 #endif | 124 #endif |
125 | 125 |
126 // Intercept arrow key messages to switch between grouped views. | 126 // Intercept arrow key messages to switch between grouped views. |
127 ui::KeyboardCode key_code = event.key_code(); | 127 ui::KeyboardCode key_code = event.key_code(); |
128 if (focused_view_ && focused_view_->GetGroup() != -1 && | 128 if (focused_view_ && focused_view_->group() != -1 && |
129 (key_code == ui::VKEY_UP || key_code == ui::VKEY_DOWN || | 129 (key_code == ui::VKEY_UP || key_code == ui::VKEY_DOWN || |
130 key_code == ui::VKEY_LEFT || key_code == ui::VKEY_RIGHT)) { | 130 key_code == ui::VKEY_LEFT || key_code == ui::VKEY_RIGHT)) { |
131 bool next = (key_code == ui::VKEY_RIGHT || key_code == ui::VKEY_DOWN); | 131 bool next = (key_code == ui::VKEY_RIGHT || key_code == ui::VKEY_DOWN); |
132 std::vector<View*> views; | 132 std::vector<View*> views; |
133 focused_view_->parent()->GetViewsWithGroup(focused_view_->GetGroup(), | 133 focused_view_->parent()->GetViewsInGroup(focused_view_->group(), &views); |
134 &views); | |
135 std::vector<View*>::const_iterator iter = std::find(views.begin(), | 134 std::vector<View*>::const_iterator iter = std::find(views.begin(), |
136 views.end(), | 135 views.end(), |
137 focused_view_); | 136 focused_view_); |
138 DCHECK(iter != views.end()); | 137 DCHECK(iter != views.end()); |
139 int index = static_cast<int>(iter - views.begin()); | 138 int index = static_cast<int>(iter - views.begin()); |
140 index += next ? 1 : -1; | 139 index += next ? 1 : -1; |
141 if (index < 0) { | 140 if (index < 0) { |
142 index = static_cast<int>(views.size()) - 1; | 141 index = static_cast<int>(views.size()) - 1; |
143 } else if (index >= static_cast<int>(views.size())) { | 142 } else if (index >= static_cast<int>(views.size())) { |
144 index = 0; | 143 index = 0; |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 std::find(focus_change_listeners_.begin(), focus_change_listeners_.end(), | 499 std::find(focus_change_listeners_.begin(), focus_change_listeners_.end(), |
501 listener); | 500 listener); |
502 if (place == focus_change_listeners_.end()) { | 501 if (place == focus_change_listeners_.end()) { |
503 NOTREACHED() << "Removing a listener that isn't registered."; | 502 NOTREACHED() << "Removing a listener that isn't registered."; |
504 return; | 503 return; |
505 } | 504 } |
506 focus_change_listeners_.erase(place); | 505 focus_change_listeners_.erase(place); |
507 } | 506 } |
508 | 507 |
509 } // namespace views | 508 } // namespace views |
OLD | NEW |