| 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 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 | 556 |
| 557 RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { | 557 RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { |
| 558 gfx::Screen::GetScreen()->RemoveObserver(this); | 558 gfx::Screen::GetScreen()->RemoveObserver(this); |
| 559 | 559 |
| 560 // This is being called from |cocoa_view_|'s destructor, so invalidate the | 560 // This is being called from |cocoa_view_|'s destructor, so invalidate the |
| 561 // pointer. | 561 // pointer. |
| 562 cocoa_view_ = nil; | 562 cocoa_view_ = nil; |
| 563 | 563 |
| 564 UnlockMouse(); | 564 UnlockMouse(); |
| 565 | 565 |
| 566 if (render_widget_host_ && render_widget_host_->delegate() && | |
| 567 render_widget_host_->delegate()->GetInputEventRouter()) { | |
| 568 render_widget_host_->delegate() | |
| 569 ->GetInputEventRouter() | |
| 570 ->RemoveSurfaceIdNamespaceOwner(GetSurfaceIdNamespace()); | |
| 571 } | |
| 572 | |
| 573 // Ensure that the browser compositor is destroyed in a safe order. | 566 // Ensure that the browser compositor is destroyed in a safe order. |
| 574 ShutdownBrowserCompositor(); | 567 ShutdownBrowserCompositor(); |
| 575 | 568 |
| 576 // We are owned by RenderWidgetHostViewCocoa, so if we go away before the | 569 // We are owned by RenderWidgetHostViewCocoa, so if we go away before the |
| 577 // RenderWidgetHost does we need to tell it not to hold a stale pointer to | 570 // RenderWidgetHost does we need to tell it not to hold a stale pointer to |
| 578 // us. | 571 // us. |
| 579 if (render_widget_host_) { | 572 if (render_widget_host_) { |
| 580 // If this is a RenderWidgetHostViewGuest's platform_view_, we're not the | 573 // If this is a RenderWidgetHostViewGuest's platform_view_, we're not the |
| 581 // RWH's view, the RenderWidgetHostViewGuest is. So don't reset the RWH's | 574 // RWH's view, the RenderWidgetHostViewGuest is. So don't reset the RWH's |
| 582 // view, the RenderWidgetHostViewGuest will do it. | 575 // view, the RenderWidgetHostViewGuest will do it. |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1053 composition_range_ = range; | 1046 composition_range_ = range; |
| 1054 composition_bounds_ = character_bounds; | 1047 composition_bounds_ = character_bounds; |
| 1055 } | 1048 } |
| 1056 | 1049 |
| 1057 void RenderWidgetHostViewMac::RenderProcessGone(base::TerminationStatus status, | 1050 void RenderWidgetHostViewMac::RenderProcessGone(base::TerminationStatus status, |
| 1058 int error_code) { | 1051 int error_code) { |
| 1059 Destroy(); | 1052 Destroy(); |
| 1060 } | 1053 } |
| 1061 | 1054 |
| 1062 void RenderWidgetHostViewMac::Destroy() { | 1055 void RenderWidgetHostViewMac::Destroy() { |
| 1056 // SurfaceIdNamespaces registered with RenderWidgetHostInputEventRouter |
| 1057 // have already been cleared when RenderWidgetHostViewBase notified its |
| 1058 // observers of our impending destruction. |
| 1063 [[NSNotificationCenter defaultCenter] | 1059 [[NSNotificationCenter defaultCenter] |
| 1064 removeObserver:cocoa_view_ | 1060 removeObserver:cocoa_view_ |
| 1065 name:NSWindowWillCloseNotification | 1061 name:NSWindowWillCloseNotification |
| 1066 object:popup_window_]; | 1062 object:popup_window_]; |
| 1067 | 1063 |
| 1068 // We've been told to destroy. | 1064 // We've been told to destroy. |
| 1069 [cocoa_view_ retain]; | 1065 [cocoa_view_ retain]; |
| 1070 [cocoa_view_ removeFromSuperview]; | 1066 [cocoa_view_ removeFromSuperview]; |
| 1071 [cocoa_view_ autorelease]; | 1067 [cocoa_view_ autorelease]; |
| 1072 | 1068 |
| 1073 [popup_window_ close]; | 1069 [popup_window_ close]; |
| 1074 popup_window_.autorelease(); | 1070 popup_window_.autorelease(); |
| 1075 | 1071 |
| 1076 [fullscreen_window_manager_ exitFullscreenMode]; | 1072 [fullscreen_window_manager_ exitFullscreenMode]; |
| 1077 fullscreen_window_manager_.reset(); | 1073 fullscreen_window_manager_.reset(); |
| 1078 [pepper_fullscreen_window_ close]; | 1074 [pepper_fullscreen_window_ close]; |
| 1079 | 1075 |
| 1080 // This can be called as part of processing the window's responder | 1076 // This can be called as part of processing the window's responder |
| 1081 // chain, for instance |-performKeyEquivalent:|. In that case the | 1077 // chain, for instance |-performKeyEquivalent:|. In that case the |
| 1082 // object needs to survive until the stack unwinds. | 1078 // object needs to survive until the stack unwinds. |
| 1083 pepper_fullscreen_window_.autorelease(); | 1079 pepper_fullscreen_window_.autorelease(); |
| 1084 | 1080 |
| 1085 // Clear SurfaceID namespace ownership before we shutdown the | |
| 1086 // compositor. | |
| 1087 if (render_widget_host_ && render_widget_host_->delegate() && | |
| 1088 render_widget_host_->delegate()->GetInputEventRouter()) { | |
| 1089 render_widget_host_->delegate() | |
| 1090 ->GetInputEventRouter() | |
| 1091 ->RemoveSurfaceIdNamespaceOwner(GetSurfaceIdNamespace()); | |
| 1092 } | |
| 1093 | |
| 1094 // Delete the delegated frame state, which will reach back into | 1081 // Delete the delegated frame state, which will reach back into |
| 1095 // render_widget_host_. | 1082 // render_widget_host_. |
| 1096 ShutdownBrowserCompositor(); | 1083 ShutdownBrowserCompositor(); |
| 1097 | 1084 |
| 1085 // Make sure none of our observers send events for us to process after |
| 1086 // we release render_widget_host_. |
| 1087 NotifyObserversAboutShutdown(); |
| 1088 |
| 1098 // We get this call just before |render_widget_host_| deletes | 1089 // We get this call just before |render_widget_host_| deletes |
| 1099 // itself. But we are owned by |cocoa_view_|, which may be retained | 1090 // itself. But we are owned by |cocoa_view_|, which may be retained |
| 1100 // by some other code. Examples are WebContentsViewMac's | 1091 // by some other code. Examples are WebContentsViewMac's |
| 1101 // |latent_focus_view_| and TabWindowController's | 1092 // |latent_focus_view_| and TabWindowController's |
| 1102 // |cachedContentView_|. | 1093 // |cachedContentView_|. |
| 1103 render_widget_host_ = NULL; | 1094 render_widget_host_ = NULL; |
| 1104 } | 1095 } |
| 1105 | 1096 |
| 1106 // Called from the renderer to tell us what the tooltip text should be. It | 1097 // Called from the renderer to tell us what the tooltip text should be. It |
| 1107 // calls us frequently so we need to cache the value to prevent doing a lot | 1098 // calls us frequently so we need to cache the value to prevent doing a lot |
| (...skipping 2341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3449 | 3440 |
| 3450 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3441 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 3451 // regions that are not draggable. (See ControlRegionView in | 3442 // regions that are not draggable. (See ControlRegionView in |
| 3452 // native_app_window_cocoa.mm). This requires the render host view to be | 3443 // native_app_window_cocoa.mm). This requires the render host view to be |
| 3453 // draggable by default. | 3444 // draggable by default. |
| 3454 - (BOOL)mouseDownCanMoveWindow { | 3445 - (BOOL)mouseDownCanMoveWindow { |
| 3455 return YES; | 3446 return YES; |
| 3456 } | 3447 } |
| 3457 | 3448 |
| 3458 @end | 3449 @end |
| OLD | NEW |