| OLD | NEW |
| 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 #include <utility> | 10 #include <utility> |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 #include "content/common/accessibility_messages.h" | 51 #include "content/common/accessibility_messages.h" |
| 52 #include "content/common/edit_command.h" | 52 #include "content/common/edit_command.h" |
| 53 #include "content/common/gpu/gpu_messages.h" | 53 #include "content/common/gpu/gpu_messages.h" |
| 54 #include "content/common/input_messages.h" | 54 #include "content/common/input_messages.h" |
| 55 #include "content/common/view_messages.h" | 55 #include "content/common/view_messages.h" |
| 56 #include "content/common/webplugin_geometry.h" | 56 #include "content/common/webplugin_geometry.h" |
| 57 #include "content/public/browser/browser_context.h" | 57 #include "content/public/browser/browser_context.h" |
| 58 #include "content/public/browser/browser_plugin_guest_manager.h" | 58 #include "content/public/browser/browser_plugin_guest_manager.h" |
| 59 #include "content/public/browser/browser_thread.h" | 59 #include "content/public/browser/browser_thread.h" |
| 60 #include "content/public/browser/native_web_keyboard_event.h" | 60 #include "content/public/browser/native_web_keyboard_event.h" |
| 61 #include "content/public/browser/notification_service.h" | |
| 62 #include "content/public/browser/notification_types.h" | |
| 63 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" | 61 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
| 64 #import "content/public/browser/render_widget_host_view_mac_delegate.h" | 62 #import "content/public/browser/render_widget_host_view_mac_delegate.h" |
| 65 #include "content/public/browser/web_contents.h" | 63 #include "content/public/browser/web_contents.h" |
| 66 #include "skia/ext/platform_canvas.h" | 64 #include "skia/ext/platform_canvas.h" |
| 67 #include "skia/ext/skia_utils_mac.h" | 65 #include "skia/ext/skia_utils_mac.h" |
| 68 #include "third_party/WebKit/public/platform/WebScreenInfo.h" | 66 #include "third_party/WebKit/public/platform/WebScreenInfo.h" |
| 69 #include "third_party/WebKit/public/web/WebInputEvent.h" | 67 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 70 #import "third_party/mozilla/ComplexTextInputPanel.h" | 68 #import "third_party/mozilla/ComplexTextInputPanel.h" |
| 71 #include "ui/accelerated_widget_mac/surface_handle_types.h" | 69 #include "ui/accelerated_widget_mac/surface_handle_types.h" |
| 72 #include "ui/base/cocoa/animation_utils.h" | 70 #include "ui/base/cocoa/animation_utils.h" |
| (...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 [cocoa_view_ setMarkedRange:range.ToNSRange()]; | 1047 [cocoa_view_ setMarkedRange:range.ToNSRange()]; |
| 1050 composition_range_ = range; | 1048 composition_range_ = range; |
| 1051 composition_bounds_ = character_bounds; | 1049 composition_bounds_ = character_bounds; |
| 1052 } | 1050 } |
| 1053 | 1051 |
| 1054 void RenderWidgetHostViewMac::RenderProcessGone(base::TerminationStatus status, | 1052 void RenderWidgetHostViewMac::RenderProcessGone(base::TerminationStatus status, |
| 1055 int error_code) { | 1053 int error_code) { |
| 1056 Destroy(); | 1054 Destroy(); |
| 1057 } | 1055 } |
| 1058 | 1056 |
| 1059 void RenderWidgetHostViewMac::RenderWidgetHostGone() { | |
| 1060 // Clear SurfaceID namespace ownership before we shutdown the | |
| 1061 // compositor. | |
| 1062 if (UseSurfacesEnabled() && render_widget_host_ && | |
| 1063 render_widget_host_->delegate() && | |
| 1064 render_widget_host_->delegate()->GetInputEventRouter()) { | |
| 1065 render_widget_host_->delegate() | |
| 1066 ->GetInputEventRouter() | |
| 1067 ->RemoveSurfaceIdNamespaceOwner(GetSurfaceIdNamespace()); | |
| 1068 } | |
| 1069 | |
| 1070 // Destroy the DelegatedFrameHost, to prevent crashes when Destroy is never | |
| 1071 // called on the view. | |
| 1072 // http://crbug.com/404828 | |
| 1073 ShutdownBrowserCompositor(); | |
| 1074 } | |
| 1075 | |
| 1076 void RenderWidgetHostViewMac::Destroy() { | 1057 void RenderWidgetHostViewMac::Destroy() { |
| 1077 [[NSNotificationCenter defaultCenter] | 1058 [[NSNotificationCenter defaultCenter] |
| 1078 removeObserver:cocoa_view_ | 1059 removeObserver:cocoa_view_ |
| 1079 name:NSWindowWillCloseNotification | 1060 name:NSWindowWillCloseNotification |
| 1080 object:popup_window_]; | 1061 object:popup_window_]; |
| 1081 | 1062 |
| 1082 // We've been told to destroy. | 1063 // We've been told to destroy. |
| 1083 [cocoa_view_ retain]; | 1064 [cocoa_view_ retain]; |
| 1084 [cocoa_view_ removeFromSuperview]; | 1065 [cocoa_view_ removeFromSuperview]; |
| 1085 [cocoa_view_ autorelease]; | 1066 [cocoa_view_ autorelease]; |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1626 | 1607 |
| 1627 bool RenderWidgetHostViewMac::Send(IPC::Message* message) { | 1608 bool RenderWidgetHostViewMac::Send(IPC::Message* message) { |
| 1628 if (render_widget_host_) | 1609 if (render_widget_host_) |
| 1629 return render_widget_host_->Send(message); | 1610 return render_widget_host_->Send(message); |
| 1630 delete message; | 1611 delete message; |
| 1631 return false; | 1612 return false; |
| 1632 } | 1613 } |
| 1633 | 1614 |
| 1634 void RenderWidgetHostViewMac::ShutdownHost() { | 1615 void RenderWidgetHostViewMac::ShutdownHost() { |
| 1635 weak_factory_.InvalidateWeakPtrs(); | 1616 weak_factory_.InvalidateWeakPtrs(); |
| 1636 render_widget_host_->Shutdown(); | 1617 render_widget_host_->ShutdownAndDestroyWidget(true); |
| 1637 // Do not touch any members at this point, |this| has been deleted. | 1618 // Do not touch any members at this point, |this| has been deleted. |
| 1638 } | 1619 } |
| 1639 | 1620 |
| 1640 void RenderWidgetHostViewMac::ShutdownBrowserCompositor() { | 1621 void RenderWidgetHostViewMac::ShutdownBrowserCompositor() { |
| 1641 DestroyBrowserCompositorView(); | 1622 DestroyBrowserCompositorView(); |
| 1642 delegated_frame_host_.reset(); | 1623 delegated_frame_host_.reset(); |
| 1643 root_layer_.reset(); | 1624 root_layer_.reset(); |
| 1644 browser_compositor_placeholder_.reset(); | 1625 browser_compositor_placeholder_.reset(); |
| 1645 } | 1626 } |
| 1646 | 1627 |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2094 | 2075 |
| 2095 // Force fullscreen windows to close on Escape so they won't keep the keyboard | 2076 // Force fullscreen windows to close on Escape so they won't keep the keyboard |
| 2096 // grabbed or be stuck onscreen if the renderer is hanging. | 2077 // grabbed or be stuck onscreen if the renderer is hanging. |
| 2097 if (event.type == NativeWebKeyboardEvent::RawKeyDown && | 2078 if (event.type == NativeWebKeyboardEvent::RawKeyDown && |
| 2098 event.windowsKeyCode == ui::VKEY_ESCAPE && | 2079 event.windowsKeyCode == ui::VKEY_ESCAPE && |
| 2099 renderWidgetHostView_->pepper_fullscreen_window()) { | 2080 renderWidgetHostView_->pepper_fullscreen_window()) { |
| 2100 RenderWidgetHostViewMac* parent = | 2081 RenderWidgetHostViewMac* parent = |
| 2101 renderWidgetHostView_->fullscreen_parent_host_view(); | 2082 renderWidgetHostView_->fullscreen_parent_host_view(); |
| 2102 if (parent) | 2083 if (parent) |
| 2103 parent->cocoa_view()->suppressNextEscapeKeyUp_ = YES; | 2084 parent->cocoa_view()->suppressNextEscapeKeyUp_ = YES; |
| 2104 widgetHost->Shutdown(); | 2085 widgetHost->ShutdownAndDestroyWidget(true); |
| 2105 return; | 2086 return; |
| 2106 } | 2087 } |
| 2107 | 2088 |
| 2108 // If there are multiple widgets on the page (such as when there are | 2089 // If there are multiple widgets on the page (such as when there are |
| 2109 // out-of-process iframes), pick the one that should process this event. | 2090 // out-of-process iframes), pick the one that should process this event. |
| 2110 if (widgetHost->delegate()) | 2091 if (widgetHost->delegate()) |
| 2111 widgetHost = widgetHost->delegate()->GetFocusedRenderWidgetHost(widgetHost); | 2092 widgetHost = widgetHost->delegate()->GetFocusedRenderWidgetHost(widgetHost); |
| 2112 | 2093 |
| 2113 // Suppress the escape key up event if necessary. | 2094 // Suppress the escape key up event if necessary. |
| 2114 if (event.windowsKeyCode == ui::VKEY_ESCAPE && suppressNextEscapeKeyUp_) { | 2095 if (event.windowsKeyCode == ui::VKEY_ESCAPE && suppressNextEscapeKeyUp_) { |
| (...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3442 | 3423 |
| 3443 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3424 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 3444 // regions that are not draggable. (See ControlRegionView in | 3425 // regions that are not draggable. (See ControlRegionView in |
| 3445 // native_app_window_cocoa.mm). This requires the render host view to be | 3426 // native_app_window_cocoa.mm). This requires the render host view to be |
| 3446 // draggable by default. | 3427 // draggable by default. |
| 3447 - (BOOL)mouseDownCanMoveWindow { | 3428 - (BOOL)mouseDownCanMoveWindow { |
| 3448 return YES; | 3429 return YES; |
| 3449 } | 3430 } |
| 3450 | 3431 |
| 3451 @end | 3432 @end |
| OLD | NEW |