Changeset 212559 in webkit


Ignore:
Timestamp:
Feb 17, 2017, 11:11:59 AM (9 years ago)
Author:
Simon Fraser
Message:

Fixed elements bounce when rubber-banding at the bottom of the page
https://bugs.webkit.org/show_bug.cgi?id=168493
rdar://problem/30567713

Reviewed by Tim Horton.

Source/WebCore:

FrameView::visibleDocumentRect() was computing a bad visible rect when bottom-rubber-banding,
by adding rubberBandBottom which is negative, rather than subtracting.

Log some more scrolling stuff.

Ironically, the existing test didn't test stick-to-viewport fixed position because
backgroundShouldExtendBeyondPage() is off by default in WTR, so clone it to a test
that sets this, to test both behaviors.

This also revealed that dynamic changes to backgroundShouldExtendBeyondPage() need
to be propagated to the scrolling tree, which is fixed in AsyncScrollingCoordinator::frameViewLayoutUpdated().

Test: fast/visual-viewport/rubberbanding-viewport-rects-extended-background.html

  • page/FrameView.cpp:

(WebCore::FrameView::updateLayoutViewport):
(WebCore::FrameView::visibleDocumentRect):

  • page/scrolling/AsyncScrollingCoordinator.cpp:

(WebCore::AsyncScrollingCoordinator::frameViewLayoutUpdated):

  • page/scrolling/ScrollingStateFrameScrollingNode.cpp:

(WebCore::ScrollingStateFrameScrollingNode::dumpProperties):

  • page/scrolling/ScrollingTreeFrameScrollingNode.cpp:

(WebCore::ScrollingTreeFrameScrollingNode::layoutViewportForScrollPosition):

  • page/scrolling/mac/ScrollingCoordinatorMac.mm:

(WebCore::ScrollingCoordinatorMac::scheduleTreeStateCommit):
(WebCore::ScrollingCoordinatorMac::commitTreeState):

LayoutTests:

  • fast/visual-viewport/rubberbanding-viewport-rects-expected.txt:
  • fast/visual-viewport/rubberbanding-viewport-rects-extended-background-expected.txt: Copied from LayoutTests/fast/visual-viewport/rubberbanding-viewport-rects-expected.txt.
  • fast/visual-viewport/rubberbanding-viewport-rects-extended-background.html: Copied from LayoutTests/fast/visual-viewport/rubberbanding-viewport-rects.html.
  • fast/visual-viewport/rubberbanding-viewport-rects.html:
  • platform/ios-simulator-wk2/fast/visual-viewport/rubberbanding-viewport-rects-expected.txt:
  • platform/ios-simulator-wk2/fast/visual-viewport/rubberbanding-viewport-rects-extended-background-expected.txt: Copied from LayoutTests/platform/ios-simulator-wk2/fast/visual-viewport/rubberbanding-viewport-rects-expected.txt.
  • platform/mac-wk1/fast/visual-viewport/rubberbanding-viewport-rects-extended-background-expected.txt: Added.
Location:
trunk
Files:
1 added
10 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r212558 r212559  
     12017-02-17  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Fixed elements bounce when rubber-banding at the bottom of the page
     4        https://bugs.webkit.org/show_bug.cgi?id=168493
     5        rdar://problem/30567713
     6
     7        Reviewed by Tim Horton.
     8
     9        * fast/visual-viewport/rubberbanding-viewport-rects-expected.txt:
     10        * fast/visual-viewport/rubberbanding-viewport-rects-extended-background-expected.txt: Copied from LayoutTests/fast/visual-viewport/rubberbanding-viewport-rects-expected.txt.
     11        * fast/visual-viewport/rubberbanding-viewport-rects-extended-background.html: Copied from LayoutTests/fast/visual-viewport/rubberbanding-viewport-rects.html.
     12        * fast/visual-viewport/rubberbanding-viewport-rects.html:
     13        * platform/ios-simulator-wk2/fast/visual-viewport/rubberbanding-viewport-rects-expected.txt:
     14        * platform/ios-simulator-wk2/fast/visual-viewport/rubberbanding-viewport-rects-extended-background-expected.txt: Copied from LayoutTests/platform/ios-simulator-wk2/fast/visual-viewport/rubberbanding-viewport-rects-expected.txt.
     15        * platform/mac-wk1/fast/visual-viewport/rubberbanding-viewport-rects-extended-background-expected.txt: Added.
     16
    1172017-02-17  Simon Fraser  <simon.fraser@apple.com>
    218
  • trunk/LayoutTests/fast/visual-viewport/rubberbanding-viewport-rects-expected.txt

    r211379 r212559  
    1212JSON.stringify(visualViewport) is {"top":525,"right":1260,"bottom":1110,"left":475,"width":785,"height":585}
    1313
    14 Scrolled to 1800, 1700
    15 JSON.stringify(layoutViewport) is {"top":1690,"right":2008,"bottom":2275,"left":1223,"width":785,"height":585}
    16 JSON.stringify(visualViewport) is {"top":1700,"right":2585,"bottom":2275,"left":1800,"width":785,"height":575}
     14Scrolled to 1800, 1850
     15JSON.stringify(layoutViewport) is {"top":1695,"right":2008,"bottom":2280,"left":1223,"width":785,"height":585}
     16JSON.stringify(visualViewport) is {"top":1850,"right":2585,"bottom":2435,"left":1800,"width":785,"height":585}
    1717PASS successfullyParsed is true
    1818
  • trunk/LayoutTests/fast/visual-viewport/rubberbanding-viewport-rects-extended-background-expected.txt

    r212558 r212559  
    1 This test scrolls the page and checks that the layout and visual viewports respond as expected.
     1This test scrolls the page with extended backgrounds enabled and checks that the layout and visual viewports respond as expected.
    22
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
     
    55
    66Scrolled to -123, -234
    7 JSON.stringify(layoutViewport) is {"top":0,"right":785,"bottom":585,"left":0,"width":785,"height":585}
     7JSON.stringify(layoutViewport) is {"top":-234,"right":662,"bottom":351,"left":-123,"width":785,"height":585}
    88JSON.stringify(visualViewport) is {"top":-234,"right":662,"bottom":351,"left":-123,"width":785,"height":585}
    99
     
    1212JSON.stringify(visualViewport) is {"top":525,"right":1260,"bottom":1110,"left":475,"width":785,"height":585}
    1313
    14 Scrolled to 1800, 1700
    15 JSON.stringify(layoutViewport) is {"top":1690,"right":2008,"bottom":2275,"left":1223,"width":785,"height":585}
    16 JSON.stringify(visualViewport) is {"top":1700,"right":2585,"bottom":2275,"left":1800,"width":785,"height":575}
     14Scrolled to 1800, 1850
     15JSON.stringify(layoutViewport) is {"top":1850,"right":2585,"bottom":2435,"left":1800,"width":785,"height":585}
     16JSON.stringify(visualViewport) is {"top":1850,"right":2585,"bottom":2435,"left":1800,"width":785,"height":585}
    1717PASS successfullyParsed is true
    1818
  • trunk/LayoutTests/fast/visual-viewport/rubberbanding-viewport-rects-extended-background.html

    r212558 r212559  
    1111    </style>
    1212    <script>
    13         description("This test scrolls the page and checks that the layout and visual viewports respond as expected.");
     13        description("This test scrolls the page with extended backgrounds enabled and checks that the layout and visual viewports respond as expected.");
    1414
    1515        if (window.internals) {
    1616            internals.settings.setVisualViewportEnabled(true);
    1717            internals.settings.setAllowUnclampedScrollPosition(true);
     18            internals.settings.setBackgroundShouldExtendBeyondPage(true);
    1819        }
    1920
     
    2930            debug('Scrolled to ' + window.scrollX + ', ' + window.scrollY);
    3031
    31             // Don't use shouldBeEqualToString() to avoid showing failures when correct output differs between platforms. 
     32            // Don't use shouldBeEqualToString() to avoid showing failures when correct output differs between platforms.
    3233            evalAndLogResult("JSON.stringify(layoutViewport)");
    3334            evalAndLogResult("JSON.stringify(visualViewport)");
     
    4344
    4445            debug('');
    45             window.scrollTo(1800, 1700);
     46            window.scrollTo(1800, 1850);
    4647            visualViewport = internals.visualViewportRect();
    4748            layoutViewport = internals.layoutViewportRect();
  • trunk/LayoutTests/fast/visual-viewport/rubberbanding-viewport-rects.html

    r211379 r212559  
    2929            debug('Scrolled to ' + window.scrollX + ', ' + window.scrollY);
    3030
    31             // Don't use shouldBeEqualToString() to avoid showing failures when correct output differs between platforms. 
     31            // Don't use shouldBeEqualToString() to avoid showing failures when correct output differs between platforms.
    3232            evalAndLogResult("JSON.stringify(layoutViewport)");
    3333            evalAndLogResult("JSON.stringify(visualViewport)");
     
    4343
    4444            debug('');
    45             window.scrollTo(1800, 1700);
     45            window.scrollTo(1800, 1850);
    4646            visualViewport = internals.visualViewportRect();
    4747            layoutViewport = internals.layoutViewportRect();
  • trunk/LayoutTests/platform/ios-simulator-wk2/fast/visual-viewport/rubberbanding-viewport-rects-expected.txt

    r211379 r212559  
    1212JSON.stringify(visualViewport) is {"top":525,"right":1275,"bottom":1125,"left":475,"width":800,"height":600}
    1313
    14 Scrolled to 1800, 1700
    15 JSON.stringify(layoutViewport) is {"top":1616,"right":2008,"bottom":2216,"left":1208,"width":800,"height":600}
    16 JSON.stringify(visualViewport) is {"top":1700,"right":2600,"bottom":2216,"left":1800,"width":800,"height":516}
     14Scrolled to 1800, 1850
     15JSON.stringify(layoutViewport) is {"top":1658,"right":2008,"bottom":2258,"left":1208,"width":800,"height":600}
     16JSON.stringify(visualViewport) is {"top":1850,"right":2600,"bottom":2450,"left":1800,"width":800,"height":600}
    1717PASS successfullyParsed is true
    1818
  • trunk/LayoutTests/platform/ios-simulator-wk2/fast/visual-viewport/rubberbanding-viewport-rects-extended-background-expected.txt

    r212558 r212559  
    1 This test scrolls the page and checks that the layout and visual viewports respond as expected.
     1This test scrolls the page with extended backgrounds enabled and checks that the layout and visual viewports respond as expected.
    22
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
     
    55
    66Scrolled to -123, -234
    7 JSON.stringify(layoutViewport) is {"top":0,"right":800,"bottom":600,"left":0,"width":800,"height":600}
     7JSON.stringify(layoutViewport) is {"top":-234,"right":677,"bottom":366,"left":-123,"width":800,"height":600}
    88JSON.stringify(visualViewport) is {"top":-234,"right":677,"bottom":366,"left":-123,"width":800,"height":600}
    99
     
    1212JSON.stringify(visualViewport) is {"top":525,"right":1275,"bottom":1125,"left":475,"width":800,"height":600}
    1313
    14 Scrolled to 1800, 1700
    15 JSON.stringify(layoutViewport) is {"top":1616,"right":2008,"bottom":2216,"left":1208,"width":800,"height":600}
    16 JSON.stringify(visualViewport) is {"top":1700,"right":2600,"bottom":2216,"left":1800,"width":800,"height":516}
     14Scrolled to 1800, 1850
     15JSON.stringify(layoutViewport) is {"top":1850,"right":2600,"bottom":2450,"left":1800,"width":800,"height":600}
     16JSON.stringify(visualViewport) is {"top":1850,"right":2600,"bottom":2450,"left":1800,"width":800,"height":600}
    1717PASS successfullyParsed is true
    1818
  • trunk/Source/WebCore/ChangeLog

    r212558 r212559  
     12017-02-17  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Fixed elements bounce when rubber-banding at the bottom of the page
     4        https://bugs.webkit.org/show_bug.cgi?id=168493
     5        rdar://problem/30567713
     6
     7        Reviewed by Tim Horton.
     8
     9        FrameView::visibleDocumentRect() was computing a bad visible rect when bottom-rubber-banding,
     10        by adding rubberBandBottom which is negative, rather than subtracting.
     11
     12        Log some more scrolling stuff.
     13
     14        Ironically, the existing test didn't test stick-to-viewport fixed position because
     15        backgroundShouldExtendBeyondPage() is off by default in WTR, so clone it to a test
     16        that sets this, to test both behaviors.
     17
     18        This also revealed that dynamic changes to backgroundShouldExtendBeyondPage() need
     19        to be propagated to the scrolling tree, which is fixed in AsyncScrollingCoordinator::frameViewLayoutUpdated().
     20
     21        Test: fast/visual-viewport/rubberbanding-viewport-rects-extended-background.html
     22
     23        * page/FrameView.cpp:
     24        (WebCore::FrameView::updateLayoutViewport):
     25        (WebCore::FrameView::visibleDocumentRect):
     26        * page/scrolling/AsyncScrollingCoordinator.cpp:
     27        (WebCore::AsyncScrollingCoordinator::frameViewLayoutUpdated):
     28        * page/scrolling/ScrollingStateFrameScrollingNode.cpp:
     29        (WebCore::ScrollingStateFrameScrollingNode::dumpProperties):
     30        * page/scrolling/ScrollingTreeFrameScrollingNode.cpp:
     31        (WebCore::ScrollingTreeFrameScrollingNode::layoutViewportForScrollPosition):
     32        * page/scrolling/mac/ScrollingCoordinatorMac.mm:
     33        (WebCore::ScrollingCoordinatorMac::scheduleTreeStateCommit):
     34        (WebCore::ScrollingCoordinatorMac::commitTreeState):
     35
    1362017-02-17  Simon Fraser  <simon.fraser@apple.com>
    237
  • trunk/Source/WebCore/page/FrameView.cpp

    r212484 r212559  
    19071907    LayoutRect layoutViewport = layoutViewportRect();
    19081908
    1909     LOG_WITH_STREAM(Scrolling, stream << "\nFrameView " << this << " updateLayoutViewport() totalContentSize " << totalContentsSize() << " unscaledDocumentRect " << (renderView() ? renderView()->unscaledDocumentRect() : IntRect()) << " header height " << headerHeight() << " footer height " << footerHeight());
     1909    LOG_WITH_STREAM(Scrolling, stream << "\nFrameView " << this << " updateLayoutViewport() totalContentSize " << totalContentsSize() << " unscaledDocumentRect " << (renderView() ? renderView()->unscaledDocumentRect() : IntRect()) << " header height " << headerHeight() << " footer height " << footerHeight() << " fixed behavior " << scrollBehaviorForFixedElements());
    19101910    LOG_WITH_STREAM(Scrolling, stream << "layoutViewport: " << layoutViewport);
    19111911    LOG_WITH_STREAM(Scrolling, stream << "visualViewport: " << visualViewportRect());
     
    19601960   
    19611961    float rubberBandBottom = std::min<float>((totalContentsSize.height() - visibleContentRect.y()) - visibleContentRect.height(), 0);
    1962     float visibleScaledDocumentBottom = std::min<float>(visibleContentRect.maxY() - headerHeight, contentsHeight) + rubberBandBottom;
     1962    float visibleScaledDocumentBottom = std::min<float>(visibleContentRect.maxY() - headerHeight, contentsHeight) - rubberBandBottom;
    19631963
    19641964    FloatRect visibleDocumentRect = visibleContentRect;
  • trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp

    r211379 r212559  
    158158    node->setReachableContentsSize(frameView.totalContentsSize());
    159159    node->setFixedElementsLayoutRelativeToFrame(frameView.fixedElementsLayoutRelativeToFrame());
     160    node->setScrollBehaviorForFixedElements(frameView.scrollBehaviorForFixedElements());
    160161
    161162#if ENABLE(CSS_SCROLL_SNAP)
  • trunk/Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.cpp

    r208503 r212559  
    282282        ts << "(max layout viewport origin " << m_maxLayoutViewportOrigin << ")\n";
    283283    }
     284   
     285    if (m_behaviorForFixed == StickToViewportBounds) {
     286        writeIndent(ts, indent + 1);
     287        ts << "(fixed behavior: stick to viewport)\n";
     288    }
    284289
    285290    if (!m_eventTrackingRegions.asynchronousDispatchRegion.isEmpty()) {
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp

    r211379 r212559  
    107107    LayoutRect layoutViewport(m_layoutViewport);
    108108
    109     LOG_WITH_STREAM(Scrolling, stream << "\nScrolling thread: " << "(visibleContentOrigin " << visibleContentOrigin << ")");
     109    LOG_WITH_STREAM(Scrolling, stream << "\nScrolling thread: " << "(visibleContentOrigin " << visibleContentOrigin << ") fixed behavior " << m_behaviorForFixed);
    110110    LOG_WITH_STREAM(Scrolling, stream << "  layoutViewport: " << layoutViewport);
    111111    LOG_WITH_STREAM(Scrolling, stream << "  visualViewport: " << visualViewport);
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm

    r211033 r212559  
    3131
    3232#include "FrameView.h"
     33#include "Logging.h"
    3334#include "MainFrame.h"
    3435#include "Page.h"
     
    104105        return;
    105106
     107    LOG(Scrolling, "ScrollingCoordinatorMac::scheduleTreeStateCommit");
    106108    m_scrollingStateTreeCommitterTimer.startOneShot(0);
    107109}
     
    110112{
    111113    willCommitTree();
     114
     115    LOG(Scrolling, "ScrollingCoordinatorMac::commitTreeState, has changes %d", scrollingStateTree()->hasChangedProperties());
     116
    112117    if (!scrollingStateTree()->hasChangedProperties())
    113118        return;
     119
     120    LOG(Scrolling, "%s", scrollingStateTreeAsText().utf8().data());
    114121
    115122    RefPtr<ThreadedScrollingTree> threadedScrollingTree = downcast<ThreadedScrollingTree>(scrollingTree());
Note: See TracChangeset for help on using the changeset viewer.