Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5821)

Unified Diff: chrome/browser/renderer_host/render_widget_host_view_mac.mm

Issue 300002: Short-circuit events rwhvmac if it's focussed. (Closed)
Patch Set: refine Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/renderer_host/render_widget_host_view_mac.mm
diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
index f19243bd3c1fd7f2128b34f714c5d12a25953ec8..7709790ee5aae8732aaa07e2ba863d258f52aae3 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
@@ -29,7 +29,6 @@ using WebKit::WebMouseWheelEvent;
@interface RenderWidgetHostViewCocoa (Private)
+ (BOOL)shouldAutohideCursorForEvent:(NSEvent*)event;
- (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r;
-- (void)keyEvent:(NSEvent *)theEvent wasKeyEquivalent:(BOOL)equiv;
- (void)cancelChildPopups;
@end
@@ -538,40 +537,13 @@ void RenderWidgetHostViewMac::SetBackground(const SkBitmap& background) {
}
- (BOOL)performKeyEquivalent:(NSEvent*)theEvent {
- // |performKeyEquivalent:| is sent to the whole view tree, not only down the
- // responder chain. We only want to handle key equivalents if we're first
- // responder.
- if ([[self window] firstResponder] != self)
- return NO;
-
- // If we return |NO| from this function, cocoa will send the key event to
- // the menu and only if the menu does not process the event to |keyDown:|. We
- // want to send the event to a renderer _before_ sending it to the menu, so
- // we need to return |YES| for all events that might be swallowed by the menu.
- // We do not return |YES| for every keypress because we don't get |keyDown:|
- // events for keys that we handle this way.
- NSUInteger modifierFlags = [theEvent modifierFlags];
- if ((modifierFlags & NSCommandKeyMask) == 0) {
- // Make sure the menu does not contain key equivalents that don't
- // contain cmd.
- DCHECK(![[NSApp mainMenu] performKeyEquivalent:theEvent]);
- return NO;
- }
-
- // Command key combinations are sent via performKeyEquivalent rather than
- // keyDown:. We just forward this on and if WebCore doesn't want to handle
- // it, we let the TabContentsView figure out how to reinject it.
- [self keyEvent:theEvent wasKeyEquivalent:YES];
- return YES;
+ // We have some magic in |CrApplication sendEvent:| that always sends key
+ // events to |keyEvent:| so that cocoa doesn't have a chance to intercept it.
+ DCHECK([[self window] firstResponder] != self);
+ return NO;
}
- (void)keyEvent:(NSEvent*)theEvent {
- [self keyEvent:theEvent wasKeyEquivalent:NO];
-}
-
-- (void)keyEvent:(NSEvent *)theEvent wasKeyEquivalent:(BOOL)equiv {
- DCHECK([theEvent type] != NSKeyDown ||
- !equiv == !([theEvent modifierFlags] & NSCommandKeyMask));
// TODO(avi): Possibly kill self? See RenderWidgetHostViewWin::OnKeyEvent and
// http://b/issue?id=1192881 .

Powered by Google App Engine
This is Rietveld 408576698