diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-04 17:50:18 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-04 17:50:18 +0000 |
commit | 4c70b7a559f7188a2820b38e6dad2758a310b55c (patch) | |
tree | b8f4fa39b556a7f0335b8b46fd5909af3b891ac6 /chrome | |
parent | dd3423c1a6bf4e13da32694bb2e9ab2be43fd87d (diff) | |
download | chromium_src-4c70b7a559f7188a2820b38e6dad2758a310b55c.zip chromium_src-4c70b7a559f7188a2820b38e6dad2758a310b55c.tar.gz chromium_src-4c70b7a559f7188a2820b38e6dad2758a310b55c.tar.bz2 |
Lands the fix for bug 8088 from m0 (http://codereview.chromium.org/100022).
Here's his description:
Mouse hover out of context menu should un-select menu item.
All Context Menu's which are implemented with ChromeMenu is not properly
un-selecting the menu item when out of focus. The areas where this is affected
are: * Tabs * Bookmark bar * Bookmark managerThe others uses winapi for context
menus. Doesn't use ChromeMenu, uses HMENU, that explanes why the others work.
For this fix, I had to make sure that the MenuPart is always NONE when the mouse
is moved outside of the context menu regions, and that is always the case.
Hence, we can assure to remove selection. The same way it has been done for
SetSelection, I have used the same technique for this, but simpler.
BUG=8088
TEST=For the above mentioned affected areas, I brought up the context menu by
right clicking, and hovered over a menu item, then move the mouse horizontally
outside the context menu region, it deselected the item.
Review URL: http://codereview.chromium.org/102025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15220 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/views/controls/menu/chrome_menu.cc | 17 | ||||
-rw-r--r-- | chrome/views/controls/menu/chrome_menu.h | 4 |
2 files changed, 5 insertions, 16 deletions
diff --git a/chrome/views/controls/menu/chrome_menu.cc b/chrome/views/controls/menu/chrome_menu.cc index 64bee99..cb94de3 100644 --- a/chrome/views/controls/menu/chrome_menu.cc +++ b/chrome/views/controls/menu/chrome_menu.cc @@ -653,7 +653,7 @@ class MenuHostRootView : public RootView { class MenuHost : public WidgetWin { public: - MenuHost(SubmenuView* submenu) + explicit MenuHost(SubmenuView* submenu) : closed_(false), submenu_(submenu), owns_capture_(false) { @@ -774,7 +774,8 @@ class EmptyMenuMenuItem : public MenuItemView { // ID used for EmptyMenuMenuItem. static const int kEmptyMenuItemViewID; - EmptyMenuMenuItem(MenuItemView* parent) : MenuItemView(parent, 0, NORMAL) { + explicit EmptyMenuMenuItem(MenuItemView* parent) : + MenuItemView(parent, 0, NORMAL) { SetTitle(l10n_util::GetString(IDS_MENU_EMPTY_SUBMENU)); // Set this so that we're not identified as a normal menu item. SetID(kEmptyMenuItemViewID); @@ -1621,8 +1622,6 @@ MenuItemView* MenuController::Run(HWND parent, pending_state_.monitor_bounds = gfx::Rect(mi.rcMonitor); } - any_menu_contains_mouse_ = false; - // Set the selection, which opens the initial menu. SetSelection(root, true, true); @@ -1777,8 +1776,6 @@ void MenuController::OnMousePressed(SubmenuView* source, return; } - any_menu_contains_mouse_ = true; - bool open_submenu = false; if (!part.menu) { part.menu = source->GetMenuItem(); @@ -1854,7 +1851,6 @@ void MenuController::OnMouseDragged(SubmenuView* source, part.menu = source->GetMenuItem(); SetSelection(part.menu ? part.menu : state_.item, true, false); } - any_menu_contains_mouse_ = (part.type == MenuPart::MENU_ITEM); } void MenuController::OnMouseReleased(SubmenuView* source, @@ -1870,7 +1866,6 @@ void MenuController::OnMouseReleased(SubmenuView* source, DCHECK(blocking_run_); MenuPart part = GetMenuPartByScreenCoordinate(source, event.x(), event.y()); - any_menu_contains_mouse_ = (part.type == MenuPart::MENU_ITEM); if (event.IsRightMouseButton() && (part.type == MenuPart::MENU_ITEM && part.menu)) { // Set the selection immediately, making sure the submenu is only open @@ -1914,17 +1909,14 @@ void MenuController::OnMouseMoved(SubmenuView* source, if (!blocking_run_) return; - any_menu_contains_mouse_ = (part.type == MenuPart::MENU_ITEM); if (part.type == MenuPart::MENU_ITEM && part.menu) { SetSelection(part.menu, true, false); - } else if (!part.is_scroll() && any_menu_contains_mouse_ && - pending_state_.item && + } else if (!part.is_scroll() && pending_state_.item && (!pending_state_.item->HasSubmenu() || !pending_state_.item->GetSubmenu()->IsShowing())) { // On exit if the user hasn't selected an item with a submenu, move the // selection back to the parent menu item. SetSelection(pending_state_.item->GetParentMenuItem(), true, false); - any_menu_contains_mouse_ = false; } } @@ -2209,7 +2201,6 @@ MenuController::MenuController(bool blocking) owner_(NULL), possible_drag_(false), valid_drop_coordinates_(false), - any_menu_contains_mouse_(false), showing_submenu_(false), result_mouse_event_flags_(0) { #ifdef DEBUG_MENU diff --git a/chrome/views/controls/menu/chrome_menu.h b/chrome/views/controls/menu/chrome_menu.h index 8e55bc0..f8b5e17 100644 --- a/chrome/views/controls/menu/chrome_menu.h +++ b/chrome/views/controls/menu/chrome_menu.h @@ -6,6 +6,7 @@ #define CHROME_VIEWS_CONTROLS_MENU_CHROME_MENU_H_ #include <list> +#include <vector> #include "base/gfx/point.h" #include "base/gfx/rect.h" @@ -932,9 +933,6 @@ class MenuController : public MessageLoopForUI::Dispatcher { int drop_y_; int last_drop_operation_; - // If true, the mouse is over some menu. - bool any_menu_contains_mouse_; - // If true, we're in the middle of invoking ShowAt on a submenu. bool showing_submenu_; |