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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 2834763002: Mac: Never dispatch keyEquivalents to the web contents if the window is not Key. (Closed)
Patch Set: Add a bespoke test Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/renderer_host/render_widget_host_view_mac_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/render_widget_host_view_mac.h" 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h"
6 6
7 #import <Carbon/Carbon.h> 7 #import <Carbon/Carbon.h>
8 #import <objc/runtime.h> 8 #import <objc/runtime.h>
9 #include <OpenGL/gl.h> 9 #include <OpenGL/gl.h>
10 #include <QuartzCore/QuartzCore.h> 10 #include <QuartzCore/QuartzCore.h>
(...skipping 1999 matching lines...) Expand 10 before | Expand all | Expand 10 after
2010 pointerType_ = deviceType == NSEraserPointingDevice 2010 pointerType_ = deviceType == NSEraserPointingDevice
2011 ? blink::WebPointerProperties::PointerType::kEraser 2011 ? blink::WebPointerProperties::PointerType::kEraser
2012 : blink::WebPointerProperties::PointerType::kPen; 2012 : blink::WebPointerProperties::PointerType::kPen;
2013 } 2013 }
2014 } 2014 }
2015 2015
2016 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent { 2016 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent {
2017 // |performKeyEquivalent:| is sent to all views of a window, not only down the 2017 // |performKeyEquivalent:| is sent to all views of a window, not only down the
2018 // responder chain (cf. "Handling Key Equivalents" in 2018 // responder chain (cf. "Handling Key Equivalents" in
2019 // http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Event Overview/HandlingKeyEvents/HandlingKeyEvents.html 2019 // http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Event Overview/HandlingKeyEvents/HandlingKeyEvents.html
2020 // ). We only want to handle key equivalents if we're first responder. 2020 // ). A |performKeyEquivalent:| may also bubble up from a dialog child window
2021 if ([[self window] firstResponder] != self) 2021 // to perform browser commands such as switching tabs. We only want to handle
2022 // key equivalents if we're first responder in the keyWindow.
2023 if (![[self window] isKeyWindow] || [[self window] firstResponder] != self)
2022 return NO; 2024 return NO;
2023 2025
2024 // If the event is reserved by the system, then do not pass it to web content. 2026 // If the event is reserved by the system, then do not pass it to web content.
2025 if (EventIsReservedBySystem(theEvent)) 2027 if (EventIsReservedBySystem(theEvent))
2026 return NO; 2028 return NO;
2027 2029
2028 // If we return |NO| from this function, cocoa will send the key event to 2030 // If we return |NO| from this function, cocoa will send the key event to
2029 // the menu and only if the menu does not process the event to |keyDown:|. We 2031 // the menu and only if the menu does not process the event to |keyDown:|. We
2030 // want to send the event to a renderer _before_ sending it to the menu, so 2032 // want to send the event to a renderer _before_ sending it to the menu, so
2031 // we need to return |YES| for all events that might be swallowed by the menu. 2033 // we need to return |YES| for all events that might be swallowed by the menu.
(...skipping 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after
3514 3516
3515 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3517 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3516 // regions that are not draggable. (See ControlRegionView in 3518 // regions that are not draggable. (See ControlRegionView in
3517 // native_app_window_cocoa.mm). This requires the render host view to be 3519 // native_app_window_cocoa.mm). This requires the render host view to be
3518 // draggable by default. 3520 // draggable by default.
3519 - (BOOL)mouseDownCanMoveWindow { 3521 - (BOOL)mouseDownCanMoveWindow {
3520 return YES; 3522 return YES;
3521 } 3523 }
3522 3524
3523 @end 3525 @end
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/render_widget_host_view_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698