Commit acd68e8c authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

MacViews: Fix DCHECK in CaptivePortalBrowserTest.GoBack

Allow BrowserCompositorMac to transition between different parent UI
layers, if needed.

Bug: 853302
Change-Id: I85596a1fe42c490d770f023c68d9a4093f050dcc
Reviewed-on: https://chromium-review.googlesource.com/1107047Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
Commit-Queue: ccameron <ccameron@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568716}
parent 78467bc5
...@@ -196,7 +196,8 @@ class CONTENT_EXPORT BrowserCompositorMac : public DelegatedFrameHostClient, ...@@ -196,7 +196,8 @@ class CONTENT_EXPORT BrowserCompositorMac : public DelegatedFrameHostClient,
// Weak pointer to the layer supplied and reset via SetParentUiLayer. |this| // Weak pointer to the layer supplied and reset via SetParentUiLayer. |this|
// is an observer of |parent_ui_layer_|, to ensure that |parent_ui_layer_| // is an observer of |parent_ui_layer_|, to ensure that |parent_ui_layer_|
// always be valid when non-null. // always be valid when non-null. The UpdateState function will re-parent
// |root_layer_| to be under |parent_ui_layer_|, if needed.
ui::Layer* parent_ui_layer_ = nullptr; ui::Layer* parent_ui_layer_ = nullptr;
bool render_widget_host_is_hidden_ = true; bool render_widget_host_is_hidden_ = true;
bool ns_view_attached_to_window_ = false; bool ns_view_attached_to_window_ = false;
......
...@@ -407,9 +407,12 @@ void BrowserCompositorMac::TransitionToState(State new_state) { ...@@ -407,9 +407,12 @@ void BrowserCompositorMac::TransitionToState(State new_state) {
// Note that the state enum values represent the other through which // Note that the state enum values represent the other through which
// transitions must be done (see comments in State definition). // transitions must be done (see comments in State definition).
// Transition UseParentLayerCompositor -> HasNoCompositor. // Transition UseParentLayerCompositor -> HasNoCompositor. Note that this
// transition will be made if we are already in UseParentLayerCompositor, but
// with a different parent layer.
if (state_ == UseParentLayerCompositor && if (state_ == UseParentLayerCompositor &&
new_state < UseParentLayerCompositor) { (new_state < UseParentLayerCompositor ||
parent_ui_layer_ != root_layer_->parent())) {
DCHECK(root_layer_->parent()); DCHECK(root_layer_->parent());
root_layer_->parent()->RemoveObserver(this); root_layer_->parent()->RemoveObserver(this);
root_layer_->parent()->Remove(root_layer_.get()); root_layer_->parent()->Remove(root_layer_.get());
...@@ -582,16 +585,16 @@ bool BrowserCompositorMac::ShouldContinueToPauseForFrame() const { ...@@ -582,16 +585,16 @@ bool BrowserCompositorMac::ShouldContinueToPauseForFrame() const {
} }
void BrowserCompositorMac::SetParentUiLayer(ui::Layer* new_parent_ui_layer) { void BrowserCompositorMac::SetParentUiLayer(ui::Layer* new_parent_ui_layer) {
if (new_parent_ui_layer) { if (new_parent_ui_layer)
DCHECK(new_parent_ui_layer->GetCompositor()); DCHECK(new_parent_ui_layer->GetCompositor());
DCHECK(!parent_ui_layer_);
parent_ui_layer_ = new_parent_ui_layer; // Set |parent_ui_layer_| to the new value, which potentially not match the
} else if (parent_ui_layer_) { // value of |root_layer_->parent()|. The call to UpdateState will re-parent
DCHECK(root_layer_->parent()); // |root_layer_|.
DCHECK_EQ(root_layer_->parent(), parent_ui_layer_); DCHECK_EQ(root_layer_->parent(), parent_ui_layer_);
parent_ui_layer_ = nullptr; parent_ui_layer_ = new_parent_ui_layer;
}
UpdateState(); UpdateState();
DCHECK_EQ(root_layer_->parent(), parent_ui_layer_);
} }
bool BrowserCompositorMac::ForceNewSurfaceForTesting() { bool BrowserCompositorMac::ForceNewSurfaceForTesting() {
......
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