Changeset 283871 in webkit


Ignore:
Timestamp:
Oct 9, 2021 3:01:37 PM (9 months ago)
Author:
Simon Fraser
Message:

Run smooth scroll animations on the scrolling thread
https://bugs.webkit.org/show_bug.cgi?id=231481

Reviewed by Tim Horton.

Source/WebCore:

Implement AsyncScrollingCoordinator::requestAnimatedScrollToPosition() and stopAnimatedScroll()
so that smooth scroll animations are dispatched to the scrolling thread.

RequestedScrollData gains a requestType field so that we can indicate the need
to cancel a running animation on the scrolling thread.

Tested by tests in imported/w3c/web-platform-tests/css/cssom-view.

  • page/scrolling/AsyncScrollingCoordinator.cpp:

(WebCore::AsyncScrollingCoordinator::requestScrollPositionUpdate):
(WebCore::AsyncScrollingCoordinator::requestAnimatedScrollToPosition):
(WebCore::AsyncScrollingCoordinator::stopAnimatedScroll):

  • page/scrolling/ScrollingCoordinatorTypes.h:

(WebCore::RequestedScrollData::operator== const):

  • page/scrolling/ScrollingTreeScrollingNode.cpp:

(WebCore::ScrollingTreeScrollingNode::handleScrollPositionRequest): We already cancel
the animation each time. If this is a ScrollRequestType::CancelAnimatedScroll, there is no
more to do.

Source/WebKit:

Implement AsyncScrollingCoordinator::requestAnimatedScrollToPosition() and stopAnimatedScroll()
so that smooth scroll animations are dispatched to the scrolling thread.

RequestedScrollData gains a requestType field so that we can indicate the need
to cancel a running animation on the scrolling thread.

Tested by tests in imported/w3c/web-platform-tests/css/cssom-view.

  • Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp:

(ArgumentCoder<RequestedScrollData>::encode):
(ArgumentCoder<RequestedScrollData>::decode):
(WebKit::dump):

LayoutTests:

imported/w3c/web-platform-tests/css/cssom-view/idlharness.html seems to pass just fine.
imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-smooth.html has some problems
indicated by the github issue.

Three tests pass now on iOS (but they are not yet scrolling in the UI process).

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r283868 r283871  
     12021-10-09  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Run smooth scroll animations on the scrolling thread
     4        https://bugs.webkit.org/show_bug.cgi?id=231481
     5
     6        Reviewed by Tim Horton.
     7
     8        imported/w3c/web-platform-tests/css/cssom-view/idlharness.html seems to pass just fine.
     9        imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-smooth.html has some problems
     10        indicated by the github issue.
     11       
     12        Three tests pass now on iOS (but they are not yet scrolling in the UI process).
     13
     14        * TestExpectations:
     15        * platform/ios/TestExpectations:
     16
    1172021-10-09  Rob Buis  <rbuis@igalia.com>
    218
  • trunk/LayoutTests/TestExpectations

    r283864 r283871  
    10001000webkit.org/b/184066 imported/w3c/web-platform-tests/IndexedDB/nested-cloning-large.html [ Skip ]
    10011001webkit.org/b/184066 imported/w3c/web-platform-tests/IndexedDB/nested-cloning-small.html [ Skip ]
    1002 [ Debug ] imported/w3c/web-platform-tests/css/cssom-view/idlharness.html [ Skip ]
    10031002webkit.org/b/182292 imported/w3c/web-platform-tests/css/cssom-view/scrollingElement-quirks-dynamic-001.html [ ImageOnlyFailure ]
    10041003webkit.org/b/182292 imported/w3c/web-platform-tests/css/cssom-view/scrollingElement-quirks-dynamic-002.html [ ImageOnlyFailure ]
     
    30033002imported/w3c/web-platform-tests/css/css-ui/text-overflow-028.html [ ImageOnlyFailure ]
    30043003imported/w3c/web-platform-tests/css/css-ui/text-overflow-029.html [ ImageOnlyFailure ]
    3005 imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-smooth.html [ Skip ]
     3004
    30063005imported/w3c/web-platform-tests/css/mediaqueries/viewport-script-dynamic.html [ ImageOnlyFailure ]
    30073006imported/w3c/web-platform-tests/css/selectors/selection-image-001.html [ ImageOnlyFailure ]
     
    30103009imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/successes_RSA-OAEP.https.any.html [ Pass Failure ]
    30113010imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/successes_RSA-OAEP.https.any.worker.html [ Pass Failure ]
     3011
     3012# https://github.com/web-platform-tests/wpt/issues/31174
     3013imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-smooth.html [ Skip ]
    30123014
    30133015webkit.org/b/224104 imported/w3c/web-platform-tests/css/css-logical/logical-values-float-clear-reftest.html [ ImageOnlyFailure ]
  • trunk/LayoutTests/platform/ios/TestExpectations

    r283864 r283871  
    24432443webkit.org/b/163755 imported/w3c/web-platform-tests/css/css-shapes/shape-outside/shape-image/shape-image-025.html [ ImageOnlyFailure ]
    24442444
    2445 webkit.org/b/5991 imported/w3c/web-platform-tests/css/cssom-view/scrolling-quirks-vs-nonquirks.html [ Failure ]
    2446 
    2447 webkit.org/b/149264 imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-subframe-root.html [ Failure ]
    2448 webkit.org/b/149264 imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-subframe-window.html [ Failure ]
    2449 
    24502445# Variation fonts are not implemented earlier than iOS 11.
    24512446fast/text/variations [ Pass Failure ImageOnlyFailure ]
  • trunk/Source/WebCore/ChangeLog

    r283868 r283871  
     12021-10-09  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Run smooth scroll animations on the scrolling thread
     4        https://bugs.webkit.org/show_bug.cgi?id=231481
     5
     6        Reviewed by Tim Horton.
     7
     8        Implement AsyncScrollingCoordinator::requestAnimatedScrollToPosition() and stopAnimatedScroll()
     9        so that smooth scroll animations are dispatched to the scrolling thread.
     10
     11        RequestedScrollData gains a requestType field so that we can indicate the need
     12        to cancel a running animation on the scrolling thread.
     13       
     14        Tested by tests in imported/w3c/web-platform-tests/css/cssom-view.
     15
     16        * page/scrolling/AsyncScrollingCoordinator.cpp:
     17        (WebCore::AsyncScrollingCoordinator::requestScrollPositionUpdate):
     18        (WebCore::AsyncScrollingCoordinator::requestAnimatedScrollToPosition):
     19        (WebCore::AsyncScrollingCoordinator::stopAnimatedScroll):
     20        * page/scrolling/ScrollingCoordinatorTypes.h:
     21        (WebCore::RequestedScrollData::operator== const):
     22        * page/scrolling/ScrollingTreeScrollingNode.cpp:
     23        (WebCore::ScrollingTreeScrollingNode::handleScrollPositionRequest): We already cancel
     24        the animation each time. If this is a ScrollRequestType::CancelAnimatedScroll, there is no
     25        more to do.
     26
    1272021-10-09  Rob Buis  <rbuis@igalia.com>
    228
  • trunk/Source/WebCore/page/DOMWindow.cpp

    r283716 r283871  
    17131713    // This is an optimization for the common case of scrolling to (0, 0) when the scroller is already at the origin.
    17141714    // If an animated scroll is in progress, this optimization is skipped to ensure that the animated scroll is really stopped.
    1715     if (view->scrollAnimationStatus() == ScrollAnimationStatus::NotAnimating && !scrollToOptions.left.value() && !scrollToOptions.top.value() && view->contentsScrollPosition().isZero())
    1716         return;
     1715    if (view->scrollAnimationStatus() == ScrollAnimationStatus::NotAnimating && !scrollToOptions.left.value() && !scrollToOptions.top.value() && view->contentsScrollPosition().isZero()) {
     1716        LOG_WITH_STREAM(Scrolling, stream << "DOMWindow::scrollTo bailing because going to 0,0");
     1717        return;
     1718    }
    17171719
    17181720    document()->updateLayoutIgnorePendingStylesheets();
  • trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp

    r283793 r283871  
    276276        return false;
    277277
    278     stateNode->setRequestedScrollData({ scrollPosition, scrollType, clamping, ScrollIsAnimated::No });
     278    stateNode->setRequestedScrollData({ ScrollRequestType::PositionUpdate, scrollPosition, scrollType, clamping, ScrollIsAnimated::No });
    279279    // FIXME: This should schedule a rendering update
    280280    commitTreeStateIfNeeded();
     
    282282}
    283283
    284 bool AsyncScrollingCoordinator::requestAnimatedScrollToPosition(ScrollableArea&, const ScrollPosition&, ScrollClamping)
    285 {
    286     // FIXME: Implement.
    287     return false;
    288 }
    289 
    290 void AsyncScrollingCoordinator::stopAnimatedScroll(ScrollableArea&)
    291 {
    292     // FIXME: Implement.
     284bool AsyncScrollingCoordinator::requestAnimatedScrollToPosition(ScrollableArea& scrollableArea, const ScrollPosition& scrollPosition, ScrollClamping clamping)
     285{
     286    ASSERT(isMainThread());
     287    ASSERT(m_page);
     288    auto scrollingNodeID = scrollableArea.scrollingNodeID();
     289    if (!scrollingNodeID)
     290        return false;
     291
     292    auto* frameView = frameViewForScrollingNode(scrollingNodeID);
     293    if (!frameView || !coordinatesScrollingForFrameView(*frameView))
     294        return false;
     295
     296    auto* stateNode = downcast<ScrollingStateScrollingNode>(m_scrollingStateTree->stateNodeForID(scrollingNodeID));
     297    if (!stateNode)
     298        return false;
     299
     300    // Animated scrolls are always programmatic.
     301    stateNode->setRequestedScrollData({ ScrollRequestType::PositionUpdate, scrollPosition, ScrollType::Programmatic, clamping, ScrollIsAnimated::Yes });
     302    // FIXME: This should schedule a rendering update
     303    commitTreeStateIfNeeded();
     304    return true;
     305}
     306
     307void AsyncScrollingCoordinator::stopAnimatedScroll(ScrollableArea& scrollableArea)
     308{
     309    ASSERT(isMainThread());
     310    ASSERT(m_page);
     311    auto scrollingNodeID = scrollableArea.scrollingNodeID();
     312    if (!scrollingNodeID)
     313        return;
     314
     315    auto* frameView = frameViewForScrollingNode(scrollingNodeID);
     316    if (!frameView || !coordinatesScrollingForFrameView(*frameView))
     317        return;
     318
     319    auto* stateNode = downcast<ScrollingStateScrollingNode>(m_scrollingStateTree->stateNodeForID(scrollingNodeID));
     320    if (!stateNode)
     321        return;
     322
     323    // Animated scrolls are always programmatic.
     324    stateNode->setRequestedScrollData({ ScrollRequestType::CancelAnimatedScroll, { } });
     325    // FIXME: This should schedule a rendering update
     326    commitTreeStateIfNeeded();
    293327}
    294328
  • trunk/Source/WebCore/page/scrolling/ScrollingCoordinatorTypes.h

    r283793 r283871  
    103103};
    104104
     105enum class ScrollRequestType : uint8_t {
     106    PositionUpdate,
     107    CancelAnimatedScroll
     108};
     109
    105110struct RequestedScrollData {
     111    ScrollRequestType requestType { ScrollRequestType::PositionUpdate };
    106112    FloatPoint scrollPosition;
    107113    ScrollType scrollType { ScrollType::User };
     
    111117    bool operator==(const RequestedScrollData& other) const
    112118    {
    113         return scrollPosition == other.scrollPosition
     119        return requestType == other.requestType
     120            && scrollPosition == other.scrollPosition
    114121            && scrollType == other.scrollType
    115             && clamping == other.clamping;
     122            && clamping == other.clamping
     123            && animated == other.animated;
    116124    }
    117125};
    118126
    119 enum ScrollUpdateType : uint8_t {
     127enum class ScrollUpdateType : uint8_t {
    120128    PositionUpdate,
    121129    AnimatedScrollDidEnd
     
    145153namespace WTF {
    146154
     155template<> struct EnumTraits<WebCore::ScrollRequestType> {
     156    using values = EnumValues<
     157        WebCore::ScrollRequestType,
     158        WebCore::ScrollRequestType::PositionUpdate,
     159        WebCore::ScrollRequestType::CancelAnimatedScroll
     160    >;
     161};
     162
    147163template<> struct EnumTraits<WebCore::ScrollingNodeType> {
    148164    using values = EnumValues<
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp

    r283849 r283871  
    238238    stopAnimatedScroll();
    239239
     240    if (requestedScrollData.requestType == ScrollRequestType::CancelAnimatedScroll)
     241        return;
     242
    240243    if (scrollingTree().scrollingTreeNodeRequestsScroll(scrollingNodeID(), requestedScrollData))
    241244        return;
  • trunk/Source/WebKit/ChangeLog

    r283857 r283871  
     12021-10-09  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Run smooth scroll animations on the scrolling thread
     4        https://bugs.webkit.org/show_bug.cgi?id=231481
     5
     6        Reviewed by Tim Horton.
     7
     8        Implement AsyncScrollingCoordinator::requestAnimatedScrollToPosition() and stopAnimatedScroll()
     9        so that smooth scroll animations are dispatched to the scrolling thread.
     10
     11        RequestedScrollData gains a requestType field so that we can indicate the need
     12        to cancel a running animation on the scrolling thread.
     13       
     14        Tested by tests in imported/w3c/web-platform-tests/css/cssom-view.
     15
     16        * Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp:
     17        (ArgumentCoder<RequestedScrollData>::encode):
     18        (ArgumentCoder<RequestedScrollData>::decode):
     19        (WebKit::dump):
     20
    1212021-10-08  BJ Burg  <bburg@apple.com>
    222
     
    4324643266
    4324743267== Rolled over to ChangeLog-2021-03-18 ==
     43268
  • trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp

    r283792 r283871  
    505505void ArgumentCoder<RequestedScrollData>::encode(Encoder& encoder, const RequestedScrollData& scrollData)
    506506{
     507    encoder << scrollData.requestType;
    507508    encoder << scrollData.scrollPosition;
    508509    encoder << scrollData.scrollType;
     
    513514bool ArgumentCoder<RequestedScrollData>::decode(Decoder& decoder, RequestedScrollData& scrollData)
    514515{
     516    if (!decoder.decode(scrollData.requestType))
     517        return false;
     518
    515519    if (!decoder.decode(scrollData.scrollPosition))
    516520        return false;
     
    729733    if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateNode::Property::RequestedScrollPosition)) {
    730734        const auto& requestedScrollData = node.requestedScrollData();
    731         ts.dumpProperty("requested-scroll-position", requestedScrollData.scrollPosition);
    732         ts.dumpProperty("requested-scroll-position-is-programatic", requestedScrollData.scrollType);
    733         ts.dumpProperty("requested-scroll-position-clamping", requestedScrollData.clamping);
     735        if (requestedScrollData.requestType == ScrollRequestType::CancelAnimatedScroll)
     736            ts.dumpProperty("requested-type", "cancel animated scroll");
     737        else {
     738            ts.dumpProperty("requested-scroll-position", requestedScrollData.scrollPosition);
     739            ts.dumpProperty("requested-scroll-position-is-programatic", requestedScrollData.scrollType);
     740            ts.dumpProperty("requested-scroll-position-clamping", requestedScrollData.clamping);
     741        }
    734742    }
    735743
Note: See TracChangeset for help on using the changeset viewer.