From 267a9cee32a87c9d6a489ffd02d77ec40d6d9d1b Mon Sep 17 00:00:00 2001 From: "sky@chromium.org" Date: Wed, 7 Jul 2010 15:47:38 +0000 Subject: Fixes menus when shown by way of pressing alt-f. I need to turn on nested tasks as in some situations the menu may be shown when the message loop is processing a task. If the message loop is processing a taskand we don't set nested tasks allowed to true then none of the tasks scheduled by the menu (paints, delays...) are processed and the menu appears totally broken. BUG=48102 TEST=give focus to the page, press alt-f, press arrow keys and make sure the menu updates appropriately. Review URL: http://codereview.chromium.org/2836044 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51719 0039d316-1c4b-4281-b951-d872f2087c98 --- views/controls/menu/menu_controller.cc | 16 ++++++++-------- views/controls/menu/menu_item_view.cc | 3 --- views/controls/menu/menu_item_view.h | 4 ---- 3 files changed, 8 insertions(+), 15 deletions(-) (limited to 'views/controls') diff --git a/views/controls/menu/menu_controller.cc b/views/controls/menu/menu_controller.cc index ae099f7..2c00e5e 100644 --- a/views/controls/menu/menu_controller.cc +++ b/views/controls/menu/menu_controller.cc @@ -268,15 +268,15 @@ MenuItemView* MenuController::Run(gfx::NativeWindow parent, if (ViewsDelegate::views_delegate) ViewsDelegate::views_delegate->AddRef(); + // We need to turn on nestable tasks as in some situations (pressing alt-f for + // one) the menus are run from a task. If we don't do this and are invoked + // from a task none of the tasks we schedule are processed and the menu + // appears totally broken. MessageLoopForUI* loop = MessageLoopForUI::current(); - if (MenuItemView::allow_task_nesting_during_run_) { - bool did_allow_task_nesting = loop->NestableTasksAllowed(); - loop->SetNestableTasksAllowed(true); - loop->Run(this); - loop->SetNestableTasksAllowed(did_allow_task_nesting); - } else { - loop->Run(this); - } + bool did_allow_task_nesting = loop->NestableTasksAllowed(); + loop->SetNestableTasksAllowed(true); + loop->Run(this); + loop->SetNestableTasksAllowed(did_allow_task_nesting); if (ViewsDelegate::views_delegate) ViewsDelegate::views_delegate->ReleaseRef(); diff --git a/views/controls/menu/menu_item_view.cc b/views/controls/menu/menu_item_view.cc index cb87761..1a5d8eb 100644 --- a/views/controls/menu/menu_item_view.cc +++ b/views/controls/menu/menu_item_view.cc @@ -57,9 +57,6 @@ const int MenuItemView::kEmptyMenuItemViewID = MenuItemView::kMenuItemViewID + 1; // static -bool MenuItemView::allow_task_nesting_during_run_ = false; - -// static int MenuItemView::label_start_; // static diff --git a/views/controls/menu/menu_item_view.h b/views/controls/menu/menu_item_view.h index 87ef1f6..baa3461 100644 --- a/views/controls/menu/menu_item_view.h +++ b/views/controls/menu/menu_item_view.h @@ -55,10 +55,6 @@ class MenuItemView : public View { // ID used to identify empty menu items. static const int kEmptyMenuItemViewID; - // If true SetNestableTasksAllowed(true) is invoked before MessageLoop::Run - // is invoked. This is only useful for testing and defaults to false. - static bool allow_task_nesting_during_run_; - // Different types of menu items. enum Type { NORMAL, -- cgit v1.1