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

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: Implemented reviewer recommendations. 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
« no previous file with comments | « ui/base/models/menu_model.h ('k') | views/controls/menu/menu_item_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1d90c36358c7a74dc103277e9ccce7737e66f7ff 100644
--- a/ui/base/models/menu_model.cc
+++ b/ui/base/models/menu_model.cc
@@ -16,17 +16,19 @@ 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();
+ const int index_offset = (*model)->GetFirstItemIndex(NULL);
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 + index_offset;
+ 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;
}
}
« no previous file with comments | « ui/base/models/menu_model.h ('k') | views/controls/menu/menu_item_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698