diff options
author | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-29 18:44:51 +0000 |
---|---|---|
committer | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-29 18:44:51 +0000 |
commit | 8345371c9a46402eafccbacc6d9053447b217643 (patch) | |
tree | a7ede888d0f716cb0de003a2110682d8dde09e4f | |
parent | 6e8316ff095408c1537b6125e1a36c5c278e62aa (diff) | |
download | chromium_src-8345371c9a46402eafccbacc6d9053447b217643.zip chromium_src-8345371c9a46402eafccbacc6d9053447b217643.tar.gz chromium_src-8345371c9a46402eafccbacc6d9053447b217643.tar.bz2 |
Don't use NSEvent currentEvent for the event that starts the context menu, it may not be what we think it is.
BUG=23157
TEST=context menus in the web content area, esp rapid right-click and dragging.
Review URL: http://codereview.chromium.org/344024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30485 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/tab_contents/render_view_context_menu_mac.mm | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/chrome/browser/tab_contents/render_view_context_menu_mac.mm b/chrome/browser/tab_contents/render_view_context_menu_mac.mm index 3a1a9af..1d63454 100644 --- a/chrome/browser/tab_contents/render_view_context_menu_mac.mm +++ b/chrome/browser/tab_contents/render_view_context_menu_mac.mm @@ -59,9 +59,24 @@ RenderViewContextMenuMac::~RenderViewContextMenuMac() { } void RenderViewContextMenuMac::DoInit() { - // show the menu + // Synthesize an event for the click, as there is no certainty that + // [NSApp currentEvent] will return a valid event. + NSEvent* currentEvent = [NSApp currentEvent]; + NSWindow* window = [parent_view_ window]; + NSPoint position = [window mouseLocationOutsideOfEventStream]; + NSTimeInterval eventTime = [currentEvent timestamp]; + NSEvent* clickEvent = [NSEvent mouseEventWithType:NSRightMouseDown + location:position + modifierFlags:NSRightMouseDownMask + timestamp:eventTime + windowNumber:[window windowNumber] + context:nil + eventNumber:0 + clickCount:1 + pressure:1.0]; + // Show the menu. [NSMenu popUpContextMenu:menu_ - withEvent:[NSApp currentEvent] + withEvent:clickEvent forView:parent_view_]; } |