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

Side by Side Diff: ui/views/controls/combobox/combobox.cc

Issue 26540004: Return blank strings for Views Combobox separator items. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Upload again to kick the CQ. Created 7 years, 2 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 | « no previous file | ui/views/controls/combobox/combobox_unittest.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/views/controls/combobox/combobox.h" 5 #include "ui/views/controls/combobox/combobox.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "grit/ui_resources.h" 9 #include "grit/ui_resources.h"
10 #include "ui/base/accessibility/accessible_view_state.h" 10 #include "ui/base/accessibility/accessible_view_state.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 171
172 int Combobox::GetSelectedRow() { 172 int Combobox::GetSelectedRow() {
173 return selected_index_; 173 return selected_index_;
174 } 174 }
175 175
176 void Combobox::SetSelectedRow(int row) { 176 void Combobox::SetSelectedRow(int row) {
177 SetSelectedIndex(row); 177 SetSelectedIndex(row);
178 } 178 }
179 179
180 string16 Combobox::GetTextForRow(int row) { 180 string16 Combobox::GetTextForRow(int row) {
181 return model()->GetItemAt(row); 181 return model()->IsItemSeparatorAt(row) ? string16() : model()->GetItemAt(row);
182 } 182 }
183 183
184 //////////////////////////////////////////////////////////////////////////////// 184 ////////////////////////////////////////////////////////////////////////////////
185 // Combobox, View overrides: 185 // Combobox, View overrides:
186 186
187 gfx::Size Combobox::GetPreferredSize() { 187 gfx::Size Combobox::GetPreferredSize() {
188 if (content_size_.IsEmpty()) 188 if (content_size_.IsEmpty())
189 UpdateFromModel(); 189 UpdateFromModel();
190 190
191 // The preferred size will drive the local bounds which in turn is used to set 191 // The preferred size will drive the local bounds which in turn is used to set
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 459
460 int Combobox::MenuCommandToIndex(int menu_command_id) const { 460 int Combobox::MenuCommandToIndex(int menu_command_id) const {
461 // (note that the id received is offset by kFirstMenuItemId) 461 // (note that the id received is offset by kFirstMenuItemId)
462 // Revert menu ID offset to map back to combobox model. 462 // Revert menu ID offset to map back to combobox model.
463 int index = menu_command_id - kFirstMenuItemId; 463 int index = menu_command_id - kFirstMenuItemId;
464 DCHECK_LT(index, model()->GetItemCount()); 464 DCHECK_LT(index, model()->GetItemCount());
465 return index; 465 return index;
466 } 466 }
467 467
468 } // namespace views 468 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/combobox/combobox_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698