top-chrome slide: set shown ratio for main frame widget only
Opening a drop-down menu in a webpage will create a new
RenderWidget with a new LayerTreeHostImpl, whose value
of the top_controls_shown_ratio_ (initialized to 0) will
be pushed to the browser when a new compositor frame is
generated. This will cause top-chrome to hide briefly
on opening the menu which will result in closing the
menu immediately.
This CL fixes the issue by allowing only the main frame
widget to set the shown ratio.
BUG=891471
TEST=Manual, added a new browser test.
Change-Id: I8ead7f903d56e68523a7654abc21aa6e5ca7b690
Reviewed-on: https://chromium-review.googlesource.com/c/1258348
Reviewed-by: David Bokan <[email protected]>
Reviewed-by: Scott Violet <[email protected]>
Commit-Queue: Ahmed Fakhry <[email protected]>
Cr-Commit-Position: refs/heads/master@{#597146}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 9cb87f79..a0f8530 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -2143,9 +2143,17 @@
return last_committed_source_id_;
}
-void WebContentsImpl::SetTopControlsShownRatio(float ratio) {
- if (delegate_)
- delegate_->SetTopControlsShownRatio(this, ratio);
+void WebContentsImpl::SetTopControlsShownRatio(
+ RenderWidgetHostImpl* render_widget_host,
+ float ratio) {
+ if (!delegate_)
+ return;
+
+ RenderFrameHostImpl* rfh = GetMainFrame();
+ if (!rfh || render_widget_host != rfh->GetRenderWidgetHost())
+ return;
+
+ delegate_->SetTopControlsShownRatio(this, ratio);
}
bool WebContentsImpl::DoBrowserControlsShrinkRendererSize() const {