0

Independently-zoomed, non-main-frame RFHs should ignore pending navigation entries

In WebContentsImpl::GetPendingZoomLevel, it's possible for the
RenderWidgetHost parameter to correspond to an independently
zoomed RenderFrameHost that isn't for a main frame. An example is
when kPdfOopif is enabled.

In theses cases GetPendingZoomLevel should not look at the
pending entry in the RenderFrameHost's NavigationController, as
it will be for the main frame, which is by definition outside
the independently zoomed subtree in this case.

This CL modifies GetPendingZoomLevel so that, if the target
RenderFrameHost isn't a main frame, it ignores any pending
entries on the associated navigation controller.

Bug: 404286904
Change-Id: Ia5dca4599ceed8c4b5647c9c2bb50b52966d5162
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6376764
Commit-Queue: James Maclean <wjmaclean@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1436297}
This commit is contained in:
W. James MacLean
2025-03-21 14:34:32 -07:00
committed by Chromium LUCI CQ
parent 491395a30a
commit 1050cd84dd

@ -8789,12 +8789,20 @@ double WebContentsImpl::GetPendingZoomLevel(RenderWidgetHostImpl* rwh) {
// and All/FencedFrameAutomaticBeaconBrowserTest.MessageExceedsLengthLimit/
// fencedframe.
url = rfh->GetLastCommittedURL();
} else {
} else if (!rfh->GetParent()) {
// Only use the pending entry if `rfh` is a main frame, otherwise the
// resulting url is from outside the independently zoomed subtree, and
// may result in the wrong zoom level.
NavigationEntry* pending_entry = rfh->GetController().GetPendingEntry();
if (!pending_entry) {
return HostZoomMap::GetZoomLevel(this, rfh->GetGlobalId());
}
url = pending_entry->GetURL();
} else {
// In this case `rfh` is for an independently-zoomed subframe. Call
// GetZoomLevel(WebContents*, RenderFrameHost*) in case `rfh` uses temporary
// zoom.
return HostZoomMap::GetZoomLevel(this, rfh->GetGlobalId());
}
#if BUILDFLAG(IS_ANDROID)
return HostZoomMapForRenderFrameHost(rfh)