Changeset 277775 in webkit


Ignore:
Timestamp:
May 19, 2021 10:05:40 PM (14 months ago)
Author:
Tomoki Imai
Message:

Scrolling must be done after the layout when doing full page zoom
https://bugs.webkit.org/show_bug.cgi?id=225730

Reviewed by Simon Fraser.

Source/WebCore:

Previously, the actual scroll was executed before the layout with the zoomed position.
It sometimes makes the scroll position exceed the page height, and cannot retain pageYOffset.
In the user experience perspective, the user may miss what they are looking at after zoom.

This patch makes the scroll happen after the layout, with the zoomed position.

Test: LayoutTests\fast\scrolling\page-y-offset-should-not-be-changed-after-zoom.html

  • page/Frame.cpp:

(WebCore::Frame::setPageAndTextZoomFactors): Makes the scroll happen after the layout.

Source/WebKit:

Add check to disallow negative or zero zoom value.

  • UIProcess/API/C/WKPage.cpp:

(WKPageSetPageZoomFactor):

LayoutTests:

Added a testcase to ensure that scroll position is not changed after zoom.

  • fast/scrolling/page-y-offset-should-not-be-changed-after-zoom-expected.txt: Added.
  • fast/scrolling/page-y-offset-should-not-be-changed-after-zoom.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r277772 r277775  
     12021-05-19  Tomoki Imai  <Tomoki.Imai@sony.com>
     2
     3        Scrolling must be done after the layout when doing full page zoom
     4        https://bugs.webkit.org/show_bug.cgi?id=225730
     5
     6        Reviewed by Simon Fraser.
     7
     8        Added a testcase to ensure that scroll position is not changed after zoom.
     9
     10        * fast/scrolling/page-y-offset-should-not-be-changed-after-zoom-expected.txt: Added.
     11        * fast/scrolling/page-y-offset-should-not-be-changed-after-zoom.html: Added.
     12
    1132021-05-19  Devin Rousso  <drousso@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r277772 r277775  
     12021-05-19  Tomoki Imai  <Tomoki.Imai@sony.com>
     2
     3        Scrolling must be done after the layout when doing full page zoom
     4        https://bugs.webkit.org/show_bug.cgi?id=225730
     5
     6        Reviewed by Simon Fraser.
     7
     8        Previously, the actual scroll was executed before the layout with the zoomed position.
     9        It sometimes makes the scroll position exceed the page height, and cannot retain pageYOffset.
     10        In the user experience perspective, the user may miss what they are looking at after zoom.
     11
     12        This patch makes the scroll happen after the layout, with the zoomed position.
     13
     14        Test: LayoutTests\fast\scrolling\page-y-offset-should-not-be-changed-after-zoom.html
     15
     16        * page/Frame.cpp:
     17        (WebCore::Frame::setPageAndTextZoomFactors): Makes the scroll happen after the layout.
     18
    1192021-05-19  Devin Rousso  <drousso@apple.com>
    220
  • trunk/Source/WebCore/page/Frame.cpp

    r277295 r277775  
    962962        return;
    963963
     964    Optional<ScrollPosition> scrollPositionAfterZoomed;
    964965    if (m_pageZoomFactor != pageZoomFactor) {
     966        // Compute the scroll position with scale after zooming to stay the same position in the content.
    965967        if (FrameView* view = this->view()) {
    966             // Update the scroll position when doing a full page zoom, so the content stays in relatively the same position.
    967             LayoutPoint scrollPosition = view->scrollPosition();
    968             float percentDifference = (pageZoomFactor / m_pageZoomFactor);
    969             view->setScrollPosition(IntPoint(scrollPosition.x() * percentDifference, scrollPosition.y() * percentDifference));
     968            scrollPositionAfterZoomed = view->scrollPosition();
     969            scrollPositionAfterZoomed->scale(pageZoomFactor / m_pageZoomFactor);
    970970        }
    971971    }
    972 
    973972    m_pageZoomFactor = pageZoomFactor;
    974973    m_textZoomFactor = textZoomFactor;
     
    982981        if (document->renderView() && document->renderView()->needsLayout() && view->didFirstLayout())
    983982            view->layoutContext().layout();
     983
     984        // Scrolling to the calculated position must be done after the layout.
     985        if (scrollPositionAfterZoomed)
     986            view->setScrollPosition(scrollPositionAfterZoomed.value());
    984987    }
    985988}
  • trunk/Source/WebKit/ChangeLog

    r277774 r277775  
     12021-05-19  Tomoki Imai  <Tomoki.Imai@sony.com>
     2
     3        Scrolling must be done after the layout when doing full page zoom
     4        https://bugs.webkit.org/show_bug.cgi?id=225730
     5
     6        Reviewed by Simon Fraser.
     7
     8        Add check to disallow negative or zero zoom value.
     9
     10        * UIProcess/API/C/WKPage.cpp:
     11        (WKPageSetPageZoomFactor):
     12
    1132021-05-19  Chris Dumez  <cdumez@apple.com>
    214
  • trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp

    r277740 r277775  
    606606{
    607607    CRASH_IF_SUSPENDED;
     608    if (zoomFactor <= 0)
     609        return;
    608610    toImpl(pageRef)->setPageZoomFactor(zoomFactor);
    609611}
Note: See TracChangeset for help on using the changeset viewer.