| OLD | NEW |
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "ui/accessibility/ax_view_state.h" | 14 #include "ui/accessibility/ax_node_data.h" |
| 15 #include "ui/base/default_style.h" | 15 #include "ui/base/default_style.h" |
| 16 #include "ui/base/ime/input_method.h" | 16 #include "ui/base/ime/input_method.h" |
| 17 #include "ui/base/material_design/material_design_controller.h" | 17 #include "ui/base/material_design/material_design_controller.h" |
| 18 #include "ui/base/models/combobox_model.h" | 18 #include "ui/base/models/combobox_model.h" |
| 19 #include "ui/base/models/combobox_model_observer.h" | 19 #include "ui/base/models/combobox_model_observer.h" |
| 20 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
| 21 #include "ui/events/event.h" | 21 #include "ui/events/event.h" |
| 22 #include "ui/gfx/animation/throb_animation.h" | 22 #include "ui/gfx/animation/throb_animation.h" |
| 23 #include "ui/gfx/canvas.h" | 23 #include "ui/gfx/canvas.h" |
| 24 #include "ui/gfx/color_palette.h" | 24 #include "ui/gfx/color_palette.h" |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 GetInputMethod()->DetachTextInputClient(GetPrefixSelector()); | 726 GetInputMethod()->DetachTextInputClient(GetPrefixSelector()); |
| 727 | 727 |
| 728 if (selector_) | 728 if (selector_) |
| 729 selector_->OnViewBlur(); | 729 selector_->OnViewBlur(); |
| 730 // Border renders differently when focused. | 730 // Border renders differently when focused. |
| 731 SchedulePaint(); | 731 SchedulePaint(); |
| 732 if (UseMd()) | 732 if (UseMd()) |
| 733 FocusRing::Uninstall(this); | 733 FocusRing::Uninstall(this); |
| 734 } | 734 } |
| 735 | 735 |
| 736 void Combobox::GetAccessibleState(ui::AXViewState* state) { | 736 void Combobox::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
| 737 state->role = ui::AX_ROLE_COMBO_BOX; | 737 node_data->role = ui::AX_ROLE_COMBO_BOX; |
| 738 state->name = accessible_name_; | 738 node_data->SetName(accessible_name_); |
| 739 state->value = model_->GetItemAt(selected_index_); | 739 node_data->SetValue(model_->GetItemAt(selected_index_)); |
| 740 state->index = selected_index_; | 740 node_data->AddIntAttribute(ui::AX_ATTR_POS_IN_SET, selected_index_); |
| 741 state->count = model_->GetItemCount(); | 741 node_data->AddIntAttribute(ui::AX_ATTR_SET_SIZE, model_->GetItemCount()); |
| 742 } | 742 } |
| 743 | 743 |
| 744 void Combobox::ButtonPressed(Button* sender, const ui::Event& event) { | 744 void Combobox::ButtonPressed(Button* sender, const ui::Event& event) { |
| 745 if (!enabled()) | 745 if (!enabled()) |
| 746 return; | 746 return; |
| 747 | 747 |
| 748 if (!UseMd()) | 748 if (!UseMd()) |
| 749 RequestFocus(); | 749 RequestFocus(); |
| 750 | 750 |
| 751 if (sender == text_button_) { | 751 if (sender == text_button_) { |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 const int kMdPaddingWidth = 8; | 994 const int kMdPaddingWidth = 8; |
| 995 int arrow_pad = UseMd() ? kMdPaddingWidth | 995 int arrow_pad = UseMd() ? kMdPaddingWidth |
| 996 : PlatformStyle::kComboboxNormalArrowPadding; | 996 : PlatformStyle::kComboboxNormalArrowPadding; |
| 997 int padding = style_ == STYLE_NORMAL | 997 int padding = style_ == STYLE_NORMAL |
| 998 ? arrow_pad * 2 | 998 ? arrow_pad * 2 |
| 999 : kActionLeftPadding + kActionRightPadding; | 999 : kActionLeftPadding + kActionRightPadding; |
| 1000 return ArrowSize().width() + padding; | 1000 return ArrowSize().width() + padding; |
| 1001 } | 1001 } |
| 1002 | 1002 |
| 1003 } // namespace views | 1003 } // namespace views |
| OLD | NEW |