Commit 079b27dc authored by W. James MacLean's avatar W. James MacLean Committed by Chromium LUCI CQ

Ensure VisualViewport reset when local mainframe is converted to remote.

This CL ensures that when a local mainframe is converted to a remote one
that the VisualViewport for the new mainframe is reset. This is
important since non-unit PageScaleFactor should only be stored for
local mainframes, otherwise the scale will be innappropriately removed
from event coordinates in out-of-process iframes.

Bug: 1150977
Change-Id: I4dc8cc4ea0c4521a2f999c97607671ff62d4d159
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2629491
Commit-Queue: James MacLean <wjmaclean@chromium.org>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844148}
parent 4043b223
...@@ -499,8 +499,15 @@ double VisualViewport::VisibleHeightCSSPx() const { ...@@ -499,8 +499,15 @@ double VisualViewport::VisibleHeightCSSPx() const {
bool VisualViewport::DidSetScaleOrLocation(float scale, bool VisualViewport::DidSetScaleOrLocation(float scale,
bool is_pinch_gesture_active, bool is_pinch_gesture_active,
const FloatPoint& location) { const FloatPoint& location) {
if (!LocalMainFrame()) if (!LocalMainFrame()) {
is_pinch_gesture_active_ = is_pinch_gesture_active;
// The VisualViewport for a remote mainframe must always be 1.0 or else
// event targeting will fail.
DCHECK(scale == 1.f);
scale_ = scale;
offset_ = ScrollOffset();
return false; return false;
}
bool values_changed = false; bool values_changed = false;
......
...@@ -8843,6 +8843,19 @@ TEST_F(WebFrameSwapTest, SwapMainFrame) { ...@@ -8843,6 +8843,19 @@ TEST_F(WebFrameSwapTest, SwapMainFrame) {
EXPECT_EQ("hello", content); EXPECT_EQ("hello", content);
} }
TEST_F(WebFrameSwapTest, SwapMainFrameWithPageScaleReset) {
WebView()->SetDefaultPageScaleLimits(1, 2);
WebView()->SetPageScaleFactor(1.25);
EXPECT_EQ(1.25, WebView()->PageScaleFactor());
WebRemoteFrame* remote_frame = frame_test_helpers::CreateRemote();
MainFrame()->Swap(remote_frame);
EXPECT_EQ(1.0, WebView()->PageScaleFactor());
// Note: if we were to extend this test to call frame_test_helpers::LoadFrame
// as in WebFrameSwapTest.SwapMainFrame, then an appropriate binding must be
// provided for the AssociatedRemote.
}
TEST_F(WebFrameSwapTest, ValidateSizeOnRemoteToLocalMainFrameSwap) { TEST_F(WebFrameSwapTest, ValidateSizeOnRemoteToLocalMainFrameSwap) {
gfx::Size size(111, 222); gfx::Size size(111, 222);
......
...@@ -333,6 +333,7 @@ void Page::SetMainFrame(Frame* main_frame) { ...@@ -333,6 +333,7 @@ void Page::SetMainFrame(Frame* main_frame) {
main_frame_ = main_frame; main_frame_ = main_frame;
page_scheduler_->SetIsMainFrameLocal(main_frame->IsLocalFrame()); page_scheduler_->SetIsMainFrameLocal(main_frame->IsLocalFrame());
visual_viewport_->Reset();
} }
LocalFrame* Page::DeprecatedLocalMainFrame() const { LocalFrame* Page::DeprecatedLocalMainFrame() const {
......
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