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

Unified Diff: ui/base/models/menu_model.cc

Issue 7067032: Add MenuModelAdapter to wrap ui::MenuModel with views::MenuDelegate interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Restore NOTREACHED() in IsCommandEnabled(). 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: ui/base/models/menu_model.cc
diff --git a/ui/base/models/menu_model.cc b/ui/base/models/menu_model.cc
index c7defd9062746ae1c3f0cd7ebb2ac4ec05f1400d..8c76944768283b3582984b879b2c81ac0101e80c 100644
--- a/ui/base/models/menu_model.cc
+++ b/ui/base/models/menu_model.cc
@@ -16,17 +16,18 @@ bool MenuModel::IsVisibleAt(int index) const {
bool MenuModel::GetModelAndIndexForCommandId(int command_id,
MenuModel** model, int* index) {
- int item_count = (*model)->GetItemCount();
+ const int item_count = (*model)->GetItemCount();
for (int i = 0; i < item_count; ++i) {
- if ((*model)->GetTypeAt(i) == TYPE_SUBMENU) {
- MenuModel* submenu_model = (*model)->GetSubmenuModelAt(i);
+ const int candidate_index = i + (*model)->GetFirstItemIndex(NULL);
sky 2011/05/25 15:41:12 Move this call outside the loop.
rhashimoto 2011/05/25 16:24:37 Done.
+ if ((*model)->GetTypeAt(candidate_index) == TYPE_SUBMENU) {
+ MenuModel* submenu_model = (*model)->GetSubmenuModelAt(candidate_index);
if (GetModelAndIndexForCommandId(command_id, &submenu_model, index)) {
*model = submenu_model;
return true;
}
}
- if ((*model)->GetCommandIdAt(i) == command_id) {
- *index = i;
+ if ((*model)->GetCommandIdAt(candidate_index) == command_id) {
+ *index = candidate_index;
return true;
}
}

Powered by Google App Engine
This is Rietveld 408576698