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

Unified Diff: ui/views/controls/combobox/combobox.cc

Issue 2069733002: MD - Use real comboboxes in website settings popup. Hide borders (but (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comment Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/combobox/combobox.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/combobox/combobox.cc
diff --git a/ui/views/controls/combobox/combobox.cc b/ui/views/controls/combobox/combobox.cc
index 3d7cfd1e26585dae22ab9fd8f8cfe5d876987304..e888c4dec065a6c8f19bea2bccc082686a25feda 100644
--- a/ui/views/controls/combobox/combobox.cc
+++ b/ui/views/controls/combobox/combobox.cc
@@ -366,6 +366,7 @@ Combobox::Combobox(ui::ComboboxModel* model, Style style)
menu_model_adapter_(new ComboboxMenuModelAdapter(this, model)),
text_button_(new TransparentButton(this)),
arrow_button_(new TransparentButton(this)),
+ size_to_largest_label_(style_ == STYLE_NORMAL),
weak_ptr_factory_(this) {
ModelChanged();
#if defined(OS_MACOSX)
@@ -438,7 +439,12 @@ void Combobox::SetSelectedIndex(int index) {
return;
selected_index_ = index;
- SchedulePaint();
+ if (size_to_largest_label_) {
+ SchedulePaint();
+ } else {
+ content_size_ = GetContentSize();
+ PreferredSizeChanged();
+ }
}
bool Combobox::SelectValue(const base::string16& value) {
@@ -878,7 +884,7 @@ gfx::Size Combobox::GetContentSize() const {
if (model_->IsItemSeparatorAt(i))
continue;
- if (style_ != STYLE_ACTION || i == selected_index_) {
+ if (size_to_largest_label_ || i == selected_index_) {
width = std::max(
width,
gfx::GetStringWidth(menu_model_adapter_->GetLabelAt(i), font_list));
« no previous file with comments | « ui/views/controls/combobox/combobox.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698