Chromium Code Reviews| 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_action_data.h" | |
| 14 #include "ui/accessibility/ax_node_data.h" | 15 #include "ui/accessibility/ax_node_data.h" |
| 15 #include "ui/base/default_style.h" | 16 #include "ui/base/default_style.h" |
| 16 #include "ui/base/ime/input_method.h" | 17 #include "ui/base/ime/input_method.h" |
| 17 #include "ui/base/material_design/material_design_controller.h" | 18 #include "ui/base/material_design/material_design_controller.h" |
| 18 #include "ui/base/models/combobox_model_observer.h" | 19 #include "ui/base/models/combobox_model_observer.h" |
| 19 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
| 20 #include "ui/events/event.h" | 21 #include "ui/events/event.h" |
| 21 #include "ui/gfx/animation/throb_animation.h" | 22 #include "ui/gfx/animation/throb_animation.h" |
| 22 #include "ui/gfx/canvas.h" | 23 #include "ui/gfx/canvas.h" |
| 23 #include "ui/gfx/color_palette.h" | 24 #include "ui/gfx/color_palette.h" |
| (...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 759 node_data->SetName(accessible_name_); | 760 node_data->SetName(accessible_name_); |
| 760 node_data->SetValue(model_->GetItemAt(selected_index_)); | 761 node_data->SetValue(model_->GetItemAt(selected_index_)); |
| 761 if (enabled()) { | 762 if (enabled()) { |
| 762 node_data->AddIntAttribute(ui::AX_ATTR_DEFAULT_ACTION_VERB, | 763 node_data->AddIntAttribute(ui::AX_ATTR_DEFAULT_ACTION_VERB, |
| 763 ui::AX_DEFAULT_ACTION_VERB_OPEN); | 764 ui::AX_DEFAULT_ACTION_VERB_OPEN); |
| 764 } | 765 } |
| 765 node_data->AddIntAttribute(ui::AX_ATTR_POS_IN_SET, selected_index_); | 766 node_data->AddIntAttribute(ui::AX_ATTR_POS_IN_SET, selected_index_); |
| 766 node_data->AddIntAttribute(ui::AX_ATTR_SET_SIZE, model_->GetItemCount()); | 767 node_data->AddIntAttribute(ui::AX_ATTR_SET_SIZE, model_->GetItemCount()); |
| 767 } | 768 } |
| 768 | 769 |
| 770 bool Combobox::HandleAccessibleAction(const ui::AXActionData& action_data) { | |
| 771 // The action handling in View would generate a mouse event, but mouse events | |
| 772 // for Combobox are handled by |arrow_button_|. Handle the action explicitly. | |
|
msw
2017/06/29 19:26:12
nit: It's not clear from this comment why allowing
tapted
2017/06/30 06:04:47
The problem is that |arrow_button_| isn't exposed
| |
| 773 if (enabled() && action_data.action == ui::AX_ACTION_DO_DEFAULT) { | |
|
msw
2017/06/29 19:26:12
Do we need some logic for handling the event when
tapted
2017/06/30 06:04:47
I don't think so. I am not a VoiceOver expert but
| |
| 774 ShowDropDownMenu(ui::MENU_SOURCE_KEYBOARD); | |
| 775 return true; | |
| 776 } | |
| 777 return View::HandleAccessibleAction(action_data); | |
| 778 } | |
| 779 | |
| 769 void Combobox::ButtonPressed(Button* sender, const ui::Event& event) { | 780 void Combobox::ButtonPressed(Button* sender, const ui::Event& event) { |
| 770 if (!enabled()) | 781 if (!enabled()) |
| 771 return; | 782 return; |
| 772 | 783 |
| 773 if (!UseMd()) | 784 if (!UseMd()) |
| 774 RequestFocus(); | 785 RequestFocus(); |
| 775 | 786 |
| 776 if (sender == text_button_) { | 787 if (sender == text_button_) { |
| 777 OnPerformAction(); | 788 OnPerformAction(); |
| 778 } else { | 789 } else { |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1014 constexpr int kMdPaddingWidth = 8; | 1025 constexpr int kMdPaddingWidth = 8; |
| 1015 constexpr int kNormalPaddingWidth = 7; | 1026 constexpr int kNormalPaddingWidth = 7; |
| 1016 int arrow_pad = UseMd() ? kMdPaddingWidth : kNormalPaddingWidth; | 1027 int arrow_pad = UseMd() ? kMdPaddingWidth : kNormalPaddingWidth; |
| 1017 int padding = style_ == STYLE_NORMAL | 1028 int padding = style_ == STYLE_NORMAL |
| 1018 ? arrow_pad * 2 | 1029 ? arrow_pad * 2 |
| 1019 : kActionLeftPadding + kActionRightPadding; | 1030 : kActionLeftPadding + kActionRightPadding; |
| 1020 return ArrowSize().width() + padding; | 1031 return ArrowSize().width() + padding; |
| 1021 } | 1032 } |
| 1022 | 1033 |
| 1023 } // namespace views | 1034 } // namespace views |
| OLD | NEW |