Commit 6f4d713f authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

MacViews: Re-enable single ui::Compositor view

Decide at initialization whether or not a RenderWidgetHostViewMac will
be displayed in its NSView or through a ui::Compositor.

This fixes a bug whereby some windows (DevTools is a good example)
would, through the vagaries of initialization order, draw a single
frame to the NSView, which would then never go away, and cover up the
ui::Compositor's version of the content (which was then updating
correctly, though not visible).

Bug: 840173, 845807
Change-Id: If051d249956b10c9e56450ed1f58b9048d331562
Reviewed-on: https://chromium-review.googlesource.com/1070764
Commit-Queue: ccameron <ccameron@chromium.org>
Reviewed-by: default avatarSidney San Martín <sdy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561717}
parent 8803f4e6
...@@ -471,9 +471,9 @@ class CONTENT_EXPORT RenderWidgetHostViewMac ...@@ -471,9 +471,9 @@ class CONTENT_EXPORT RenderWidgetHostViewMac
// State tracked by Show/Hide/IsShowing. // State tracked by Show/Hide/IsShowing.
bool is_visible_ = false; bool is_visible_ = false;
// Set to true if |this| has ever been displayed via a parent ui::Layer (in // Set to true if |this| is only to be displayed via a parent ui::Layer (in
// which case its NSView will only ever be used for input, not display). // which case its NSView will only ever be used for input, not display).
bool display_only_using_parent_ui_layer_ = false; bool display_using_parent_ui_layer_ = false;
// The bounds of the view in its NSWindow's coordinate system (with origin // The bounds of the view in its NSWindow's coordinate system (with origin
// in the upper-left). // in the upper-left).
......
...@@ -112,7 +112,7 @@ NSView* RenderWidgetHostViewMac::AcceleratedWidgetGetNSView() const { ...@@ -112,7 +112,7 @@ NSView* RenderWidgetHostViewMac::AcceleratedWidgetGetNSView() const {
void RenderWidgetHostViewMac::AcceleratedWidgetCALayerParamsUpdated() { void RenderWidgetHostViewMac::AcceleratedWidgetCALayerParamsUpdated() {
// This may be called when we do not have a parent ui::Layer (e.g, when tab // This may be called when we do not have a parent ui::Layer (e.g, when tab
// capturing a background layer). Do not update the NSView in this case. // capturing a background layer). Do not update the NSView in this case.
if (display_only_using_parent_ui_layer_) if (display_using_parent_ui_layer_)
return; return;
// Set the background color for the root layer from the frame that just // Set the background color for the root layer from the frame that just
...@@ -146,6 +146,10 @@ RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget, ...@@ -146,6 +146,10 @@ RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget,
ui::GestureProviderConfigType::CURRENT_PLATFORM), ui::GestureProviderConfigType::CURRENT_PLATFORM),
this), this),
weak_factory_(this) { weak_factory_(this) {
// All WebContents in MacViews browser will be directly embedded in an
// external ui::Compositor. Popup windows are the one exception.
display_using_parent_ui_layer_ = !features::IsViewsBrowserCocoa();
// The NSView is on the other side of |ns_view_bridge_|. // The NSView is on the other side of |ns_view_bridge_|.
ns_view_bridge_ = RenderWidgetHostNSViewBridge::Create(this); ns_view_bridge_ = RenderWidgetHostNSViewBridge::Create(this);
...@@ -204,8 +208,8 @@ RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { ...@@ -204,8 +208,8 @@ RenderWidgetHostViewMac::~RenderWidgetHostViewMac() {
} }
void RenderWidgetHostViewMac::SetParentUiLayer(ui::Layer* parent_ui_layer) { void RenderWidgetHostViewMac::SetParentUiLayer(ui::Layer* parent_ui_layer) {
if (parent_ui_layer) if (!display_using_parent_ui_layer_)
display_only_using_parent_ui_layer_ = true; return;
if (browser_compositor_) if (browser_compositor_)
browser_compositor_->SetParentUiLayer(parent_ui_layer); browser_compositor_->SetParentUiLayer(parent_ui_layer);
} }
...@@ -256,7 +260,9 @@ void RenderWidgetHostViewMac::InitAsChild( ...@@ -256,7 +260,9 @@ void RenderWidgetHostViewMac::InitAsChild(
void RenderWidgetHostViewMac::InitAsPopup( void RenderWidgetHostViewMac::InitAsPopup(
RenderWidgetHostView* parent_host_view, RenderWidgetHostView* parent_host_view,
const gfx::Rect& pos) { const gfx::Rect& pos) {
// This path is used by the time/date picker. // This path is used by the time/date picker. It does not have a parent
// WebContentsViewCocoa, and so its NSView must display its content.
display_using_parent_ui_layer_ = false;
ns_view_bridge_->InitAsPopup(pos, popup_type_); ns_view_bridge_->InitAsPopup(pos, popup_type_);
} }
...@@ -939,7 +945,7 @@ bool RenderWidgetHostViewMac::GetCachedFirstRectForCharacterRange( ...@@ -939,7 +945,7 @@ bool RenderWidgetHostViewMac::GetCachedFirstRectForCharacterRange(
bool RenderWidgetHostViewMac::ShouldContinueToPauseForFrame() { bool RenderWidgetHostViewMac::ShouldContinueToPauseForFrame() {
// Only pause for frames when drawing through a separate ui::Compositor. // Only pause for frames when drawing through a separate ui::Compositor.
if (display_only_using_parent_ui_layer_) if (display_using_parent_ui_layer_)
return false; return false;
return browser_compositor_->ShouldContinueToPauseForFrame(); return browser_compositor_->ShouldContinueToPauseForFrame();
...@@ -995,7 +1001,7 @@ bool RenderWidgetHostViewMac::RequestRepaintForTesting() { ...@@ -995,7 +1001,7 @@ bool RenderWidgetHostViewMac::RequestRepaintForTesting() {
} }
gfx::Vector2d RenderWidgetHostViewMac::GetOffsetFromRootSurface() { gfx::Vector2d RenderWidgetHostViewMac::GetOffsetFromRootSurface() {
if (display_only_using_parent_ui_layer_) if (display_using_parent_ui_layer_)
return view_bounds_in_window_dip_.OffsetFromOrigin(); return view_bounds_in_window_dip_.OffsetFromOrigin();
return gfx::Vector2d(); return gfx::Vector2d();
} }
...@@ -1242,7 +1248,7 @@ base::Optional<SkColor> RenderWidgetHostViewMac::GetBackgroundColor() const { ...@@ -1242,7 +1248,7 @@ base::Optional<SkColor> RenderWidgetHostViewMac::GetBackgroundColor() const {
void RenderWidgetHostViewMac::SetBackgroundLayerColor(SkColor color) { void RenderWidgetHostViewMac::SetBackgroundLayerColor(SkColor color) {
// If displaying via a ui::Layer, leave the background color of the NSView // If displaying via a ui::Layer, leave the background color of the NSView
// as transparent (it is to be used for input handling only). // as transparent (it is to be used for input handling only).
if (display_only_using_parent_ui_layer_) if (display_using_parent_ui_layer_)
return; return;
if (color == background_layer_color_) if (color == background_layer_color_)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment