Changeset 245561 in webkit


Ignore:
Timestamp:
May 20, 2019, 10:01:54 PM (6 years ago)
Author:
Wenson Hsieh
Message:

[iOS] Layout viewport size on google.com increases after rotating to landscape and back
https://bugs.webkit.org/show_bug.cgi?id=198062
<rdar://problem/50547895>

Reviewed by Maciej Stachowiak.

Source/WebKit:

During an animated resize (e.g. when rotating the device on iOS), we currently immediately trigger the new
shrink-to-fit content size heuristic in the middle of dynamicViewportSizeUpdate, after the new view layout size
has been applied to the viewport configuration but before we've issued a resize event to the page.

Thus, on pages that use listen to the resize event and adjust their content accordingly to fit within the new
layout width, we prematurely declare that the page has horizontally overflowed, and try to lay out at a larger
width and scale down. This causes the page to unnecessarily shrink after rotating to landscale orientation and
back.

To fix this, we simply move the call to shrink-to-fit-content to the end of the dynamic viewport size update,
such that the page has had a chance to adjust to the new layout size.

Test: fast/events/ios/rotation/do-not-shrink-to-fit-content-after-rotation.html

  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::dynamicViewportSizeUpdate):

LayoutTests:

Add a UIHelper method to simulate device rotation to a given orientation, and use it in a new layout test that
simulates rotation to and from landscape orientation, and verifies that the initial scale did not change from
its expected value of 1.

  • fast/events/ios/rotation/do-not-shrink-to-fit-content-after-rotation-expected.txt: Added.
  • fast/events/ios/rotation/do-not-shrink-to-fit-content-after-rotation.html: Added.
  • resources/ui-helper.js:

(window.UIHelper.rotateDevice.return.new.Promise.):
(window.UIHelper.rotateDevice):
(window.UIHelper):

Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r245538 r245561  
     12019-05-20  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iOS] Layout viewport size on google.com increases after rotating to landscape and back
     4        https://bugs.webkit.org/show_bug.cgi?id=198062
     5        <rdar://problem/50547895>
     6
     7        Reviewed by Maciej Stachowiak.
     8
     9        Add a UIHelper method to simulate device rotation to a given orientation, and use it in a new layout test that
     10        simulates rotation to and from landscape orientation, and verifies that the initial scale did not change from
     11        its expected value of 1.
     12
     13        * fast/events/ios/rotation/do-not-shrink-to-fit-content-after-rotation-expected.txt: Added.
     14        * fast/events/ios/rotation/do-not-shrink-to-fit-content-after-rotation.html: Added.
     15        * resources/ui-helper.js:
     16        (window.UIHelper.rotateDevice.return.new.Promise.):
     17        (window.UIHelper.rotateDevice):
     18        (window.UIHelper):
     19
    1202019-05-20  Chris Dumez  <cdumez@apple.com>
    221
  • trunk/LayoutTests/resources/ui-helper.js

    r245285 r245561  
    907907        });
    908908    }
     909
     910    static rotateDevice(orientationName, animatedResize = false)
     911    {
     912        if (!this.isWebKit2() || !this.isIOS())
     913            return Promise.resolve();
     914
     915        return new Promise(resolve => {
     916            testRunner.runUIScript(`(() => {
     917                uiController.${animatedResize ? "simulateRotationLikeSafari" : "simulateRotation"}("${orientationName}", function() {
     918                    uiController.doAfterVisibleContentRectUpdate(() => uiController.uiScriptComplete());
     919                });
     920            })()`, resolve);
     921        });
     922    }
    909923}
  • trunk/Source/WebKit/ChangeLog

    r245543 r245561  
     12019-05-20  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iOS] Layout viewport size on google.com increases after rotating to landscape and back
     4        https://bugs.webkit.org/show_bug.cgi?id=198062
     5        <rdar://problem/50547895>
     6
     7        Reviewed by Maciej Stachowiak.
     8
     9        During an animated resize (e.g. when rotating the device on iOS), we currently immediately trigger the new
     10        shrink-to-fit content size heuristic in the middle of dynamicViewportSizeUpdate, after the new view layout size
     11        has been applied to the viewport configuration but before we've issued a resize event to the page.
     12
     13        Thus, on pages that use listen to the resize event and adjust their content accordingly to fit within the new
     14        layout width, we prematurely declare that the page has horizontally overflowed, and try to lay out at a larger
     15        width and scale down. This causes the page to unnecessarily shrink after rotating to landscale orientation and
     16        back.
     17
     18        To fix this, we simply move the call to shrink-to-fit-content to the end of the dynamic viewport size update,
     19        such that the page has had a chance to adjust to the new layout size.
     20
     21        Test: fast/events/ios/rotation/do-not-shrink-to-fit-content-after-rotation.html
     22
     23        * WebProcess/WebPage/ios/WebPageIOS.mm:
     24        (WebKit::WebPage::dynamicViewportSizeUpdate):
     25
    1262019-05-20  Ross Kirsling  <ross.kirsling@sony.com>
    227
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r245543 r245561  
    30033003        viewportConfigurationChanged();
    30043004
    3005 #if ENABLE(VIEWPORT_RESIZING)
    3006     if (immediatelyShrinkToFitContent())
    3007         viewportConfigurationChanged();
    3008 #endif
    3009 
    30103005    IntSize newLayoutSize = m_viewportConfiguration.layoutSize();
    30113006
     
    31393134    frameView.setScrollOffset(roundedUnobscuredContentRectPosition);
    31403135
     3136#if ENABLE(VIEWPORT_RESIZING)
     3137    if (immediatelyShrinkToFitContent())
     3138        viewportConfigurationChanged();
     3139#endif
     3140
    31413141    m_drawingArea->scheduleCompositingLayerFlush();
    31423142
Note: See TracChangeset for help on using the changeset viewer.