- Revision
- 247223
- Author
- wenson_hs...@apple.com
- Date
- 2019-07-08 12:03:42 -0700 (Mon, 08 Jul 2019)
Log Message
[iPadOS] Viewport pops while loading sohu.com, xinhuanet.com, and various other websites
https://bugs.webkit.org/show_bug.cgi?id=199575
<rdar://problem/51842220>
Reviewed by Simon Fraser.
Source/WebKit:
Currently, the shrink-to-fit-content heuristic added to scale desktop sites fit within the viewport on iPadOS
only runs during two intervals: after document load, and after page load. On very script-heavy websites, this
may cause a visible jump, as rendering may commence well before the document is finished parsing.
To mitigate this, we move the first opportunity for the shrink-to-fit heuristic from after document, to right
after the page transition has completed (before we unfreeze the layer tree).
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDidFinishDocumentLoad):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::didCompletePageTransition):
(WebKit::WebPage::didFinishDocumentLoad): Deleted.
Remove this didFinishDocumentLoad hook, which was only used to schedule the shrink-to-fit timer.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::immediatelyShrinkToFitContent):
m_mainFrame might be null after page transition completes, so we need to ensure immediatelyShrinkToFitContent is
robust in this scenario.
LayoutTests:
Adjusts an existing layout test, and introduces a new test to verify that the shrink-to-fit heuristic is given a
chance to run before document load. See WebKit ChangeLog for more details.
* fast/viewport/ios/shrink-to-fit-content-before-document-load-expected.txt: Added.
* fast/viewport/ios/shrink-to-fit-content-before-document-load.html: Added.
* fast/viewport/ios/shrink-to-fit-content-temporary-overflow.html:
Tweak this layout test to add the temporarily overflowing element after document load.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (247222 => 247223)
--- trunk/LayoutTests/ChangeLog 2019-07-08 18:59:49 UTC (rev 247222)
+++ trunk/LayoutTests/ChangeLog 2019-07-08 19:03:42 UTC (rev 247223)
@@ -1,5 +1,22 @@
2019-07-08 Wenson Hsieh <wenson_hs...@apple.com>
+ [iPadOS] Viewport pops while loading sohu.com, xinhuanet.com, and various other websites
+ https://bugs.webkit.org/show_bug.cgi?id=199575
+ <rdar://problem/51842220>
+
+ Reviewed by Simon Fraser.
+
+ Adjusts an existing layout test, and introduces a new test to verify that the shrink-to-fit heuristic is given a
+ chance to run before document load. See WebKit ChangeLog for more details.
+
+ * fast/viewport/ios/shrink-to-fit-content-before-document-load-expected.txt: Added.
+ * fast/viewport/ios/shrink-to-fit-content-before-document-load.html: Added.
+ * fast/viewport/ios/shrink-to-fit-content-temporary-overflow.html:
+
+ Tweak this layout test to add the temporarily overflowing element after document load.
+
+2019-07-08 Wenson Hsieh <wenson_hs...@apple.com>
+
Unable to paste from Notes into Excel 365 spreadsheet
https://bugs.webkit.org/show_bug.cgi?id=199565
<rdar://problem/43615497>
Added: trunk/LayoutTests/fast/viewport/ios/shrink-to-fit-content-before-document-load-expected.txt (0 => 247223)
--- trunk/LayoutTests/fast/viewport/ios/shrink-to-fit-content-before-document-load-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/viewport/ios/shrink-to-fit-content-before-document-load-expected.txt 2019-07-08 19:03:42 UTC (rev 247223)
@@ -0,0 +1,11 @@
+Verifies that the shrink-to-fit heuristic is given a chance to run before document load finishes. This test requires WebKitTestRunner.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS innerWidth is 1280
+PASS visualViewport.scale.toFixed(2) is (screen.width / 1280).toFixed(2)
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/viewport/ios/shrink-to-fit-content-before-document-load.html (0 => 247223)
--- trunk/LayoutTests/fast/viewport/ios/shrink-to-fit-content-before-document-load.html (rev 0)
+++ trunk/LayoutTests/fast/viewport/ios/shrink-to-fit-content-before-document-load.html 2019-07-08 19:03:42 UTC (rev 247223)
@@ -0,0 +1,38 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ shouldIgnoreMetaViewport=true ] -->
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<style>
+body, html {
+ margin: 0;
+ width: 100%;
+ height: 100%;
+}
+
+#bar {
+ width: 1280px;
+ height: 100px;
+ background: linear-gradient(to right, red 0%, green 50%, blue 100%);
+}
+</style>
+<script src=""
+<script src=""
+<script>
+description("Verifies that the shrink-to-fit heuristic is given a chance to run before document load finishes. This test requires WebKitTestRunner.");
+
+addEventListener("DOMContentLoaded", () => {
+ shouldBe("innerWidth", "1280");
+ shouldBe("visualViewport.scale.toFixed(2)", "(screen.width / 1280).toFixed(2)");
+});
+</script>
+</head>
+<body>
+<div id="bar"></div>
+<div id="description"></div>
+<div class="square"></div>
+<script>
+document.scrollingElement.scrollTo(0, 1);
+document.scrollingElement.scrollTop;
+</script>
+</body>
+</html>
Modified: trunk/LayoutTests/fast/viewport/ios/shrink-to-fit-content-temporary-overflow.html (247222 => 247223)
--- trunk/LayoutTests/fast/viewport/ios/shrink-to-fit-content-temporary-overflow.html 2019-07-08 18:59:49 UTC (rev 247222)
+++ trunk/LayoutTests/fast/viewport/ios/shrink-to-fit-content-temporary-overflow.html 2019-07-08 19:03:42 UTC (rev 247223)
@@ -48,6 +48,20 @@
description("This test verifies that a temporary change in content width does not cause the viewport width to permanently expand to try and accomodate the content. To test manually, load the page and check that the box below reads 'PASS'. This test is only intended to run on devices with less than 1200px screen width.");
+function forceLayoutByScrollingTo(y) {
+ document.scrollingElement.scrollTo(0, y);
+ return document.scrollingElement.scrollTop;
+}
+
+addEventListener("DOMContentLoaded", () => {
+ forceLayoutByScrollingTo(1);
+ const bar = document.createElement("div");
+ bar.classList.add("bar");
+ document.body.appendChild(bar);
+ forceLayoutByScrollingTo(0);
+ bar.remove();
+});
+
addEventListener("load", async () => {
if (!window.testRunner)
return;
@@ -62,14 +76,5 @@
<body>
<div id="description"></div>
<div class="square"></div>
-<script>
-const bar = document.createElement("div");
-bar.classList.add("bar");
-document.body.appendChild(bar);
-document.scrollingElement.scrollTo(0, 1);
-document.scrollingElement.scrollTo(0, 0);
-document.scrollingElement.scrollTop;
-bar.remove();
-</script>
</body>
</html>
Modified: trunk/Source/WebKit/ChangeLog (247222 => 247223)
--- trunk/Source/WebKit/ChangeLog 2019-07-08 18:59:49 UTC (rev 247222)
+++ trunk/Source/WebKit/ChangeLog 2019-07-08 19:03:42 UTC (rev 247223)
@@ -1,3 +1,33 @@
+2019-07-08 Wenson Hsieh <wenson_hs...@apple.com>
+
+ [iPadOS] Viewport pops while loading sohu.com, xinhuanet.com, and various other websites
+ https://bugs.webkit.org/show_bug.cgi?id=199575
+ <rdar://problem/51842220>
+
+ Reviewed by Simon Fraser.
+
+ Currently, the shrink-to-fit-content heuristic added to scale desktop sites fit within the viewport on iPadOS
+ only runs during two intervals: after document load, and after page load. On very script-heavy websites, this
+ may cause a visible jump, as rendering may commence well before the document is finished parsing.
+
+ To mitigate this, we move the first opportunity for the shrink-to-fit heuristic from after document, to right
+ after the page transition has completed (before we unfreeze the layer tree).
+
+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+ (WebKit::WebFrameLoaderClient::dispatchDidFinishDocumentLoad):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::didCompletePageTransition):
+ (WebKit::WebPage::didFinishDocumentLoad): Deleted.
+
+ Remove this didFinishDocumentLoad hook, which was only used to schedule the shrink-to-fit timer.
+
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::immediatelyShrinkToFitContent):
+
+ m_mainFrame might be null after page transition completes, so we need to ensure immediatelyShrinkToFitContent is
+ robust in this scenario.
+
2019-07-08 Chris Dumez <cdu...@apple.com>
Add threading assertion to WTF::CompletionHandler
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (247222 => 247223)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp 2019-07-08 18:59:49 UTC (rev 247222)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp 2019-07-08 19:03:42 UTC (rev 247223)
@@ -614,8 +614,6 @@
// Notify the UIProcess.
webPage->send(Messages::WebPageProxy::DidFinishDocumentLoadForFrame(m_frame->frameID(), navigationID, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
-
- webPage->didFinishDocumentLoad(*m_frame);
}
void WebFrameLoaderClient::dispatchDidFinishLoad()
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (247222 => 247223)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2019-07-08 18:59:49 UTC (rev 247222)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2019-07-08 19:03:42 UTC (rev 247223)
@@ -3270,6 +3270,11 @@
void WebPage::didCompletePageTransition()
{
+#if ENABLE(VIEWPORT_RESIZING)
+ if (immediatelyShrinkToFitContent())
+ viewportConfigurationChanged(ZoomToInitialScale::Yes);
+#endif
+
unfreezeLayerTree(LayerTreeFreezeReason::PageTransition);
RELEASE_LOG_IF_ALLOWED("%p - WebPage - Did complete page transition", this);
@@ -5795,16 +5800,6 @@
updateMockAccessibilityElementAfterCommittingLoad();
}
-void WebPage::didFinishDocumentLoad(WebFrame& frame)
-{
- if (!frame.isMainFrame())
- return;
-
-#if ENABLE(VIEWPORT_RESIZING)
- scheduleShrinkToFitContent();
-#endif
-}
-
void WebPage::didFinishLoad(WebFrame& frame)
{
if (!frame.isMainFrame())
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (247222 => 247223)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2019-07-08 18:59:49 UTC (rev 247222)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2019-07-08 19:03:42 UTC (rev 247223)
@@ -359,7 +359,6 @@
void didCommitLoad(WebFrame*);
void willReplaceMultipartContent(const WebFrame&);
void didReplaceMultipartContent(const WebFrame&);
- void didFinishDocumentLoad(WebFrame&);
void didFinishLoad(WebFrame&);
void show();
String userAgent(const URL&) const;
Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (247222 => 247223)
--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2019-07-08 18:59:49 UTC (rev 247222)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2019-07-08 19:03:42 UTC (rev 247223)
@@ -3320,6 +3320,9 @@
if (m_isClosed)
return false;
+ if (!m_mainFrame)
+ return false;
+
if (!m_page->settings().allowViewportShrinkToFitContent())
return false;