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 | 10 |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 | 551 |
552 RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { | 552 RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { |
553 gfx::Screen::GetScreenFor(cocoa_view_)->RemoveObserver(this); | 553 gfx::Screen::GetScreenFor(cocoa_view_)->RemoveObserver(this); |
554 | 554 |
555 // This is being called from |cocoa_view_|'s destructor, so invalidate the | 555 // This is being called from |cocoa_view_|'s destructor, so invalidate the |
556 // pointer. | 556 // pointer. |
557 cocoa_view_ = nil; | 557 cocoa_view_ = nil; |
558 | 558 |
559 UnlockMouse(); | 559 UnlockMouse(); |
560 | 560 |
| 561 // Ensure that the browser compositor is destroyed in a safe order. |
| 562 ShutdownBrowserCompositor(); |
| 563 |
561 // Make sure that the layer doesn't reach into the now-invalid object. | 564 // Make sure that the layer doesn't reach into the now-invalid object. |
562 DestroyCompositedIOSurfaceAndLayer(); | 565 DestroyCompositedIOSurfaceAndLayer(); |
563 DestroySoftwareLayer(); | 566 DestroySoftwareLayer(); |
564 | 567 |
565 // We are owned by RenderWidgetHostViewCocoa, so if we go away before the | 568 // We are owned by RenderWidgetHostViewCocoa, so if we go away before the |
566 // RenderWidgetHost does we need to tell it not to hold a stale pointer to | 569 // RenderWidgetHost does we need to tell it not to hold a stale pointer to |
567 // us. | 570 // us. |
568 if (render_widget_host_) | 571 if (render_widget_host_) |
569 render_widget_host_->SetView(NULL); | 572 render_widget_host_->SetView(NULL); |
570 } | 573 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 delegated_frame_host_->AddedToWindow(); | 656 delegated_frame_host_->AddedToWindow(); |
654 delegated_frame_host_->WasShown(ui::LatencyInfo()); | 657 delegated_frame_host_->WasShown(ui::LatencyInfo()); |
655 } | 658 } |
656 | 659 |
657 void RenderWidgetHostViewMac::DestroyBrowserCompositorView() { | 660 void RenderWidgetHostViewMac::DestroyBrowserCompositorView() { |
658 TRACE_EVENT0("browser", | 661 TRACE_EVENT0("browser", |
659 "RenderWidgetHostViewMac::DestroyBrowserCompositorView"); | 662 "RenderWidgetHostViewMac::DestroyBrowserCompositorView"); |
660 if (!browser_compositor_view_) | 663 if (!browser_compositor_view_) |
661 return; | 664 return; |
662 | 665 |
| 666 // Marking the DelegatedFrameHost as removed from the window hierarchy is |
| 667 // necessary to remove all connections to its old ui::Compositor. |
663 delegated_frame_host_->WasHidden(); | 668 delegated_frame_host_->WasHidden(); |
664 delegated_frame_host_->RemovingFromWindow(); | 669 delegated_frame_host_->RemovingFromWindow(); |
665 browser_compositor_view_.reset(); | 670 browser_compositor_view_.reset(); |
666 } | 671 } |
667 | 672 |
668 void RenderWidgetHostViewMac::EnsureSoftwareLayer() { | 673 void RenderWidgetHostViewMac::EnsureSoftwareLayer() { |
669 TRACE_EVENT0("browser", "RenderWidgetHostViewMac::EnsureSoftwareLayer"); | 674 TRACE_EVENT0("browser", "RenderWidgetHostViewMac::EnsureSoftwareLayer"); |
670 if (software_layer_) | 675 if (software_layer_) |
671 return; | 676 return; |
672 | 677 |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1135 fullscreen_window_manager_.reset(); | 1140 fullscreen_window_manager_.reset(); |
1136 [pepper_fullscreen_window_ close]; | 1141 [pepper_fullscreen_window_ close]; |
1137 | 1142 |
1138 // This can be called as part of processing the window's responder | 1143 // This can be called as part of processing the window's responder |
1139 // chain, for instance |-performKeyEquivalent:|. In that case the | 1144 // chain, for instance |-performKeyEquivalent:|. In that case the |
1140 // object needs to survive until the stack unwinds. | 1145 // object needs to survive until the stack unwinds. |
1141 pepper_fullscreen_window_.autorelease(); | 1146 pepper_fullscreen_window_.autorelease(); |
1142 | 1147 |
1143 // Delete the delegated frame state, which will reach back into | 1148 // Delete the delegated frame state, which will reach back into |
1144 // render_widget_host_. | 1149 // render_widget_host_. |
1145 DestroyBrowserCompositorView(); | 1150 ShutdownBrowserCompositor(); |
1146 delegated_frame_host_.reset(); | |
1147 root_layer_.reset(); | |
1148 browser_compositor_view_placeholder_.reset(); | |
1149 | 1151 |
1150 // We get this call just before |render_widget_host_| deletes | 1152 // We get this call just before |render_widget_host_| deletes |
1151 // itself. But we are owned by |cocoa_view_|, which may be retained | 1153 // itself. But we are owned by |cocoa_view_|, which may be retained |
1152 // by some other code. Examples are WebContentsViewMac's | 1154 // by some other code. Examples are WebContentsViewMac's |
1153 // |latent_focus_view_| and TabWindowController's | 1155 // |latent_focus_view_| and TabWindowController's |
1154 // |cachedContentView_|. | 1156 // |cachedContentView_|. |
1155 render_widget_host_ = NULL; | 1157 render_widget_host_ = NULL; |
1156 } | 1158 } |
1157 | 1159 |
1158 // Called from the renderer to tell us what the tooltip text should be. It | 1160 // Called from the renderer to tell us what the tooltip text should be. It |
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2022 void RenderWidgetHostViewMac::ReleaseReferencesToSoftwareFrame() { | 2024 void RenderWidgetHostViewMac::ReleaseReferencesToSoftwareFrame() { |
2023 DestroySoftwareLayer(); | 2025 DestroySoftwareLayer(); |
2024 } | 2026 } |
2025 | 2027 |
2026 void RenderWidgetHostViewMac::ShutdownHost() { | 2028 void RenderWidgetHostViewMac::ShutdownHost() { |
2027 weak_factory_.InvalidateWeakPtrs(); | 2029 weak_factory_.InvalidateWeakPtrs(); |
2028 render_widget_host_->Shutdown(); | 2030 render_widget_host_->Shutdown(); |
2029 // Do not touch any members at this point, |this| has been deleted. | 2031 // Do not touch any members at this point, |this| has been deleted. |
2030 } | 2032 } |
2031 | 2033 |
| 2034 void RenderWidgetHostViewMac::ShutdownBrowserCompositor() { |
| 2035 DestroyBrowserCompositorView(); |
| 2036 delegated_frame_host_.reset(); |
| 2037 root_layer_.reset(); |
| 2038 browser_compositor_view_placeholder_.reset(); |
| 2039 } |
| 2040 |
2032 void RenderWidgetHostViewMac::GotAcceleratedFrame() { | 2041 void RenderWidgetHostViewMac::GotAcceleratedFrame() { |
2033 EnsureCompositedIOSurfaceLayer(); | 2042 EnsureCompositedIOSurfaceLayer(); |
2034 SendVSyncParametersToRenderer(); | 2043 SendVSyncParametersToRenderer(); |
2035 | 2044 |
2036 // Delete software backingstore and layer. | 2045 // Delete software backingstore and layer. |
2037 software_frame_manager_->DiscardCurrentFrame(); | 2046 software_frame_manager_->DiscardCurrentFrame(); |
2038 DestroySoftwareLayer(); | 2047 DestroySoftwareLayer(); |
2039 } | 2048 } |
2040 | 2049 |
2041 void RenderWidgetHostViewMac::GotSoftwareFrame() { | 2050 void RenderWidgetHostViewMac::GotSoftwareFrame() { |
(...skipping 2019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4061 | 4070 |
4062 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 4071 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
4063 // regions that are not draggable. (See ControlRegionView in | 4072 // regions that are not draggable. (See ControlRegionView in |
4064 // native_app_window_cocoa.mm). This requires the render host view to be | 4073 // native_app_window_cocoa.mm). This requires the render host view to be |
4065 // draggable by default. | 4074 // draggable by default. |
4066 - (BOOL)mouseDownCanMoveWindow { | 4075 - (BOOL)mouseDownCanMoveWindow { |
4067 return YES; | 4076 return YES; |
4068 } | 4077 } |
4069 | 4078 |
4070 @end | 4079 @end |
OLD | NEW |