Changeset 247223 in webkit


Ignore:
Timestamp:
Jul 8, 2019 12:03:42 PM (5 years ago)
Author:
Wenson Hsieh
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.

Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r247222 r247223  
     12019-07-08  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iPadOS] Viewport pops while loading sohu.com, xinhuanet.com, and various other websites
     4        https://bugs.webkit.org/show_bug.cgi?id=199575
     5        <rdar://problem/51842220>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Adjusts an existing layout test, and introduces a new test to verify that the shrink-to-fit heuristic is given a
     10        chance to run before document load. See WebKit ChangeLog for more details.
     11
     12        * fast/viewport/ios/shrink-to-fit-content-before-document-load-expected.txt: Added.
     13        * fast/viewport/ios/shrink-to-fit-content-before-document-load.html: Added.
     14        * fast/viewport/ios/shrink-to-fit-content-temporary-overflow.html:
     15
     16        Tweak this layout test to add the temporarily overflowing element after document load.
     17
    1182019-07-08  Wenson Hsieh  <wenson_hsieh@apple.com>
    219
  • trunk/LayoutTests/fast/viewport/ios/shrink-to-fit-content-temporary-overflow.html

    r244849 r247223  
    4949description("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.");
    5050
     51function forceLayoutByScrollingTo(y) {
     52    document.scrollingElement.scrollTo(0, y);
     53    return document.scrollingElement.scrollTop;
     54}
     55
     56addEventListener("DOMContentLoaded", () => {
     57    forceLayoutByScrollingTo(1);
     58    const bar = document.createElement("div");
     59    bar.classList.add("bar");
     60    document.body.appendChild(bar);
     61    forceLayoutByScrollingTo(0);
     62    bar.remove();
     63});
     64
    5165addEventListener("load", async () => {
    5266    if (!window.testRunner)
     
    6377<div id="description"></div>
    6478<div class="square"></div>
    65 <script>
    66 const bar = document.createElement("div");
    67 bar.classList.add("bar");
    68 document.body.appendChild(bar);
    69 document.scrollingElement.scrollTo(0, 1);
    70 document.scrollingElement.scrollTo(0, 0);
    71 document.scrollingElement.scrollTop;
    72 bar.remove();
    73 </script>
    7479</body>
    7580</html>
  • trunk/Source/WebKit/ChangeLog

    r247218 r247223  
     12019-07-08  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iPadOS] Viewport pops while loading sohu.com, xinhuanet.com, and various other websites
     4        https://bugs.webkit.org/show_bug.cgi?id=199575
     5        <rdar://problem/51842220>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Currently, the shrink-to-fit-content heuristic added to scale desktop sites fit within the viewport on iPadOS
     10        only runs during two intervals: after document load, and after page load. On very script-heavy websites, this
     11        may cause a visible jump, as rendering may commence well before the document is finished parsing.
     12
     13        To mitigate this, we move the first opportunity for the shrink-to-fit heuristic from after document, to right
     14        after the page transition has completed (before we unfreeze the layer tree).
     15
     16        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
     17        (WebKit::WebFrameLoaderClient::dispatchDidFinishDocumentLoad):
     18        * WebProcess/WebPage/WebPage.cpp:
     19        (WebKit::WebPage::didCompletePageTransition):
     20        (WebKit::WebPage::didFinishDocumentLoad): Deleted.
     21
     22        Remove this didFinishDocumentLoad hook, which was only used to schedule the shrink-to-fit timer.
     23
     24        * WebProcess/WebPage/WebPage.h:
     25        * WebProcess/WebPage/ios/WebPageIOS.mm:
     26        (WebKit::WebPage::immediatelyShrinkToFitContent):
     27
     28        m_mainFrame might be null after page transition completes, so we need to ensure immediatelyShrinkToFitContent is
     29        robust in this scenario.
     30
    1312019-07-08  Chris Dumez  <cdumez@apple.com>
    232
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp

    r246767 r247223  
    615615    // Notify the UIProcess.
    616616    webPage->send(Messages::WebPageProxy::DidFinishDocumentLoadForFrame(m_frame->frameID(), navigationID, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
    617 
    618     webPage->didFinishDocumentLoad(*m_frame);
    619617}
    620618
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r247192 r247223  
    32713271void WebPage::didCompletePageTransition()
    32723272{
     3273#if ENABLE(VIEWPORT_RESIZING)
     3274    if (immediatelyShrinkToFitContent())
     3275        viewportConfigurationChanged(ZoomToInitialScale::Yes);
     3276#endif
     3277
    32733278    unfreezeLayerTree(LayerTreeFreezeReason::PageTransition);
    32743279
     
    57965801}
    57975802
    5798 void WebPage::didFinishDocumentLoad(WebFrame& frame)
    5799 {
    5800     if (!frame.isMainFrame())
    5801         return;
    5802 
    5803 #if ENABLE(VIEWPORT_RESIZING)
    5804     scheduleShrinkToFitContent();
    5805 #endif
    5806 }
    5807 
    58085803void WebPage::didFinishLoad(WebFrame& frame)
    58095804{
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r247161 r247223  
    360360    void willReplaceMultipartContent(const WebFrame&);
    361361    void didReplaceMultipartContent(const WebFrame&);
    362     void didFinishDocumentLoad(WebFrame&);
    363362    void didFinishLoad(WebFrame&);
    364363    void show();
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r247200 r247223  
    33213321        return false;
    33223322
     3323    if (!m_mainFrame)
     3324        return false;
     3325
    33233326    if (!m_page->settings().allowViewportShrinkToFitContent())
    33243327        return false;
Note: See TracChangeset for help on using the changeset viewer.