Propagate auto-resize viewport values to OOPIF processes
RenderWidgetHostViewChildFrame currently gets its visible viewport size
from the top-level RenderWidgetHostView, which typically comes from the
platform window. However, when the top-level frame has auto-resize
enabled, internally it sets its own visible viewport, and this
information not available to OOPIF children. This causes issues
in particular for extension popups which have window sizes of (0, 0)
and rely on auto-resize to modify the viewport in Blink.
This patch causes the WebContents to store the auto-resize value
reported by the top-level frame and make it available to OOPIF
RenderWidgetHostViews. They, in turn, allow an auto-resize size to
override the windows size when determining their visible viewport.
BUG=726743
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_site_isolation
Review-Url: https://codereview.chromium.org/2914013004
Cr-Commit-Position: refs/heads/master@{#476772}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 626c4c8..cef65a9 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -2787,10 +2787,32 @@
if (render_widget_host != GetRenderViewHost()->GetWidget())
return;
+ auto_resize_size_ = new_size;
+
+ // Out-of-process iframe visible viewport sizes usually come from the
+ // top-level RenderWidgetHostView, but when auto-resize is enabled on the
+ // top frame then that size is used instead.
+ for (FrameTreeNode* node : frame_tree_.Nodes()) {
+ if (node->current_frame_host()->is_local_root()) {
+ RenderWidgetHostImpl* host =
+ node->current_frame_host()->GetRenderWidgetHost();
+ if (host != render_widget_host)
+ host->WasResized();
+ }
+ }
+
if (delegate_)
delegate_->ResizeDueToAutoResize(this, new_size);
}
+gfx::Size WebContentsImpl::GetAutoResizeSize() {
+ return auto_resize_size_;
+}
+
+void WebContentsImpl::ResetAutoResizeSize() {
+ auto_resize_size_ = gfx::Size();
+}
+
WebContents* WebContentsImpl::OpenURL(const OpenURLParams& params) {
if (!delegate_)
return NULL;