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

Issue 1310903004: Use a ui::MenuModel in views::Combobox (Closed)

Created:
5 years, 3 months ago by tapted
Modified:
5 years, 3 months ago
Reviewers:
sky
CC:
chromium-reviews, tfarina, chrome-apps-syd-reviews_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Use a ui::MenuModel in views::Combobox views::Combobox currently does its own menu-building rather than using a ui::MenuModel. However, the only thing missing from MenuModel is the ability to set a minimum menu width. (Combobox currently does this by adding an invisible SubmenuView with a given width.) Moving the menu building out of Combobox allows Mac to build a native menu instead, which gives a much nicer menu experience there. In particular, Comboboxes on Mac center the menu over the button vertically, and have fancy scrolling/repositioning mechanisms when the menu is shown near the edge of the screen. This CL adds an Adapter class that adapts a ui::ComboboxModel to the ui::MenuModel interface, allowing views:Comboxbox to be simplified elsewhere. MenuRunnerImplCocoa will be extended to support comboboxes in a follow-up. For the minimum width, MenuController::CalculateMenuBounds() can just use the width of the anchor rectangle for the same effect. Note that TranslateBubbleView is the only user of Combobox::STYLE_ACTION. TranslateBubbleView puts a separator after the first item which Combobox always removes. MenuModel::IsVisibleAt() isn't checked for separators, so simply don't add the separator to keep things simple. BUG=522365 Committed: https://crrev.com/e989104781ae77c9bdb31d24b96830bf27a2c717 Cr-Commit-Position: refs/heads/master@{#347867}

Patch Set 1 #

Patch Set 2 : more obsolete code #

Patch Set 3 : It works! \o/ Just .. offset is wrong #

Patch Set 4 : Update tests. To fix: ComboboxTest.ContentWidth #

Patch Set 5 : Audit headers #

Patch Set 6 : Fix test / extend coverage. Vertical whitespace. #

Patch Set 7 : Fonts are slow: keep the content_size cache #

Patch Set 8 : Clearer IsVisibleAt #

Patch Set 9 : Fix the translate bubble #

Patch Set 10 : Split out Cocoa changes to http://crrev.com/1321023005 #

Total comments: 13

Patch Set 11 : respond to comments #

Patch Set 12 : Maintain the current selection #

Total comments: 2

Patch Set 13 : +curlies #

Unified diffs Side-by-side diffs Delta from patch set Stats (+338 lines, -187 lines) Patch
M chrome/browser/ui/views/translate/translate_bubble_view.cc View 1 2 3 4 5 6 7 8 1 chunk +0 lines, -1 line 0 comments Download
M ui/views/controls/combobox/combobox.h View 1 2 3 4 5 6 7 8 9 10 8 chunks +20 lines, -44 lines 0 comments Download
M ui/views/controls/combobox/combobox.cc View 1 2 3 4 5 6 7 8 9 10 11 12 15 chunks +156 lines, -102 lines 0 comments Download
M ui/views/controls/combobox/combobox_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 18 chunks +153 lines, -40 lines 0 comments Download
M ui/views/controls/menu/menu_config.h View 1 2 3 4 5 1 chunk +3 lines, -0 lines 0 comments Download
M ui/views/controls/menu/menu_config.cc View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
M ui/views/controls/menu/menu_config_mac.mm View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
M ui/views/controls/menu/menu_controller.cc View 1 2 3 4 5 1 chunk +4 lines, -0 lines 0 comments Download

Messages

Total messages: 13 (3 generated)
tapted
Hi sky, please take a look. Let me know what you think. There's a strong ...
5 years, 3 months ago (2015-09-03 12:52:27 UTC) #2
sky
https://codereview.chromium.org/1310903004/diff/180001/ui/views/controls/combobox/combobox.cc File ui/views/controls/combobox/combobox.cc (right): https://codereview.chromium.org/1310903004/diff/180001/ui/views/controls/combobox/combobox.cc#newcode236 ui/views/controls/combobox/combobox.cc:236: const int num_items = GetItemCount(); move into for loop. ...
5 years, 3 months ago (2015-09-03 17:52:27 UTC) #3
tapted
https://codereview.chromium.org/1310903004/diff/180001/ui/views/controls/combobox/combobox.cc File ui/views/controls/combobox/combobox.cc (right): https://codereview.chromium.org/1310903004/diff/180001/ui/views/controls/combobox/combobox.cc#newcode236 ui/views/controls/combobox/combobox.cc:236: const int num_items = GetItemCount(); On 2015/09/03 17:52:27, sky ...
5 years, 3 months ago (2015-09-04 00:46:55 UTC) #4
sky
https://codereview.chromium.org/1310903004/diff/180001/ui/views/controls/combobox/combobox.cc File ui/views/controls/combobox/combobox.cc (right): https://codereview.chromium.org/1310903004/diff/180001/ui/views/controls/combobox/combobox.cc#newcode422 ui/views/controls/combobox/combobox.cc:422: selected_index_ = std::min(model_->GetDefaultIndex(), model_->GetItemCount()); On 2015/09/04 00:46:54, tapted wrote: ...
5 years, 3 months ago (2015-09-04 14:34:17 UTC) #5
tapted
https://codereview.chromium.org/1310903004/diff/180001/ui/views/controls/combobox/combobox.cc File ui/views/controls/combobox/combobox.cc (right): https://codereview.chromium.org/1310903004/diff/180001/ui/views/controls/combobox/combobox.cc#newcode422 ui/views/controls/combobox/combobox.cc:422: selected_index_ = std::min(model_->GetDefaultIndex(), model_->GetItemCount()); On 2015/09/04 14:34:17, sky wrote: ...
5 years, 3 months ago (2015-09-07 00:37:27 UTC) #6
sky
LGTM https://codereview.chromium.org/1310903004/diff/200002/ui/views/controls/combobox/combobox.cc File ui/views/controls/combobox/combobox.cc (right): https://codereview.chromium.org/1310903004/diff/200002/ui/views/controls/combobox/combobox.cc#newcode409 ui/views/controls/combobox/combobox.cc:409: selected_index_ = model_->GetDefaultIndex(); nit: {}
5 years, 3 months ago (2015-09-08 16:23:12 UTC) #7
tapted
https://codereview.chromium.org/1310903004/diff/200002/ui/views/controls/combobox/combobox.cc File ui/views/controls/combobox/combobox.cc (right): https://codereview.chromium.org/1310903004/diff/200002/ui/views/controls/combobox/combobox.cc#newcode409 ui/views/controls/combobox/combobox.cc:409: selected_index_ = model_->GetDefaultIndex(); On 2015/09/08 16:23:12, sky wrote: > ...
5 years, 3 months ago (2015-09-09 00:30:58 UTC) #8
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1310903004/230001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1310903004/230001
5 years, 3 months ago (2015-09-09 00:31:57 UTC) #11
commit-bot: I haz the power
Committed patchset #13 (id:230001)
5 years, 3 months ago (2015-09-09 09:05:07 UTC) #12
commit-bot: I haz the power
5 years, 3 months ago (2015-09-09 09:06:15 UTC) #13
Message was sent while issue was closed.
Patchset 13 (id:??) landed as
https://crrev.com/e989104781ae77c9bdb31d24b96830bf27a2c717
Cr-Commit-Position: refs/heads/master@{#347867}

Powered by Google App Engine
This is Rietveld 408576698