| Index: ui/views/controls/combobox/native_combobox_views.cc
|
| diff --git a/ui/views/controls/combobox/native_combobox_views.cc b/ui/views/controls/combobox/native_combobox_views.cc
|
| index a6e14710cf8a2d4bb067af0065fda4112661ddf0..525b1666241b73abeb3cc89cf266244f51ca863c 100644
|
| --- a/ui/views/controls/combobox/native_combobox_views.cc
|
| +++ b/ui/views/controls/combobox/native_combobox_views.cc
|
| @@ -55,13 +55,13 @@ namespace views {
|
| const char NativeComboboxViews::kViewClassName[] =
|
| "views/NativeComboboxViews";
|
|
|
| -NativeComboboxViews::NativeComboboxViews(Combobox* parent)
|
| - : combobox_(parent),
|
| +NativeComboboxViews::NativeComboboxViews(Combobox* combo_box)
|
| + : combobox_(combo_box),
|
| text_border_(new FocusableBorder()),
|
| disclosure_arrow_(ui::ResourceBundle::GetSharedInstance().GetImageNamed(
|
| IDR_DISCLOSURE_ARROW).ToSkBitmap()),
|
| dropdown_open_(false),
|
| - selected_item_(-1),
|
| + selected_index_(-1),
|
| content_width_(0),
|
| content_height_(0) {
|
| set_border(text_border_);
|
| @@ -92,43 +92,41 @@ bool NativeComboboxViews::OnKeyPressed(const views::KeyEvent& key_event) {
|
| DCHECK(key_event.type() == ui::ET_KEY_PRESSED);
|
|
|
| // Check if we are in the default state (-1) and set to first item.
|
| - if(selected_item_ == -1)
|
| - selected_item_ = 0;
|
| + if(selected_index_ == -1)
|
| + selected_index_ = 0;
|
|
|
| - int new_item = selected_item_;
|
| - switch(key_event.key_code()){
|
| -
|
| - // move to the next element if any
|
| + int new_index = selected_index_;
|
| + switch (key_event.key_code()) {
|
| + // Move to the next element if any.
|
| case ui::VKEY_DOWN:
|
| - if (new_item < (combobox_->model()->GetItemCount() - 1))
|
| - new_item++;
|
| + if (new_index < (combobox_->model()->GetItemCount() - 1))
|
| + new_index++;
|
| break;
|
|
|
| - // move to the end of the list
|
| + // Move to the end of the list,
|
| case ui::VKEY_END:
|
| case ui::VKEY_NEXT:
|
| - new_item = combobox_->model()->GetItemCount() - 1;
|
| + new_index = combobox_->model()->GetItemCount() - 1;
|
| break;
|
|
|
| - // move to the top of the list
|
| + // Move to the top of the list.
|
| case ui::VKEY_HOME:
|
| case ui::VKEY_PRIOR:
|
| - new_item = 0;
|
| + new_index = 0;
|
| break;
|
|
|
| // move to the previous element if any
|
| case ui::VKEY_UP:
|
| - if (new_item > 0)
|
| - new_item--;
|
| + if (new_index > 0)
|
| + new_index--;
|
| break;
|
|
|
| default:
|
| return false;
|
| -
|
| }
|
|
|
| - if(new_item != selected_item_) {
|
| - selected_item_ = new_item;
|
| + if (new_index != selected_index_) {
|
| + selected_index_ = new_index;
|
| combobox_->SelectionChanged();
|
| SchedulePaint();
|
| }
|
| @@ -182,16 +180,16 @@ void NativeComboboxViews::UpdateFromModel() {
|
| content_height_ = font.GetFontSize();
|
| }
|
|
|
| -void NativeComboboxViews::UpdateSelectedItem() {
|
| - selected_item_ = combobox_->selected_item();
|
| +void NativeComboboxViews::UpdateSelectedIndex() {
|
| + selected_index_ = combobox_->selected_index();
|
| }
|
|
|
| void NativeComboboxViews::UpdateEnabled() {
|
| SetEnabled(combobox_->enabled());
|
| }
|
|
|
| -int NativeComboboxViews::GetSelectedItem() const {
|
| - return selected_item_;
|
| +int NativeComboboxViews::GetSelectedIndex() const {
|
| + return selected_index_;
|
| }
|
|
|
| bool NativeComboboxViews::IsDropdownOpen() const {
|
| @@ -253,10 +251,10 @@ bool NativeComboboxViews::IsCommandEnabled(int id) const {
|
| }
|
|
|
| void NativeComboboxViews::ExecuteCommand(int id) {
|
| - // revert menu offset to map back to combobox model
|
| + // Revert menu offset to map back to combobox model.
|
| id -= kFirstMenuItemId;
|
| DCHECK_LT(id, combobox_->model()->GetItemCount());
|
| - selected_item_ = id;
|
| + selected_index_ = id;
|
| combobox_->SelectionChanged();
|
| SchedulePaint();
|
| }
|
| @@ -283,7 +281,7 @@ void NativeComboboxViews::PaintText(gfx::Canvas* canvas) {
|
| int text_height = height() - insets.height();
|
| SkColor text_color = kTextColor;
|
|
|
| - int index = GetSelectedItem();
|
| + int index = GetSelectedIndex();
|
| if (index < 0 || index > combobox_->model()->GetItemCount())
|
| index = 0;
|
| string16 text = combobox_->model()->GetItemAt(index);
|
|
|