summaryrefslogtreecommitdiffstats
path: root/ui/base/models
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-18 21:42:17 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-18 21:42:17 +0000
commit817fa8377dc8716f96fd85420fbbad1abfdfce74 (patch)
tree2ebc81b18d6987a4295321ace1326167112e59c4 /ui/base/models
parentad9192b97f0870ce55428fa0b0017f3e67ed73d0 (diff)
downloadchromium_src-817fa8377dc8716f96fd85420fbbad1abfdfce74.zip
chromium_src-817fa8377dc8716f96fd85420fbbad1abfdfce74.tar.gz
chromium_src-817fa8377dc8716f96fd85420fbbad1abfdfce74.tar.bz2
Nukes MenuModel::GetFirstItemIndex. It is only needed for windows, so
I pushed the code there. Additionally the places that tested this or tried to implement it did so incorrectly. BUG=none TEST=none R=ben@chromium.org Review URL: https://chromiumcodereview.appspot.com/12025003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177763 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base/models')
-rw-r--r--ui/base/models/menu_model.cc11
-rw-r--r--ui/base/models/menu_model.h13
2 files changed, 6 insertions, 18 deletions
diff --git a/ui/base/models/menu_model.cc b/ui/base/models/menu_model.cc
index 59bce28..1a3190d 100644
--- a/ui/base/models/menu_model.cc
+++ b/ui/base/models/menu_model.cc
@@ -6,20 +6,17 @@
namespace ui {
-int MenuModel::GetFirstItemIndex(gfx::NativeMenu native_menu) const {
- return 0;
-}
-
bool MenuModel::IsVisibleAt(int index) const {
return true;
}
+// static
bool MenuModel::GetModelAndIndexForCommandId(int command_id,
- MenuModel** model, int* index) {
+ MenuModel** model,
+ int* index) {
const int item_count = (*model)->GetItemCount();
- const int index_offset = (*model)->GetFirstItemIndex(NULL);
for (int i = 0; i < item_count; ++i) {
- const int candidate_index = i + index_offset;
+ const int candidate_index = i;
if ((*model)->GetTypeAt(candidate_index) == TYPE_SUBMENU) {
MenuModel* submenu_model = (*model)->GetSubmenuModelAt(candidate_index);
if (GetModelAndIndexForCommandId(command_id, &submenu_model, index)) {
diff --git a/ui/base/models/menu_model.h b/ui/base/models/menu_model.h
index 8b42f60..095dde5 100644
--- a/ui/base/models/menu_model.h
+++ b/ui/base/models/menu_model.h
@@ -43,16 +43,6 @@ class UI_EXPORT MenuModel {
// triggering a custom rendering mode.
virtual bool HasIcons() const = 0;
- // Returns the index of the first item. This is 0 for most menus except the
- // system menu on Windows. |native_menu| is the menu to locate the start index
- // within. It is guaranteed to be reset to a clean default state. Some
- // callers of this method may pass NULL for native_menu.
- // IMPORTANT: If the model implementation returns something _other_ than 0
- // here, it must offset the values for |index| it passes to the
- // methods below by this number - this is NOT done automatically!
- // TODO(sky): remove this from MenuModel. It's confusing.
- virtual int GetFirstItemIndex(gfx::NativeMenu native_menu) const;
-
// Returns the number of items in the menu.
virtual int GetItemCount() const = 0;
@@ -133,7 +123,8 @@ class UI_EXPORT MenuModel {
// Retrieves the model and index that contains a specific command id. Returns
// true if an item with the specified command id is found. |model| is inout,
// and specifies the model to start searching from.
- static bool GetModelAndIndexForCommandId(int command_id, MenuModel** model,
+ static bool GetModelAndIndexForCommandId(int command_id,
+ MenuModel** model,
int* index);
};