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

Unified Diff: views/controls/menu/menu_controller.cc

Issue 6931039: Add MenuItemView API to add and remove items at a particular index. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to trunk. Created 9 years, 7 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
Index: views/controls/menu/menu_controller.cc
diff --git a/views/controls/menu/menu_controller.cc b/views/controls/menu/menu_controller.cc
index 1af598fe0c22da3941cd7acfd42d184078e3cc57..16f3690a8f676745217f38a1c53a5ccab6b69478 100644
--- a/views/controls/menu/menu_controller.cc
+++ b/views/controls/menu/menu_controller.cc
@@ -1344,16 +1344,15 @@ void MenuController::MenuChildrenChanged(MenuItemView* item) {
DCHECK(item);
DCHECK(item->GetSubmenu()->IsShowing());
- // Currently this only supports adjusting the bounds of the last menu.
- DCHECK(item == state_.item->GetParentMenuItem());
-
- // Make sure the submenu isn't showing for the current item (the position may
- // have changed or the menu removed). This also moves the selection back to
- // the parent, which handles the case where the selected item was removed.
- SetSelection(state_.item->GetParentMenuItem(),
- SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY);
-
- OpenMenuImpl(item, false);
+ // If the current item is a descendant of the item that changed,
+ // move the selection back to the changed item.
+ const MenuItemView* ancestor = state_.item;
sky 2011/05/11 14:26:10 You should update if either state_.item or pending
rhashimoto 2011/05/11 19:41:07 Done.
+ while (ancestor && ancestor != item)
+ ancestor = ancestor->GetParentMenuItem();
+ if (ancestor) {
+ SetSelection(item, SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY);
+ OpenMenuImpl(item, false);
sky 2011/05/11 14:26:10 You should only invoke OpenMenuItem if item has a
rhashimoto 2011/05/11 19:41:07 Done, though I think we only get here if the item
+ }
}
void MenuController::BuildPathsAndCalculateDiff(

Powered by Google App Engine
This is Rietveld 408576698