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 <Carbon/Carbon.h> | 7 #import <Carbon/Carbon.h> |
8 #import <objc/runtime.h> | 8 #import <objc/runtime.h> |
9 #include <OpenGL/gl.h> | 9 #include <OpenGL/gl.h> |
10 #include <QuartzCore/QuartzCore.h> | 10 #include <QuartzCore/QuartzCore.h> |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
442 | 442 |
443 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget, | 443 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget, |
444 bool is_guest_view_hack) | 444 bool is_guest_view_hack) |
445 : render_widget_host_(RenderWidgetHostImpl::From(widget)), | 445 : render_widget_host_(RenderWidgetHostImpl::From(widget)), |
446 page_at_minimum_scale_(true), | 446 page_at_minimum_scale_(true), |
447 is_loading_(false), | 447 is_loading_(false), |
448 allow_pause_for_resize_or_repaint_(true), | 448 allow_pause_for_resize_or_repaint_(true), |
449 is_guest_view_hack_(is_guest_view_hack), | 449 is_guest_view_hack_(is_guest_view_hack), |
450 fullscreen_parent_host_view_(nullptr), | 450 fullscreen_parent_host_view_(nullptr), |
451 needs_flush_input_(false), | 451 needs_flush_input_(false), |
452 background_color_(SK_ColorWHITE), | |
452 weak_factory_(this) { | 453 weak_factory_(this) { |
453 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| | 454 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| |
454 // goes away. Since we autorelease it, our caller must put | 455 // goes away. Since we autorelease it, our caller must put |
455 // |GetNativeView()| into the view hierarchy right after calling us. | 456 // |GetNativeView()| into the view hierarchy right after calling us. |
456 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] | 457 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] |
457 initWithRenderWidgetHostViewMac:this] autorelease]; | 458 initWithRenderWidgetHostViewMac:this] autorelease]; |
458 | 459 |
459 // Paint this view host with |background_color_| when there is no content | 460 // Paint this view host with |background_color_| when there is no content |
460 // ready to draw. | 461 // ready to draw. |
461 background_layer_.reset([[CALayer alloc] init]); | 462 background_layer_.reset([[CALayer alloc] init]); |
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1427 browser_compositor_->DidCreateNewRendererCompositorFrameSink(); | 1428 browser_compositor_->DidCreateNewRendererCompositorFrameSink(); |
1428 } | 1429 } |
1429 | 1430 |
1430 void RenderWidgetHostViewMac::SubmitCompositorFrame( | 1431 void RenderWidgetHostViewMac::SubmitCompositorFrame( |
1431 const cc::LocalSurfaceId& local_surface_id, | 1432 const cc::LocalSurfaceId& local_surface_id, |
1432 cc::CompositorFrame frame) { | 1433 cc::CompositorFrame frame) { |
1433 TRACE_EVENT0("browser", "RenderWidgetHostViewMac::OnSwapCompositorFrame"); | 1434 TRACE_EVENT0("browser", "RenderWidgetHostViewMac::OnSwapCompositorFrame"); |
1434 | 1435 |
1435 // Override the compositor background color. See RenderWidgetHostViewAura | 1436 // Override the compositor background color. See RenderWidgetHostViewAura |
1436 // for more details. | 1437 // for more details. |
1437 SetBackgroundColor(frame.metadata.root_background_color); | 1438 SetBackgroundColor(frame.metadata.root_background_color); |
lfg
2017/04/06 18:37:59
Let's apply the same fix here as you have done for
Eric Seckler
2017/04/07 08:27:41
Ah, didn't realize this was added to RWHVMac now,
| |
1438 | 1439 |
1439 last_scroll_offset_ = frame.metadata.root_scroll_offset; | 1440 last_scroll_offset_ = frame.metadata.root_scroll_offset; |
1440 | 1441 |
1441 page_at_minimum_scale_ = | 1442 page_at_minimum_scale_ = |
1442 frame.metadata.page_scale_factor == frame.metadata.min_page_scale_factor; | 1443 frame.metadata.page_scale_factor == frame.metadata.min_page_scale_factor; |
1443 browser_compositor_->SubmitCompositorFrame(local_surface_id, | 1444 browser_compositor_->SubmitCompositorFrame(local_surface_id, |
1444 std::move(frame)); | 1445 std::move(frame)); |
1445 UpdateDisplayVSyncParameters(); | 1446 UpdateDisplayVSyncParameters(); |
1446 } | 1447 } |
1447 | 1448 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1637 } | 1638 } |
1638 | 1639 |
1639 void RenderWidgetHostViewMac::ShowDefinitionForSelection() { | 1640 void RenderWidgetHostViewMac::ShowDefinitionForSelection() { |
1640 RenderWidgetHostViewMacDictionaryHelper helper(this); | 1641 RenderWidgetHostViewMacDictionaryHelper helper(this); |
1641 helper.ShowDefinitionForSelection(); | 1642 helper.ShowDefinitionForSelection(); |
1642 } | 1643 } |
1643 | 1644 |
1644 void RenderWidgetHostViewMac::SetBackgroundColor(SkColor color) { | 1645 void RenderWidgetHostViewMac::SetBackgroundColor(SkColor color) { |
1645 if (color == background_color_) | 1646 if (color == background_color_) |
1646 return; | 1647 return; |
1648 background_color_ = color; | |
1647 | 1649 |
1648 RenderWidgetHostViewBase::SetBackgroundColor(color); | 1650 DCHECK(SkColorGetA(color) == SK_AlphaOPAQUE || |
1649 bool opaque = GetBackgroundOpaque(); | 1651 SkColorGetA(color) == SK_AlphaTRANSPARENT); |
1652 bool opaque = SkColorGetA(color) == SK_AlphaOPAQUE; | |
1650 | 1653 |
1651 if (render_widget_host_) | 1654 if (render_widget_host_) |
1652 render_widget_host_->SetBackgroundOpaque(opaque); | 1655 render_widget_host_->SetBackgroundOpaque(opaque); |
1653 | 1656 |
1654 [cocoa_view_ setOpaque:opaque]; | 1657 [cocoa_view_ setOpaque:opaque]; |
1655 | 1658 |
1656 browser_compositor_->SetHasTransparentBackground(!opaque); | 1659 browser_compositor_->SetHasTransparentBackground(!opaque); |
1657 | 1660 |
1658 ScopedCAActionDisabler disabler; | 1661 ScopedCAActionDisabler disabler; |
1659 base::ScopedCFTypeRef<CGColorRef> cg_color( | 1662 base::ScopedCFTypeRef<CGColorRef> cg_color( |
1660 skia::CGColorCreateFromSkColor(color)); | 1663 skia::CGColorCreateFromSkColor(color)); |
1661 [background_layer_ setBackgroundColor:cg_color]; | 1664 [background_layer_ setBackgroundColor:cg_color]; |
1662 } | 1665 } |
1663 | 1666 |
1667 SkColor RenderWidgetHostViewMac::background_color() const { | |
1668 return background_color_; | |
1669 } | |
1670 | |
1664 BrowserAccessibilityManager* | 1671 BrowserAccessibilityManager* |
1665 RenderWidgetHostViewMac::CreateBrowserAccessibilityManager( | 1672 RenderWidgetHostViewMac::CreateBrowserAccessibilityManager( |
1666 BrowserAccessibilityDelegate* delegate, bool for_root_frame) { | 1673 BrowserAccessibilityDelegate* delegate, bool for_root_frame) { |
1667 return new BrowserAccessibilityManagerMac( | 1674 return new BrowserAccessibilityManagerMac( |
1668 BrowserAccessibilityManagerMac::GetEmptyDocument(), delegate); | 1675 BrowserAccessibilityManagerMac::GetEmptyDocument(), delegate); |
1669 } | 1676 } |
1670 | 1677 |
1671 gfx::Point RenderWidgetHostViewMac::AccessibilityOriginInScreen( | 1678 gfx::Point RenderWidgetHostViewMac::AccessibilityOriginInScreen( |
1672 const gfx::Rect& bounds) { | 1679 const gfx::Rect& bounds) { |
1673 NSPoint origin = NSMakePoint(bounds.x(), bounds.y()); | 1680 NSPoint origin = NSMakePoint(bounds.x(), bounds.y()); |
(...skipping 1833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3507 | 3514 |
3508 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3515 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
3509 // regions that are not draggable. (See ControlRegionView in | 3516 // regions that are not draggable. (See ControlRegionView in |
3510 // native_app_window_cocoa.mm). This requires the render host view to be | 3517 // native_app_window_cocoa.mm). This requires the render host view to be |
3511 // draggable by default. | 3518 // draggable by default. |
3512 - (BOOL)mouseDownCanMoveWindow { | 3519 - (BOOL)mouseDownCanMoveWindow { |
3513 return YES; | 3520 return YES; |
3514 } | 3521 } |
3515 | 3522 |
3516 @end | 3523 @end |
OLD | NEW |