| 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 |
| (...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 950 if (arrow_button_) { | 950 if (arrow_button_) { |
| 951 original_state = arrow_button_->state(); | 951 original_state = arrow_button_->state(); |
| 952 arrow_button_->SetState(Button::STATE_PRESSED); | 952 arrow_button_->SetState(Button::STATE_PRESSED); |
| 953 } | 953 } |
| 954 MenuAnchorPosition anchor_position = | 954 MenuAnchorPosition anchor_position = |
| 955 style_ == STYLE_ACTION ? MENU_ANCHOR_TOPRIGHT : MENU_ANCHOR_TOPLEFT; | 955 style_ == STYLE_ACTION ? MENU_ANCHOR_TOPRIGHT : MENU_ANCHOR_TOPLEFT; |
| 956 | 956 |
| 957 // Allow |menu_runner_| to be set by the testing API, but if this method is | 957 // Allow |menu_runner_| to be set by the testing API, but if this method is |
| 958 // ever invoked recursively, ensure the old menu is closed. | 958 // ever invoked recursively, ensure the old menu is closed. |
| 959 if (!menu_runner_ || menu_runner_->IsRunning()) { | 959 if (!menu_runner_ || menu_runner_->IsRunning()) { |
| 960 menu_runner_.reset(new MenuRunner( | 960 menu_runner_.reset( |
| 961 menu_model_.get(), MenuRunner::COMBOBOX | MenuRunner::ASYNC, | 961 new MenuRunner(menu_model_.get(), MenuRunner::COMBOBOX, |
| 962 base::Bind(&Combobox::OnMenuClosed, base::Unretained(this), | 962 base::Bind(&Combobox::OnMenuClosed, |
| 963 original_state))); | 963 base::Unretained(this), original_state))); |
| 964 } | 964 } |
| 965 menu_runner_->RunMenuAt(GetWidget(), nullptr, bounds, anchor_position, | 965 menu_runner_->RunMenuAt(GetWidget(), nullptr, bounds, anchor_position, |
| 966 source_type); | 966 source_type); |
| 967 } | 967 } |
| 968 | 968 |
| 969 void Combobox::OnMenuClosed(Button::ButtonState original_button_state) { | 969 void Combobox::OnMenuClosed(Button::ButtonState original_button_state) { |
| 970 menu_runner_.reset(); | 970 menu_runner_.reset(); |
| 971 if (arrow_button_) | 971 if (arrow_button_) |
| 972 arrow_button_->SetState(original_button_state); | 972 arrow_button_->SetState(original_button_state); |
| 973 closed_time_ = base::Time::Now(); | 973 closed_time_ = base::Time::Now(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1016 const int kMdPaddingWidth = 8; | 1016 const int kMdPaddingWidth = 8; |
| 1017 int arrow_pad = UseMd() ? kMdPaddingWidth | 1017 int arrow_pad = UseMd() ? kMdPaddingWidth |
| 1018 : PlatformStyle::kComboboxNormalArrowPadding; | 1018 : PlatformStyle::kComboboxNormalArrowPadding; |
| 1019 int padding = style_ == STYLE_NORMAL | 1019 int padding = style_ == STYLE_NORMAL |
| 1020 ? arrow_pad * 2 | 1020 ? arrow_pad * 2 |
| 1021 : kActionLeftPadding + kActionRightPadding; | 1021 : kActionLeftPadding + kActionRightPadding; |
| 1022 return ArrowSize().width() + padding; | 1022 return ArrowSize().width() + padding; |
| 1023 } | 1023 } |
| 1024 | 1024 |
| 1025 } // namespace views | 1025 } // namespace views |
| OLD | NEW |