diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-12 16:18:07 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-12 16:18:07 +0000 |
commit | c9fe2440f7cf280fc7a2ebd0b91acebb096bc4ab (patch) | |
tree | 42a57f5d33ae3cb4bc951e11a782f24670d88b0e /chrome/browser/tab_contents | |
parent | 02fb75abae043fc1d6c14bebedeb6598dd955ef5 (diff) | |
download | chromium_src-c9fe2440f7cf280fc7a2ebd0b91acebb096bc4ab.zip chromium_src-c9fe2440f7cf280fc7a2ebd0b91acebb096bc4ab.tar.gz chromium_src-c9fe2440f7cf280fc7a2ebd0b91acebb096bc4ab.tar.bz2 |
Send key equivalents to renderer first.
Based on a patch by avi@.
See also http://codereview.chromium.org/271054 .
Known issues:
* Breaks if any menu item ever uses a keyboard accelerator that doesn't use cmd as part of the flags.
(* Suppressing keypress() doesn't prevent default action (suppressing keydown() works though. Both Firefox and Safari prevent the default action when either is suppressed). This seems to be broken on linux and windows too, though – it seems to match IE8, but not Firefox or Safari. I guess this is the question for the web council.)
BUG=15090
TEST=Cmd-f now sucks when used on google docs.
Review URL: http://codereview.chromium.org/242069
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28709 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r-- | chrome/browser/tab_contents/tab_contents_view_mac.mm | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/chrome/browser/tab_contents/tab_contents_view_mac.mm b/chrome/browser/tab_contents/tab_contents_view_mac.mm index 03baffc..61195b1 100644 --- a/chrome/browser/tab_contents/tab_contents_view_mac.mm +++ b/chrome/browser/tab_contents/tab_contents_view_mac.mm @@ -43,7 +43,7 @@ COMPILE_ASSERT_MATCHING_ENUM(DragOperationEvery); @interface TabContentsViewCocoa (Private) - (id)initWithTabContentsViewMac:(TabContentsViewMac*)w; -- (void)processKeyboardEvent:(NSEvent*)event; +- (void)processKeyboardEvent:(NativeWebKeyboardEvent*)event; - (void)registerDragTypes; - (void)setCurrentDragOperation:(NSDragOperation)operation; - (void)startDragWithDropData:(const WebDropData&)dropData @@ -202,7 +202,8 @@ void TabContentsViewMac::TakeFocus(bool reverse) { void TabContentsViewMac::HandleKeyboardEvent( const NativeWebKeyboardEvent& event) { - [cocoa_view_.get() processKeyboardEvent:event.os_event]; + [cocoa_view_.get() processKeyboardEvent: + const_cast<NativeWebKeyboardEvent*>(&event)]; } void TabContentsViewMac::ShowContextMenu(const ContextMenuParams& params) { @@ -293,7 +294,15 @@ void TabContentsViewMac::Observe(NotificationType type, return tabContentsView_->tab_contents(); } -- (void)processKeyboardEvent:(NSEvent*)event { +- (void)processKeyboardEvent:(NativeWebKeyboardEvent*)wkEvent { + NSEvent* event = wkEvent->os_event; + + if ([event type] == NSKeyDown && ([event modifierFlags] & NSCommandKeyMask)) { + // We need to dispatch this to the menu. + if ([[NSApp mainMenu] performKeyEquivalent:event]) + return; + } + // If this tab is no longer active, it's window will be |nil|. In that case, // best ignore the event. if (![self window]) |