diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-06-27 11:18:24 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-07-03 09:38:30 +0000 |
commit | d94af01c90575348c4e81a418257f254b6f8d225 (patch) | |
tree | 77a26669b33eaa4d46b88b07e17dacc61eba6001 /chromium/third_party/blink/renderer/core/exported | |
parent | 5d87695f37678f96492b258bbab36486c59866b4 (diff) | |
download | qtwebengine-chromium-d94af01c90575348c4e81a418257f254b6f8d225.tar.gz |
BASELINE: Update Chromium to 75.0.3770.116
Change-Id: Ifcd5227841577e8ce81a1b7a54c56caba4d85e02
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'chromium/third_party/blink/renderer/core/exported')
3 files changed, 144 insertions, 3 deletions
diff --git a/chromium/third_party/blink/renderer/core/exported/web_frame_test.cc b/chromium/third_party/blink/renderer/core/exported/web_frame_test.cc index a6969cca501..c45adc0ced8 100644 --- a/chromium/third_party/blink/renderer/core/exported/web_frame_test.cc +++ b/chromium/third_party/blink/renderer/core/exported/web_frame_test.cc @@ -122,6 +122,7 @@ #include "third_party/blink/renderer/core/fullscreen/fullscreen.h" #include "third_party/blink/renderer/core/geometry/dom_rect.h" #include "third_party/blink/renderer/core/html/forms/html_form_element.h" +#include "third_party/blink/renderer/core/html/forms/html_input_element.h" #include "third_party/blink/renderer/core/html/html_body_element.h" #include "third_party/blink/renderer/core/html/html_iframe_element.h" #include "third_party/blink/renderer/core/html/image_document.h" @@ -3390,6 +3391,46 @@ TEST_F(WebFrameTest, CanOverrideScaleLimits) { EXPECT_EQ(2.0f, web_view_helper.GetWebView()->MaximumPageScaleFactor()); } +// Test that setting the "ignore viewport tag scale limits" override remembers +// the current defaults and restores them when the override is removed. +TEST_F(WebFrameTest, RestoreOriginalDefaultScaleLimits) { + RegisterMockedHttpURLLoad("simple_div.html"); + + FixedLayoutTestWebViewClient client; + client.screen_info_.device_scale_factor = 1; + int viewport_width = 640; + int viewport_height = 480; + + frame_test_helpers::WebViewHelper web_view_helper; + web_view_helper.InitializeAndLoad(base_url_ + "simple_div.html", nullptr, + &client, nullptr, ConfigureAndroid); + web_view_helper.Resize(WebSize(viewport_width, viewport_height)); + web_view_helper.GetWebView()->SetDefaultPageScaleLimits(0.25f, 5); + + const float minimum_scale_factor = + web_view_helper.GetWebView()->MinimumPageScaleFactor(); + + web_view_helper.GetWebView()->SetInitialPageScaleOverride(2.0f); + + // Removing the override when none is set shouldn't change the initial scale. + web_view_helper.GetWebView()->SetIgnoreViewportTagScaleLimits(false); + UpdateAllLifecyclePhases(web_view_helper.GetWebView()); + EXPECT_EQ(2.0f, web_view_helper.GetWebView()->PageScaleFactor()); + + // Setting the override when will change the initial scale. + web_view_helper.GetWebView()->SetIgnoreViewportTagScaleLimits(true); + web_view_helper.GetWebView()->ResetScaleStateImmediately(); + UpdateAllLifecyclePhases(web_view_helper.GetWebView()); + EXPECT_EQ(minimum_scale_factor, + web_view_helper.GetWebView()->PageScaleFactor()); + + // Disable the override, we should now use the minimum scale factor + web_view_helper.GetWebView()->SetIgnoreViewportTagScaleLimits(false); + web_view_helper.GetWebView()->ResetScaleStateImmediately(); + UpdateAllLifecyclePhases(web_view_helper.GetWebView()); + EXPECT_EQ(2.0f, web_view_helper.GetWebView()->PageScaleFactor()); +} + // Android doesn't have scrollbars on the main LocalFrameView #if defined(OS_ANDROID) TEST_F(WebFrameTest, DISABLED_updateOverlayScrollbarLayers) @@ -11419,6 +11460,40 @@ class WebFrameSimTest : public SimTest { } }; +// This test ensures that setting the "Force Ignore Zoom" accessibility setting +// also causes us to override the initial scale set by the page so that we load +// fully zoomed out. Since we're overriding the minimum-scale, we're making the +// layout viewport larger. Since |position: fixed| elements are sized based on +// the layout viewport size, they may be cut off when the page first loads. +TEST_F(WebFrameSimTest, ForceIgnoreZoomShouldOverrideInitialScale) { + UseAndroidSettings(); + WebView().MainFrameWidget()->Resize(WebSize(500, 300)); + WebView().SetIgnoreViewportTagScaleLimits(true); + + SimRequest r("https://example.com/test.html", "text/html"); + LoadURL("https://example.com/test.html"); + r.Complete(R"HTML( + <!DOCTYPE html> + <meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1"> + <style> + body, html { + width: 100%; + height: 100%; + margin: 0; + } + #wide { + width: 1000px; + height: 10px; + } + </style> + <div id="wide"></div> + )HTML"); + + Compositor().BeginFrame(); + + EXPECT_EQ(0.5f, WebView().PageScaleFactor()); +} + TEST_F(WebFrameSimTest, HitTestWithIgnoreClippingAtNegativeOffset) { WebView().MainFrameWidget()->Resize(WebSize(500, 300)); WebView().GetPage()->GetSettings().SetTextAutosizingEnabled(false); @@ -11939,6 +12014,58 @@ TEST_F(WebFrameSimTest, ScrollFocusedIntoViewClipped) { EXPECT_GT(clip->scrollTop(), 0); } +// This test ensures that we scroll to the correct scale when the focused +// element has a selection rather than a carret. +TEST_F(WebFrameSimTest, ScrollFocusedSelectionIntoView) { + UseAndroidSettings(); + WebView().MainFrameWidget()->Resize(WebSize(400, 600)); + WebView().EnableFakePageScaleAnimationForTesting(true); + WebView().GetPage()->GetSettings().SetTextAutosizingEnabled(false); + + SimRequest request("https://example.com/test.html", "text/html"); + LoadURL("https://example.com/test.html"); + request.Complete(R"HTML( + <!DOCTYPE html> + <style> + ::-webkit-scrollbar { + width: 0px; + height: 0px; + } + body, html { + margin: 0px; + width: 100%; + height: 100%; + } + input { + padding: 0; + width: 100px; + height: 20px; + } + </style> + <input type="text" id="target" value="test"> + )HTML"); + + Compositor().BeginFrame(); + WebView().AdvanceFocus(false); + + HTMLInputElement* input = + ToHTMLInputElement(GetDocument().getElementById("target")); + input->select(); + + // Simulate the keyboard being shown and resizing the widget. Cause a scroll + // into view after. + ASSERT_EQ(WebView().FakePageScaleAnimationPageScaleForTesting(), 0.f); + WebFrameWidget* widget = WebView().MainFrameImpl()->FrameWidgetImpl(); + widget->ScrollFocusedEditableElementIntoView(); + + // Make sure zoomed in but only up to a legible scale. The bounds are + // arbitrary and fuzzy since we don't specifically care to constrain the + // amount of zooming (that should be tested elsewhere), we just care that it + // zooms but not off to infinity. + EXPECT_GT(WebView().FakePageScaleAnimationPageScaleForTesting(), .75f); + EXPECT_LT(WebView().FakePageScaleAnimationPageScaleForTesting(), 2.f); +} + TEST_F(WebFrameSimTest, DoubleTapZoomWhileScrolled) { UseAndroidSettings(); WebView().MainFrameWidget()->Resize(WebSize(490, 500)); diff --git a/chromium/third_party/blink/renderer/core/exported/web_view_impl.cc b/chromium/third_party/blink/renderer/core/exported/web_view_impl.cc index fa2150289b4..41e11e56e95 100644 --- a/chromium/third_party/blink/renderer/core/exported/web_view_impl.cc +++ b/chromium/third_party/blink/renderer/core/exported/web_view_impl.cc @@ -2156,7 +2156,7 @@ bool WebViewImpl::ScrollFocusedEditableElementIntoView() { element->GetDocument() .GetFrame() ->Selection() - .AbsoluteCaretBounds())), + .ComputeRectToScroll(kDoNotRevealExtent))), ShouldZoomToLegibleScale(*element)); return true; @@ -2514,16 +2514,26 @@ void WebViewImpl::SetMaximumLegibleScale(float maximum_legible_scale) { } void WebViewImpl::SetIgnoreViewportTagScaleLimits(bool ignore) { + // This method should be idempotent. + if (ignore == pre_override_default_constraints_.has_value()) + return; + PageScaleConstraints constraints = GetPageScaleConstraintsSet().UserAgentConstraints(); if (ignore) { + DCHECK(!pre_override_default_constraints_); + pre_override_default_constraints_.emplace(constraints); + constraints.minimum_scale = GetPageScaleConstraintsSet().DefaultConstraints().minimum_scale; constraints.maximum_scale = GetPageScaleConstraintsSet().DefaultConstraints().maximum_scale; + constraints.initial_scale = + GetPageScaleConstraintsSet().DefaultConstraints().minimum_scale; } else { - constraints.minimum_scale = -1; - constraints.maximum_scale = -1; + DCHECK(pre_override_default_constraints_); + constraints = pre_override_default_constraints_.value(); + pre_override_default_constraints_.reset(); } GetPage()->SetUserAgentPageScaleConstraints(constraints); } diff --git a/chromium/third_party/blink/renderer/core/exported/web_view_impl.h b/chromium/third_party/blink/renderer/core/exported/web_view_impl.h index aaa17462ee6..64a22db62db 100644 --- a/chromium/third_party/blink/renderer/core/exported/web_view_impl.h +++ b/chromium/third_party/blink/renderer/core/exported/web_view_impl.h @@ -691,6 +691,10 @@ class CORE_EXPORT WebViewImpl final : public WebView, FloatSize elastic_overscroll_; + // When overriding the default page scale constraints, store the original so + // we can revert to them when the override is removed. + base::Optional<PageScaleConstraints> pre_override_default_constraints_; + Persistent<EventListener> popup_mouse_wheel_event_listener_; // The local root whose document has |popup_mouse_wheel_event_listener_| |