summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhajimehoshi@chromium.org <hajimehoshi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-28 02:24:01 +0000
committerhajimehoshi@chromium.org <hajimehoshi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-28 02:24:01 +0000
commitce7dca32b979cc172ac2e10bab49078bfc852b0b (patch)
tree923fc1d7bf3cce5612c9158437b3344c6faad961
parentc33efbcb3a2384f8264ced5c218e6e080da2a02f (diff)
downloadchromium_src-ce7dca32b979cc172ac2e10bab49078bfc852b0b.zip
chromium_src-ce7dca32b979cc172ac2e10bab49078bfc852b0b.tar.gz
chromium_src-ce7dca32b979cc172ac2e10bab49078bfc852b0b.tar.bz2
Merge 253531 "Combobox: Have the first item not rendered for an ..."
> Combobox: Have the first item not rendered for an action combobox > > This CL skips rendering the first item and separators on the dropdown > menu for an 'action' combobox. > > BUG=341994 > TEST=manual > > Review URL: https://codereview.chromium.org/178003009 TBR=hajimehoshi@chromium.org Review URL: https://codereview.chromium.org/183863006 git-svn-id: svn://svn.chromium.org/chrome/branches/1847/src@254025 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ui/views/controls/combobox/combobox.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/ui/views/controls/combobox/combobox.cc b/ui/views/controls/combobox/combobox.cc
index cb24b25..01e855d 100644
--- a/ui/views/controls/combobox/combobox.cc
+++ b/ui/views/controls/combobox/combobox.cc
@@ -586,9 +586,14 @@ void Combobox::UpdateFromModel() {
int num_items = model()->GetItemCount();
int width = 0;
+ bool text_item_appended = false;
for (int i = 0; i < num_items; ++i) {
+ // When STYLE_ACTION is used, the first item and the following separators
+ // are not added to the dropdown menu. It is assumed that the first item is
+ // always selected and rendered on the top of the action button.
if (model()->IsItemSeparatorAt(i)) {
- menu->AppendSeparator();
+ if (text_item_appended || style_ != STYLE_ACTION)
+ menu->AppendSeparator();
continue;
}
@@ -598,7 +603,10 @@ void Combobox::UpdateFromModel() {
// text is displayed correctly in right-to-left UIs.
base::i18n::AdjustStringForLocaleDirection(&text);
- menu->AppendMenuItem(i + kFirstMenuItemId, text, MenuItemView::NORMAL);
+ if (style_ != STYLE_ACTION || i > 0) {
+ menu->AppendMenuItem(i + kFirstMenuItemId, text, MenuItemView::NORMAL);
+ text_item_appended = true;
+ }
if (style_ != STYLE_ACTION || i == selected_index_)
width = std::max(width, gfx::GetStringWidth(text, font_list));