| 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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 | 646 |
| 647 void RenderWidgetHostViewMac::DestroyBrowserCompositorView() { | 647 void RenderWidgetHostViewMac::DestroyBrowserCompositorView() { |
| 648 TRACE_EVENT0("browser", | 648 TRACE_EVENT0("browser", |
| 649 "RenderWidgetHostViewMac::DestroyBrowserCompositorView"); | 649 "RenderWidgetHostViewMac::DestroyBrowserCompositorView"); |
| 650 | 650 |
| 651 // Transition from Active -> Suspended if need be. | 651 // Transition from Active -> Suspended if need be. |
| 652 SuspendBrowserCompositorView(); | 652 SuspendBrowserCompositorView(); |
| 653 | 653 |
| 654 // Destroy the BrowserCompositorView to transition Suspended -> Destroyed. | 654 // Destroy the BrowserCompositorView to transition Suspended -> Destroyed. |
| 655 if (browser_compositor_state_ == BrowserCompositorSuspended) { | 655 if (browser_compositor_state_ == BrowserCompositorSuspended) { |
| 656 browser_compositor_->accelerated_widget_mac()->ResetNSView(); | 656 if (browser_compositor_) { |
| 657 browser_compositor_->compositor()->SetScaleAndSize(1.0, gfx::Size(0, 0)); | 657 browser_compositor_->accelerated_widget_mac()->ResetNSView(); |
| 658 browser_compositor_->compositor()->SetRootLayer(nullptr); | 658 browser_compositor_->compositor()->SetScaleAndSize(1.0, gfx::Size(0, 0)); |
| 659 BrowserCompositorMac::Recycle(browser_compositor_.Pass()); | 659 browser_compositor_->compositor()->SetRootLayer(nullptr); |
| 660 BrowserCompositorMac::Recycle(browser_compositor_.Pass()); |
| 661 } |
| 660 browser_compositor_state_ = BrowserCompositorDestroyed; | 662 browser_compositor_state_ = BrowserCompositorDestroyed; |
| 661 } | 663 } |
| 662 } | 664 } |
| 663 | 665 |
| 664 void RenderWidgetHostViewMac::DestroySuspendedBrowserCompositorViewIfNeeded() { | 666 void RenderWidgetHostViewMac::DestroySuspendedBrowserCompositorViewIfNeeded() { |
| 665 if (browser_compositor_state_ != BrowserCompositorSuspended) | 667 if (browser_compositor_state_ != BrowserCompositorSuspended) |
| 666 return; | 668 return; |
| 667 | 669 |
| 668 // If this view is in a window that is visible, keep around the suspended | 670 // If this view is in a window that is visible, keep around the suspended |
| 669 // BrowserCompositorView in case |cocoa_view_| is suddenly revealed (so that | 671 // BrowserCompositorView in case |cocoa_view_| is suddenly revealed (so that |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 void RenderWidgetHostViewMac::WasOccluded() { | 886 void RenderWidgetHostViewMac::WasOccluded() { |
| 885 if (render_widget_host_->is_hidden()) | 887 if (render_widget_host_->is_hidden()) |
| 886 return; | 888 return; |
| 887 | 889 |
| 888 // Note that the following call to WasHidden() can trigger thumbnail | 890 // Note that the following call to WasHidden() can trigger thumbnail |
| 889 // generation on behalf of the NTP, and that cannot succeed if the browser | 891 // generation on behalf of the NTP, and that cannot succeed if the browser |
| 890 // compositor view has been suspended. Therefore these two statements must | 892 // compositor view has been suspended. Therefore these two statements must |
| 891 // occur in this specific order. However, because thumbnail generation is | 893 // occur in this specific order. However, because thumbnail generation is |
| 892 // asychronous, that operation won't run before SuspendBrowserCompositorView() | 894 // asychronous, that operation won't run before SuspendBrowserCompositorView() |
| 893 // completes. As a result you won't get a thumbnail for the page unless you | 895 // completes. As a result you won't get a thumbnail for the page unless you |
| 894 // happen to switch back to it. See http://crbug.com/530707 . | 896 // execute these two statements in this specific order. |
| 895 render_widget_host_->WasHidden(); | 897 render_widget_host_->WasHidden(); |
| 896 SuspendBrowserCompositorView(); | 898 SuspendBrowserCompositorView(); |
| 897 } | 899 } |
| 898 | 900 |
| 899 void RenderWidgetHostViewMac::SetSize(const gfx::Size& size) { | 901 void RenderWidgetHostViewMac::SetSize(const gfx::Size& size) { |
| 900 gfx::Rect rect = GetViewBounds(); | 902 gfx::Rect rect = GetViewBounds(); |
| 901 rect.set_size(size); | 903 rect.set_size(size); |
| 902 SetBounds(rect); | 904 SetBounds(rect); |
| 903 } | 905 } |
| 904 | 906 |
| (...skipping 2536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3441 | 3443 |
| 3442 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3444 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 3443 // regions that are not draggable. (See ControlRegionView in | 3445 // regions that are not draggable. (See ControlRegionView in |
| 3444 // native_app_window_cocoa.mm). This requires the render host view to be | 3446 // native_app_window_cocoa.mm). This requires the render host view to be |
| 3445 // draggable by default. | 3447 // draggable by default. |
| 3446 - (BOOL)mouseDownCanMoveWindow { | 3448 - (BOOL)mouseDownCanMoveWindow { |
| 3447 return YES; | 3449 return YES; |
| 3448 } | 3450 } |
| 3449 | 3451 |
| 3450 @end | 3452 @end |
| OLD | NEW |