diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-10 21:54:49 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-10 21:54:49 +0000 |
commit | c08494af57caf5666d7f721ddf5f0b96d68cb460 (patch) | |
tree | 4dd0e60ab91f143eac507c25e8ccc4f6b7fbfda2 /views/controls | |
parent | d0c3529bddf7ec5724f232ea6b258f4d74604338 (diff) | |
download | chromium_src-c08494af57caf5666d7f721ddf5f0b96d68cb460.zip chromium_src-c08494af57caf5666d7f721ddf5f0b96d68cb460.tar.gz chromium_src-c08494af57caf5666d7f721ddf5f0b96d68cb460.tar.bz2 |
Fixes possible crash in showing bookmark menu. The problem occurred
when you clicked on one top level menu on the bookmark bar, moused
over another menu and then we loaded favicons for the first menu. The
code needs to figure out which menu has the icon instead of invoking
set icon on menu_.
BUG=27067
TEST=make sure bookmark menus work ok.
Review URL: http://codereview.chromium.org/388007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31603 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls')
-rw-r--r-- | views/controls/menu/menu_item_view.cc | 36 | ||||
-rw-r--r-- | views/controls/menu/menu_item_view.h | 6 |
2 files changed, 21 insertions, 21 deletions
diff --git a/views/controls/menu/menu_item_view.cc b/views/controls/menu/menu_item_view.cc index 2734788..5e92186 100644 --- a/views/controls/menu/menu_item_view.cc +++ b/views/controls/menu/menu_item_view.cc @@ -165,7 +165,7 @@ void MenuItemView::SetSelected(bool selected) { } void MenuItemView::SetIcon(const SkBitmap& icon, int item_id) { - MenuItemView* item = GetDescendantByID(item_id); + MenuItemView* item = GetMenuItemByID(item_id); DCHECK(item); item->SetIcon(icon); } @@ -216,6 +216,23 @@ wchar_t MenuItemView::GetMnemonic() { return 0; } +MenuItemView* MenuItemView::GetMenuItemByID(int id) { + if (GetCommand() == id) + return this; + if (!HasSubmenu()) + return NULL; + for (int i = 0; i < GetSubmenu()->GetChildViewCount(); ++i) { + View* child = GetSubmenu()->GetChildViewAt(i); + if (child->GetID() == MenuItemView::kMenuItemViewID) { + MenuItemView* result = static_cast<MenuItemView*>(child)-> + GetMenuItemByID(id); + if (result) + return result; + } + } + return NULL; +} + MenuItemView::MenuItemView(MenuItemView* parent, int command, MenuItemView::Type type) { @@ -291,23 +308,6 @@ MenuItemView* MenuItemView::AppendMenuItemInternal(int item_id, return item; } -MenuItemView* MenuItemView::GetDescendantByID(int id) { - if (GetCommand() == id) - return this; - if (!HasSubmenu()) - return NULL; - for (int i = 0; i < GetSubmenu()->GetChildViewCount(); ++i) { - View* child = GetSubmenu()->GetChildViewAt(i); - if (child->GetID() == MenuItemView::kMenuItemViewID) { - MenuItemView* result = static_cast<MenuItemView*>(child)-> - GetDescendantByID(id); - if (result) - return result; - } - } - return NULL; -} - void MenuItemView::DropMenuClosed(bool notify_delegate) { DCHECK(controller_); DCHECK(!controller_->IsBlockingRun()); diff --git a/views/controls/menu/menu_item_view.h b/views/controls/menu/menu_item_view.h index a85e265..c528671 100644 --- a/views/controls/menu/menu_item_view.h +++ b/views/controls/menu/menu_item_view.h @@ -218,6 +218,9 @@ class MenuItemView : public View { has_icons_ = has_icons; } + // Returns the descendant with the specified command. + MenuItemView* GetMenuItemByID(int id); + protected: // Creates a MenuItemView. This is used by the various AddXXX methods. MenuItemView(MenuItemView* parent, int command, Type type); @@ -240,9 +243,6 @@ class MenuItemView : public View { const SkBitmap& icon, Type type); - // Returns the descendant with the specified command. - MenuItemView* GetDescendantByID(int id); - // Invoked by the MenuController when the menu closes as the result of // drag and drop run. void DropMenuClosed(bool notify_delegate); |