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