Title: [283871] trunk
Revision
283871
Author
[email protected]
Date
2021-10-09 15:01:37 -0700 (Sat, 09 Oct 2021)

Log 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).

* TestExpectations:
* platform/ios/TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (283870 => 283871)


--- trunk/LayoutTests/ChangeLog	2021-10-09 21:35:21 UTC (rev 283870)
+++ trunk/LayoutTests/ChangeLog	2021-10-09 22:01:37 UTC (rev 283871)
@@ -1,3 +1,19 @@
+2021-10-09  Simon Fraser  <[email protected]>
+
+        Run smooth scroll animations on the scrolling thread
+        https://bugs.webkit.org/show_bug.cgi?id=231481
+
+        Reviewed by Tim Horton.
+
+        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).
+
+        * TestExpectations:
+        * platform/ios/TestExpectations:
+
 2021-10-09  Rob Buis  <[email protected]>
 
         Remove scrollbars explicitly when destroying render tree

Modified: trunk/LayoutTests/TestExpectations (283870 => 283871)


--- trunk/LayoutTests/TestExpectations	2021-10-09 21:35:21 UTC (rev 283870)
+++ trunk/LayoutTests/TestExpectations	2021-10-09 22:01:37 UTC (rev 283871)
@@ -999,7 +999,6 @@
 webkit.org/b/184066 imported/w3c/web-platform-tests/IndexedDB/nested-cloning-large-multiple.html [ Skip ]
 webkit.org/b/184066 imported/w3c/web-platform-tests/IndexedDB/nested-cloning-large.html [ Skip ]
 webkit.org/b/184066 imported/w3c/web-platform-tests/IndexedDB/nested-cloning-small.html [ Skip ]
-[ Debug ] imported/w3c/web-platform-tests/css/cssom-view/idlharness.html [ Skip ]
 webkit.org/b/182292 imported/w3c/web-platform-tests/css/cssom-view/scrollingElement-quirks-dynamic-001.html [ ImageOnlyFailure ]
 webkit.org/b/182292 imported/w3c/web-platform-tests/css/cssom-view/scrollingElement-quirks-dynamic-002.html [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-ui/text-overflow-010.html [ ImageOnlyFailure ]
@@ -3002,7 +3001,7 @@
 imported/w3c/web-platform-tests/css/css-ui/text-overflow-027.html [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-ui/text-overflow-028.html [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-ui/text-overflow-029.html [ ImageOnlyFailure ]
-imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-smooth.html [ Skip ]
+
 imported/w3c/web-platform-tests/css/mediaqueries/viewport-script-dynamic.html [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/selectors/selection-image-001.html [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/selectors/selection-image-002.html [ ImageOnlyFailure ]
@@ -3010,6 +3009,9 @@
 imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/successes_RSA-OAEP.https.any.html [ Pass Failure ]
 imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/successes_RSA-OAEP.https.any.worker.html [ Pass Failure ]
 
+# https://github.com/web-platform-tests/wpt/issues/31174
+imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-smooth.html [ Skip ]
+
 webkit.org/b/224104 imported/w3c/web-platform-tests/css/css-logical/logical-values-float-clear-reftest.html [ ImageOnlyFailure ]
 
 # wpt css-shapes

Modified: trunk/LayoutTests/platform/ios/TestExpectations (283870 => 283871)


--- trunk/LayoutTests/platform/ios/TestExpectations	2021-10-09 21:35:21 UTC (rev 283870)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2021-10-09 22:01:37 UTC (rev 283871)
@@ -2442,11 +2442,6 @@
 
 webkit.org/b/163755 imported/w3c/web-platform-tests/css/css-shapes/shape-outside/shape-image/shape-image-025.html [ ImageOnlyFailure ]
 
-webkit.org/b/5991 imported/w3c/web-platform-tests/css/cssom-view/scrolling-quirks-vs-nonquirks.html [ Failure ]
-
-webkit.org/b/149264 imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-subframe-root.html [ Failure ]
-webkit.org/b/149264 imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-subframe-window.html [ Failure ]
-
 # Variation fonts are not implemented earlier than iOS 11.
 fast/text/variations [ Pass Failure ImageOnlyFailure ]
 animations/font-variations [ Pass Failure ImageOnlyFailure Timeout ]

Modified: trunk/Source/WebCore/ChangeLog (283870 => 283871)


--- trunk/Source/WebCore/ChangeLog	2021-10-09 21:35:21 UTC (rev 283870)
+++ trunk/Source/WebCore/ChangeLog	2021-10-09 22:01:37 UTC (rev 283871)
@@ -1,3 +1,29 @@
+2021-10-09  Simon Fraser  <[email protected]>
+
+        Run smooth scroll animations on the scrolling thread
+        https://bugs.webkit.org/show_bug.cgi?id=231481
+
+        Reviewed by Tim Horton.
+
+        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.
+
 2021-10-09  Rob Buis  <[email protected]>
 
         Remove scrollbars explicitly when destroying render tree

Modified: trunk/Source/WebCore/page/DOMWindow.cpp (283870 => 283871)


--- trunk/Source/WebCore/page/DOMWindow.cpp	2021-10-09 21:35:21 UTC (rev 283870)
+++ trunk/Source/WebCore/page/DOMWindow.cpp	2021-10-09 22:01:37 UTC (rev 283871)
@@ -1712,8 +1712,10 @@
 
     // This is an optimization for the common case of scrolling to (0, 0) when the scroller is already at the origin.
     // If an animated scroll is in progress, this optimization is skipped to ensure that the animated scroll is really stopped.
-    if (view->scrollAnimationStatus() == ScrollAnimationStatus::NotAnimating && !scrollToOptions.left.value() && !scrollToOptions.top.value() && view->contentsScrollPosition().isZero())
+    if (view->scrollAnimationStatus() == ScrollAnimationStatus::NotAnimating && !scrollToOptions.left.value() && !scrollToOptions.top.value() && view->contentsScrollPosition().isZero()) {
+        LOG_WITH_STREAM(Scrolling, stream << "DOMWindow::scrollTo bailing because going to 0,0");
         return;
+    }
 
     document()->updateLayoutIgnorePendingStylesheets();
 

Modified: trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp (283870 => 283871)


--- trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp	2021-10-09 21:35:21 UTC (rev 283870)
+++ trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp	2021-10-09 22:01:37 UTC (rev 283871)
@@ -275,21 +275,55 @@
     if (!stateNode)
         return false;
 
-    stateNode->setRequestedScrollData({ scrollPosition, scrollType, clamping, ScrollIsAnimated::No });
+    stateNode->setRequestedScrollData({ ScrollRequestType::PositionUpdate, scrollPosition, scrollType, clamping, ScrollIsAnimated::No });
     // FIXME: This should schedule a rendering update
     commitTreeStateIfNeeded();
     return true;
 }
 
-bool AsyncScrollingCoordinator::requestAnimatedScrollToPosition(ScrollableArea&, const ScrollPosition&, ScrollClamping)
+bool AsyncScrollingCoordinator::requestAnimatedScrollToPosition(ScrollableArea& scrollableArea, const ScrollPosition& scrollPosition, ScrollClamping clamping)
 {
-    // FIXME: Implement.
-    return false;
+    ASSERT(isMainThread());
+    ASSERT(m_page);
+    auto scrollingNodeID = scrollableArea.scrollingNodeID();
+    if (!scrollingNodeID)
+        return false;
+
+    auto* frameView = frameViewForScrollingNode(scrollingNodeID);
+    if (!frameView || !coordinatesScrollingForFrameView(*frameView))
+        return false;
+
+    auto* stateNode = downcast<ScrollingStateScrollingNode>(m_scrollingStateTree->stateNodeForID(scrollingNodeID));
+    if (!stateNode)
+        return false;
+
+    // Animated scrolls are always programmatic.
+    stateNode->setRequestedScrollData({ ScrollRequestType::PositionUpdate, scrollPosition, ScrollType::Programmatic, clamping, ScrollIsAnimated::Yes });
+    // FIXME: This should schedule a rendering update
+    commitTreeStateIfNeeded();
+    return true;
 }
 
-void AsyncScrollingCoordinator::stopAnimatedScroll(ScrollableArea&)
+void AsyncScrollingCoordinator::stopAnimatedScroll(ScrollableArea& scrollableArea)
 {
-    // FIXME: Implement.
+    ASSERT(isMainThread());
+    ASSERT(m_page);
+    auto scrollingNodeID = scrollableArea.scrollingNodeID();
+    if (!scrollingNodeID)
+        return;
+
+    auto* frameView = frameViewForScrollingNode(scrollingNodeID);
+    if (!frameView || !coordinatesScrollingForFrameView(*frameView))
+        return;
+
+    auto* stateNode = downcast<ScrollingStateScrollingNode>(m_scrollingStateTree->stateNodeForID(scrollingNodeID));
+    if (!stateNode)
+        return;
+
+    // Animated scrolls are always programmatic.
+    stateNode->setRequestedScrollData({ ScrollRequestType::CancelAnimatedScroll, { } });
+    // FIXME: This should schedule a rendering update
+    commitTreeStateIfNeeded();
 }
 
 void AsyncScrollingCoordinator::applyScrollingTreeLayerPositions()

Modified: trunk/Source/WebCore/page/scrolling/ScrollingCoordinatorTypes.h (283870 => 283871)


--- trunk/Source/WebCore/page/scrolling/ScrollingCoordinatorTypes.h	2021-10-09 21:35:21 UTC (rev 283870)
+++ trunk/Source/WebCore/page/scrolling/ScrollingCoordinatorTypes.h	2021-10-09 22:01:37 UTC (rev 283871)
@@ -102,7 +102,13 @@
     ChangingObscuredInsetsInteractively // This implies Unstable.
 };
 
+enum class ScrollRequestType : uint8_t {
+    PositionUpdate,
+    CancelAnimatedScroll
+};
+
 struct RequestedScrollData {
+    ScrollRequestType requestType { ScrollRequestType::PositionUpdate };
     FloatPoint scrollPosition;
     ScrollType scrollType { ScrollType::User };
     ScrollClamping clamping { ScrollClamping::Clamped };
@@ -110,13 +116,15 @@
 
     bool operator==(const RequestedScrollData& other) const
     {
-        return scrollPosition == other.scrollPosition
+        return requestType == other.requestType
+            && scrollPosition == other.scrollPosition
             && scrollType == other.scrollType
-            && clamping == other.clamping;
+            && clamping == other.clamping
+            && animated == other.animated;
     }
 };
 
-enum ScrollUpdateType : uint8_t {
+enum class ScrollUpdateType : uint8_t {
     PositionUpdate,
     AnimatedScrollDidEnd
 };
@@ -144,6 +152,14 @@
 
 namespace WTF {
 
+template<> struct EnumTraits<WebCore::ScrollRequestType> {
+    using values = EnumValues<
+        WebCore::ScrollRequestType,
+        WebCore::ScrollRequestType::PositionUpdate,
+        WebCore::ScrollRequestType::CancelAnimatedScroll
+    >;
+};
+
 template<> struct EnumTraits<WebCore::ScrollingNodeType> {
     using values = EnumValues<
         WebCore::ScrollingNodeType,

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp (283870 => 283871)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp	2021-10-09 21:35:21 UTC (rev 283870)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp	2021-10-09 22:01:37 UTC (rev 283871)
@@ -237,6 +237,9 @@
 
     stopAnimatedScroll();
 
+    if (requestedScrollData.requestType == ScrollRequestType::CancelAnimatedScroll)
+        return;
+
     if (scrollingTree().scrollingTreeNodeRequestsScroll(scrollingNodeID(), requestedScrollData))
         return;
 

Modified: trunk/Source/WebKit/ChangeLog (283870 => 283871)


--- trunk/Source/WebKit/ChangeLog	2021-10-09 21:35:21 UTC (rev 283870)
+++ trunk/Source/WebKit/ChangeLog	2021-10-09 22:01:37 UTC (rev 283871)
@@ -1,3 +1,23 @@
+2021-10-09  Simon Fraser  <[email protected]>
+
+        Run smooth scroll animations on the scrolling thread
+        https://bugs.webkit.org/show_bug.cgi?id=231481
+
+        Reviewed by Tim Horton.
+
+        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):
+
 2021-10-08  BJ Burg  <[email protected]>
 
         [Cocoa] Web Inspector: provide a way for _WKInspectorExtension clients to be notified when the inspected page navigates
@@ -43245,3 +43265,4 @@
         Tested by imported/w3c/web-platform-tests/xhr/responsexml-document-properties.htm.
 
 == Rolled over to ChangeLog-2021-03-18 ==
+

Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp (283870 => 283871)


--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp	2021-10-09 21:35:21 UTC (rev 283870)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp	2021-10-09 22:01:37 UTC (rev 283871)
@@ -504,6 +504,7 @@
 
 void ArgumentCoder<RequestedScrollData>::encode(Encoder& encoder, const RequestedScrollData& scrollData)
 {
+    encoder << scrollData.requestType;
     encoder << scrollData.scrollPosition;
     encoder << scrollData.scrollType;
     encoder << scrollData.clamping;
@@ -512,6 +513,9 @@
 
 bool ArgumentCoder<RequestedScrollData>::decode(Decoder& decoder, RequestedScrollData& scrollData)
 {
+    if (!decoder.decode(scrollData.requestType))
+        return false;
+
     if (!decoder.decode(scrollData.scrollPosition))
         return false;
 
@@ -728,9 +732,13 @@
 
     if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateNode::Property::RequestedScrollPosition)) {
         const auto& requestedScrollData = node.requestedScrollData();
-        ts.dumpProperty("requested-scroll-position", requestedScrollData.scrollPosition);
-        ts.dumpProperty("requested-scroll-position-is-programatic", requestedScrollData.scrollType);
-        ts.dumpProperty("requested-scroll-position-clamping", requestedScrollData.clamping);
+        if (requestedScrollData.requestType == ScrollRequestType::CancelAnimatedScroll)
+            ts.dumpProperty("requested-type", "cancel animated scroll");
+        else {
+            ts.dumpProperty("requested-scroll-position", requestedScrollData.scrollPosition);
+            ts.dumpProperty("requested-scroll-position-is-programatic", requestedScrollData.scrollType);
+            ts.dumpProperty("requested-scroll-position-clamping", requestedScrollData.clamping);
+        }
     }
 
     if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateNode::Property::ScrollContainerLayer))
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to