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

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

Issue 374643002: Mac: Enable delegated renderer by default (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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 | « content/browser/cocoa/system_hotkey_map_unittest.mm ('k') | content/content_browser.gypi » ('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 <objc/runtime.h> 7 #import <objc/runtime.h>
8 #include <OpenGL/gl.h> 8 #include <OpenGL/gl.h>
9 #include <QuartzCore/QuartzCore.h> 9 #include <QuartzCore/QuartzCore.h>
10 10
(...skipping 10 matching lines...) Expand all
21 #include "base/mac/sdk_forward_declarations.h" 21 #include "base/mac/sdk_forward_declarations.h"
22 #include "base/message_loop/message_loop.h" 22 #include "base/message_loop/message_loop.h"
23 #include "base/metrics/histogram.h" 23 #include "base/metrics/histogram.h"
24 #include "base/strings/string_util.h" 24 #include "base/strings/string_util.h"
25 #include "base/strings/stringprintf.h" 25 #include "base/strings/stringprintf.h"
26 #include "base/strings/sys_string_conversions.h" 26 #include "base/strings/sys_string_conversions.h"
27 #include "base/strings/utf_string_conversions.h" 27 #include "base/strings/utf_string_conversions.h"
28 #include "base/sys_info.h" 28 #include "base/sys_info.h"
29 #import "content/browser/accessibility/browser_accessibility_cocoa.h" 29 #import "content/browser/accessibility/browser_accessibility_cocoa.h"
30 #include "content/browser/accessibility/browser_accessibility_manager_mac.h" 30 #include "content/browser/accessibility/browser_accessibility_manager_mac.h"
31 #import "content/browser/cocoa/system_hotkey_helper_mac.h"
32 #import "content/browser/cocoa/system_hotkey_map.h"
33 #include "content/browser/compositor/resize_lock.h" 31 #include "content/browser/compositor/resize_lock.h"
34 #include "content/browser/frame_host/frame_tree.h" 32 #include "content/browser/frame_host/frame_tree.h"
35 #include "content/browser/frame_host/frame_tree_node.h" 33 #include "content/browser/frame_host/frame_tree_node.h"
36 #include "content/browser/frame_host/render_frame_host_impl.h" 34 #include "content/browser/frame_host/render_frame_host_impl.h"
37 #include "content/browser/gpu/compositor_util.h" 35 #include "content/browser/gpu/compositor_util.h"
38 #include "content/browser/renderer_host/compositing_iosurface_context_mac.h" 36 #include "content/browser/renderer_host/compositing_iosurface_context_mac.h"
39 #include "content/browser/renderer_host/compositing_iosurface_layer_mac.h" 37 #include "content/browser/renderer_host/compositing_iosurface_layer_mac.h"
40 #include "content/browser/renderer_host/compositing_iosurface_mac.h" 38 #include "content/browser/renderer_host/compositing_iosurface_mac.h"
41 #include "content/browser/renderer_host/render_widget_helper.h" 39 #include "content/browser/renderer_host/render_widget_helper.h"
42 #include "content/browser/renderer_host/render_view_host_impl.h" 40 #include "content/browser/renderer_host/render_view_host_impl.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 using content::RenderWidgetHostViewMac; 89 using content::RenderWidgetHostViewMac;
92 using content::RenderWidgetHostViewMacEditCommandHelper; 90 using content::RenderWidgetHostViewMacEditCommandHelper;
93 using content::TextInputClientMac; 91 using content::TextInputClientMac;
94 using content::WebContents; 92 using content::WebContents;
95 using blink::WebInputEvent; 93 using blink::WebInputEvent;
96 using blink::WebInputEventFactory; 94 using blink::WebInputEventFactory;
97 using blink::WebMouseEvent; 95 using blink::WebMouseEvent;
98 using blink::WebMouseWheelEvent; 96 using blink::WebMouseWheelEvent;
99 using blink::WebGestureEvent; 97 using blink::WebGestureEvent;
100 98
101 namespace {
102
103 // Whether a keyboard event has been reserved by OSX.
104 BOOL EventIsReservedBySystem(NSEvent* event) {
105 content::SystemHotkeyHelperMac* helper =
106 content::SystemHotkeyHelperMac::GetInstance();
107 return helper->map()->IsEventReserved(event);
108 }
109
110 } // namespace
111
112 // These are not documented, so use only after checking -respondsToSelector:. 99 // These are not documented, so use only after checking -respondsToSelector:.
113 @interface NSApplication (UndocumentedSpeechMethods) 100 @interface NSApplication (UndocumentedSpeechMethods)
114 - (void)speakString:(NSString*)string; 101 - (void)speakString:(NSString*)string;
115 - (void)stopSpeaking:(id)sender; 102 - (void)stopSpeaking:(id)sender;
116 - (BOOL)isSpeaking; 103 - (BOOL)isSpeaking;
117 @end 104 @end
118 105
119 // Declare things that are part of the 10.7 SDK. 106 // Declare things that are part of the 10.7 SDK.
120 #if !defined(MAC_OS_X_VERSION_10_7) || \ 107 #if !defined(MAC_OS_X_VERSION_10_7) || \
121 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 108 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
(...skipping 2403 matching lines...) Expand 10 before | Expand all | Expand 10 after
2525 } 2512 }
2526 2513
2527 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent { 2514 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent {
2528 // |performKeyEquivalent:| is sent to all views of a window, not only down the 2515 // |performKeyEquivalent:| is sent to all views of a window, not only down the
2529 // responder chain (cf. "Handling Key Equivalents" in 2516 // responder chain (cf. "Handling Key Equivalents" in
2530 // http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Event Overview/HandlingKeyEvents/HandlingKeyEvents.html 2517 // http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Event Overview/HandlingKeyEvents/HandlingKeyEvents.html
2531 // ). We only want to handle key equivalents if we're first responder. 2518 // ). We only want to handle key equivalents if we're first responder.
2532 if ([[self window] firstResponder] != self) 2519 if ([[self window] firstResponder] != self)
2533 return NO; 2520 return NO;
2534 2521
2535 // If the event is reserved by the system, then do not pass it to web content.
2536 if (EventIsReservedBySystem(theEvent))
2537 return NO;
2538
2539 // If we return |NO| from this function, cocoa will send the key event to 2522 // If we return |NO| from this function, cocoa will send the key event to
2540 // the menu and only if the menu does not process the event to |keyDown:|. We 2523 // the menu and only if the menu does not process the event to |keyDown:|. We
2541 // want to send the event to a renderer _before_ sending it to the menu, so 2524 // want to send the event to a renderer _before_ sending it to the menu, so
2542 // we need to return |YES| for all events that might be swallowed by the menu. 2525 // we need to return |YES| for all events that might be swallowed by the menu.
2543 // We do not return |YES| for every keypress because we don't get |keyDown:| 2526 // We do not return |YES| for every keypress because we don't get |keyDown:|
2544 // events for keys that we handle this way. 2527 // events for keys that we handle this way.
2545 NSUInteger modifierFlags = [theEvent modifierFlags]; 2528 NSUInteger modifierFlags = [theEvent modifierFlags];
2546 if ((modifierFlags & NSCommandKeyMask) == 0) { 2529 if ((modifierFlags & NSCommandKeyMask) == 0) {
2547 // Make sure the menu does not contain key equivalents that don't 2530 // Make sure the menu does not contain key equivalents that don't
2548 // contain cmd. 2531 // contain cmd.
(...skipping 27 matching lines...) Expand all
2576 if (handled) 2559 if (handled)
2577 return kEventHandled; 2560 return kEventHandled;
2578 } 2561 }
2579 2562
2580 [self keyEvent:theEvent wasKeyEquivalent:NO]; 2563 [self keyEvent:theEvent wasKeyEquivalent:NO];
2581 return kEventHandled; 2564 return kEventHandled;
2582 } 2565 }
2583 2566
2584 - (void)keyEvent:(NSEvent*)theEvent wasKeyEquivalent:(BOOL)equiv { 2567 - (void)keyEvent:(NSEvent*)theEvent wasKeyEquivalent:(BOOL)equiv {
2585 TRACE_EVENT0("browser", "RenderWidgetHostViewCocoa::keyEvent"); 2568 TRACE_EVENT0("browser", "RenderWidgetHostViewCocoa::keyEvent");
2586
2587 // If the user changes the system hotkey mapping after Chrome has been
2588 // launched, then it is possible that a formerly reserved system hotkey is no
2589 // longer reserved. The hotkey would have skipped the renderer, but would
2590 // also have not been handled by the system. If this is the case, immediately
2591 // return.
2592 // TODO(erikchen): SystemHotkeyHelperMac should use the File System Events
2593 // api to monitor changes to system hotkeys. This logic will have to be
2594 // updated.
2595 // http://crbug.com/383558.
2596 if (EventIsReservedBySystem(theEvent))
2597 return;
2598
2599 DCHECK([theEvent type] != NSKeyDown || 2569 DCHECK([theEvent type] != NSKeyDown ||
2600 !equiv == !([theEvent modifierFlags] & NSCommandKeyMask)); 2570 !equiv == !([theEvent modifierFlags] & NSCommandKeyMask));
2601 2571
2602 if ([theEvent type] == NSFlagsChanged) { 2572 if ([theEvent type] == NSFlagsChanged) {
2603 // Ignore NSFlagsChanged events from the NumLock and Fn keys as 2573 // Ignore NSFlagsChanged events from the NumLock and Fn keys as
2604 // Safari does in -[WebHTMLView flagsChanged:] (of "WebHTMLView.mm"). 2574 // Safari does in -[WebHTMLView flagsChanged:] (of "WebHTMLView.mm").
2605 int keyCode = [theEvent keyCode]; 2575 int keyCode = [theEvent keyCode];
2606 if (!keyCode || keyCode == 10 || keyCode == 63) 2576 if (!keyCode || keyCode == 10 || keyCode == 63)
2607 return; 2577 return;
2608 } 2578 }
(...skipping 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after
3982 3952
3983 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3953 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3984 // regions that are not draggable. (See ControlRegionView in 3954 // regions that are not draggable. (See ControlRegionView in
3985 // native_app_window_cocoa.mm). This requires the render host view to be 3955 // native_app_window_cocoa.mm). This requires the render host view to be
3986 // draggable by default. 3956 // draggable by default.
3987 - (BOOL)mouseDownCanMoveWindow { 3957 - (BOOL)mouseDownCanMoveWindow {
3988 return YES; 3958 return YES;
3989 } 3959 }
3990 3960
3991 @end 3961 @end
OLDNEW
« no previous file with comments | « content/browser/cocoa/system_hotkey_map_unittest.mm ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698