Plumb TextAutosizer RemotePageInfo to OOPIF renderers.
This CL makes page-level state from Blink's TextAutosizer available to
remote-frame renderers by plumbing it through the browser process and
sending it back out using a PageMessage.
While this CL does not fix TextAutosizing in OOPIF renderers, it makes
the necessary information available in those renderers.
Bug: 393285
Change-Id: I1bc04fb503821e1eeebfc8f2aa919007ed35a279
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1627930
Commit-Queue: James MacLean <[email protected]>
Reviewed-by: danakj <[email protected]>
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: Alex Moshchuk <[email protected]>
Cr-Commit-Position: refs/heads/master@{#665951}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index f88cff5..bad90d7 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -588,6 +588,7 @@
#endif // !defined(OS_ANDROID)
is_overlay_content_(false),
showing_context_menu_(false),
+ text_autosizer_page_info_({0, 0, 1.f}),
had_inner_webcontents_(false),
loading_weak_factory_(this),
weak_factory_(this) {
@@ -864,6 +865,9 @@
IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits)
IPC_MESSAGE_HANDLER(ViewHostMsg_PageScaleFactorChanged,
OnPageScaleFactorChanged)
+ IPC_MESSAGE_HANDLER(
+ ViewHostMsg_NotifyTextAutosizerPageInfoChangedInLocalMainFrame,
+ OnTextAutosizerPageInfoChanged)
#if BUILDFLAG(ENABLE_PLUGINS)
IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission,
OnRequestPpapiBrokerPermission)
@@ -4775,6 +4779,18 @@
observer.OnPageScaleFactorChanged(page_scale_factor);
}
+void WebContentsImpl::OnTextAutosizerPageInfoChanged(
+ RenderViewHostImpl* source,
+ const blink::WebTextAutosizerPageInfo& page_info) {
+ // Keep a copy of |page_info| in case we create a new RenderView before
+ // the next update.
+ text_autosizer_page_info_ = page_info;
+ frame_tree_.root()->render_manager()->SendPageMessage(
+ new PageMsg_UpdateTextAutosizerPageInfoForRemoteMainFrames(
+ MSG_ROUTING_NONE, page_info),
+ source->GetSiteInstance());
+}
+
void WebContentsImpl::EnumerateDirectory(
RenderFrameHost* render_frame_host,
std::unique_ptr<FileSelectListener> listener,
@@ -6412,6 +6428,15 @@
created_with_opener_)) {
return false;
}
+ // Set the TextAutosizer state from the main frame's renderer on the new view,
+ // but only if it's not for the main frame. Main frame renderers should create
+ // this state themselves from up-to-date values, so we shouldn't override it
+ // with the cached values.
+ if (!render_view_host->GetMainFrame()) {
+ render_view_host->Send(
+ new PageMsg_UpdateTextAutosizerPageInfoForRemoteMainFrames(
+ render_view_host->GetRoutingID(), text_autosizer_page_info_));
+ }
if (proxy_routing_id == MSG_ROUTING_NONE && node_.outer_web_contents())
ReattachToOuterWebContentsFrame();