Diff
Modified: trunk/LayoutTests/ChangeLog (273689 => 273690)
--- trunk/LayoutTests/ChangeLog 2021-03-01 21:29:20 UTC (rev 273689)
+++ trunk/LayoutTests/ChangeLog 2021-03-01 21:32:19 UTC (rev 273690)
@@ -1,3 +1,34 @@
+2021-03-01 Martin Robinson <[email protected]>
+
+ Scroll snapping doesn't kick in when dragging scrollbars
+ https://bugs.webkit.org/show_bug.cgi?id=146696
+
+ Reviewed by Simon Fraser.
+
+ Add support for scroll snap after dragging scrollbar thumb
+
+ This change adds support for scroll snap when the scrollbar thumb is
+ released from a drag operation. This animation is currently done with
+ the non-native scroll animator for all platforms, since that is also
+ what is used for smooth scrolling.
+
+ This change adjusts the non-native scroll animator's smoothness factor,
+ because it is too slow for short scroll snaps. I have verified that the
+ new smoothness factor is also a good selection for smooth scrolling
+ operations (still an experimental feature). A further change should use
+ "native" animations when possible for both smooth scrolling and scroll
+ snap after thumb drags. This is tracked by the following bug:
+ https://bugs.webkit.org/show_bug.cgi?id=218857
+
+ * css3/scroll-snap/scroll-snap-click-scrollbar-gutter-expected.txt: Added.
+ * css3/scroll-snap/scroll-snap-click-scrollbar-gutter.html: Added.
+ * css3/scroll-snap/scroll-snap-drag-scrollbar-thumb-expected.txt: Added.
+ * css3/scroll-snap/scroll-snap-drag-scrollbar-thumb.html: Added.
+ * platform/ios-wk2/TestExpectations: Mark new test as failing on iOS
+ which has issues with scrollbars.
+ * platform/ios/TestExpectations: Skip the new test on iOS which does not
+ support scrolling by dragging the scrollbar.
+
2021-03-01 Truitt Savell <[email protected]>
media/media-fullscreen-pause-inline.html is flaky failing
Added: trunk/LayoutTests/css3/scroll-snap/scroll-snap-click-scrollbar-gutter-expected.txt (0 => 273690)
--- trunk/LayoutTests/css3/scroll-snap/scroll-snap-click-scrollbar-gutter-expected.txt (rev 0)
+++ trunk/LayoutTests/css3/scroll-snap/scroll-snap-click-scrollbar-gutter-expected.txt 2021-03-01 21:32:19 UTC (rev 273690)
@@ -0,0 +1,6 @@
+PASS clicking the horizontal scrollbar gutter snapped
+PASS dragging the vertical scrollbar thumb snapped
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/css3/scroll-snap/scroll-snap-click-scrollbar-gutter.html (0 => 273690)
--- trunk/LayoutTests/css3/scroll-snap/scroll-snap-click-scrollbar-gutter.html (rev 0)
+++ trunk/LayoutTests/css3/scroll-snap/scroll-snap-click-scrollbar-gutter.html 2021-03-01 21:32:19 UTC (rev 273690)
@@ -0,0 +1,102 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Clicking in the scrollbar gutter should trigger scroll snapping</title>
+ <style type="text/css">
+ /* Use customized scrollbar to avoid platform differences. */
+ ::-webkit-scrollbar {
+ width: 20px;
+ height: 20px;
+ }
+ ::-webkit-scrollbar-button {
+ height: 0px;
+ width: 0px;
+ }
+
+ ::-webkit-scrollbar-track-piece {
+ background-color: gray;
+ }
+
+ ::-webkit-scrollbar-thumb {
+ height: 20px;
+ width: 20px;
+ background-color: black;
+ }
+
+ body {
+ margin: 0px;
+ }
+
+ .container {
+ height: 200px;
+ width: 200px;
+ overflow: auto;
+ scroll-snap-type: both mandatory;
+ }
+
+ .block {
+ height: 1000px;
+ width: 250px;
+ scroll-snap-align: start;
+ }
+
+ .horizontal-drawer {
+ height: 100%;
+ width: 2000px;
+ }
+
+ .horizontal-drawer .block {
+ width: 1000px;
+ height: 250px;
+ }
+ </style>
+ <script src=""
+ <script src=""
+ <script>
+ window.jsTestIsAsync = true;
+
+ async function onLoad()
+ {
+ if (window.eventSender == undefined) {
+ document.getElementById('console').innerText = "Clicking in the scrollbar gutter should trigger scroll snapping.";
+ return;
+ }
+ try {
+ eventSender.mouseMoveTo(175, 190);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+
+ let horizontalContainer = document.getElementById("horizontal-container");
+ await UIHelper.waitForTargetScrollAnimationToSettle(horizontalContainer);
+ expectTrue(horizontalContainer.scrollLeft == 1000, "clicking the horizontal scrollbar gutter snapped");
+
+ eventSender.mouseMoveTo(190, 370);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ let verticalContainer = document.getElementById("vertical-container");
+ await UIHelper.waitForTargetScrollAnimationToSettle(verticalContainer);
+ expectTrue(verticalContainer.scrollTop == 1000, "dragging the vertical scrollbar thumb snapped");
+ } catch (e) {
+ console.log(e);
+ } finally {
+ finishJSTest();
+ }
+ }
+ </script>
+ </head>
+ <body _onload_="onLoad();">
+ <div id="horizontal-container" class="container">
+ <div class="horizontal-drawer">
+ <div class="block" style="float: left; background: #80475E"></div>
+ <div class="block" style="width: 450px; float: left; background: #CC5A71"></div>
+ </div>
+ </div>
+ <div id="vertical-container" class="container">
+ <div class="block" style="background: #80475E"></div>
+ <div class="block" style="height: 450px; background: #CC5A71"></div>
+ </div>
+ <p id="console"></p>
+ <script>
+ </script>
+ </body>
+</html>
Added: trunk/LayoutTests/css3/scroll-snap/scroll-snap-drag-scrollbar-thumb-expected.txt (0 => 273690)
--- trunk/LayoutTests/css3/scroll-snap/scroll-snap-drag-scrollbar-thumb-expected.txt (rev 0)
+++ trunk/LayoutTests/css3/scroll-snap/scroll-snap-drag-scrollbar-thumb-expected.txt 2021-03-01 21:32:19 UTC (rev 273690)
@@ -0,0 +1,6 @@
+PASS dragging the horizontal scrollbar thumb snapped
+PASS dragging the vertical scrollbar thumb snapped
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/css3/scroll-snap/scroll-snap-drag-scrollbar-thumb.html (0 => 273690)
--- trunk/LayoutTests/css3/scroll-snap/scroll-snap-drag-scrollbar-thumb.html (rev 0)
+++ trunk/LayoutTests/css3/scroll-snap/scroll-snap-drag-scrollbar-thumb.html 2021-03-01 21:32:19 UTC (rev 273690)
@@ -0,0 +1,100 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Dragging the scrollbar thumb should trigger scroll snapping</title>
+ <style type="text/css">
+ /* Use customized scrollbar to avoid platform differences. */
+ ::-webkit-scrollbar {
+ width: 20px;
+ height: 20px;
+ }
+ ::-webkit-scrollbar-button {
+ height: 20px;
+ width: 20px;
+ background-color: blue;
+ }
+
+ ::-webkit-scrollbar-track-piece {
+ background-color: gray;
+ }
+
+ ::-webkit-scrollbar-thumb {
+ height: 20px;
+ width: 20px;
+ background-color: black;
+ }
+
+ body {
+ margin: 0px;
+ }
+
+ .container {
+ height: 200px;
+ width: 200px;
+ overflow: auto;
+ scroll-snap-type: both mandatory;
+ }
+
+ .horizontal-drawer {
+ height: 100%;
+ width: 500px;
+ }
+
+ .block {
+ height: 100%;
+ width: 250px;
+ scroll-snap-align: start;
+ }
+ </style>
+ <script src=""
+ <script src=""
+ <script>
+ window.jsTestIsAsync = true;
+
+ async function onLoad()
+ {
+ if (window.eventSender == undefined) {
+ document.getElementById('console').innerText = "Dragging the scrollbar thumb should trigger scroll snapping.";
+ return;
+ }
+ try {
+ eventSender.mouseMoveTo(20, 190);
+ eventSender.mouseDown();
+ eventSender.mouseMoveTo(80, 190);
+ eventSender.mouseUp();
+
+ let horizontalContainer = document.getElementById("horizontal-container");
+ await UIHelper.waitForTargetScrollAnimationToSettle(horizontalContainer);
+ expectTrue(horizontalContainer.scrollLeft == 250, "dragging the horizontal scrollbar thumb snapped");
+
+ eventSender.mouseMoveTo(190, 220);
+ eventSender.mouseDown();
+ eventSender.mouseMoveTo(190, 270);
+ eventSender.mouseUp();
+ let verticalContainer = document.getElementById("vertical-container");
+ await UIHelper.waitForTargetScrollAnimationToSettle(verticalContainer);
+ expectTrue(verticalContainer.scrollTop == 180, "dragging the vertical scrollbar thumb snapped");
+ } catch (e) {
+ console.log(e);
+ } finally {
+ finishJSTest();
+ }
+ }
+ </script>
+ </head>
+ <body _onload_="onLoad();">
+ <div id="horizontal-container" class="container">
+ <div class="horizontal-drawer">
+ <div class="block" style="float: left; background: #80475E"></div>
+ <div class="block" style="float: left; background: #CC5A71"></div>
+ </div>
+ </div>
+ <div id="vertical-container" class="container">
+ <div class="block" style="background: #80475E"></div>
+ <div class="block" style="background: #CC5A71"></div>
+ </div>
+ <p id="console"></p>
+ <script>
+ </script>
+ </body>
+</html>
Modified: trunk/LayoutTests/platform/ios/TestExpectations (273689 => 273690)
--- trunk/LayoutTests/platform/ios/TestExpectations 2021-03-01 21:29:20 UTC (rev 273689)
+++ trunk/LayoutTests/platform/ios/TestExpectations 2021-03-01 21:32:19 UTC (rev 273690)
@@ -2348,6 +2348,7 @@
# iOS does not allow you to scroll by dragging the scrollbar thumb.
webkit.org/b/157201 fast/scrolling/rtl-drag-vertical-scroller.html [ Failure ]
+webkit.org/b/157201 css3/scroll-snap/scroll-snap-drag-scrollbar-thumb.html [ Failure ]
# DumpRenderTree doesn't support logging calls to runOpenPanel and iOS's WebKitTestRunner doesn't support eventSender.mouseDown.
fast/forms/file/open-file-panel.html [ Skip ]
Modified: trunk/LayoutTests/platform/ios-wk2/TestExpectations (273689 => 273690)
--- trunk/LayoutTests/platform/ios-wk2/TestExpectations 2021-03-01 21:29:20 UTC (rev 273689)
+++ trunk/LayoutTests/platform/ios-wk2/TestExpectations 2021-03-01 21:32:19 UTC (rev 273690)
@@ -137,6 +137,7 @@
scrollbars/scrollbars-on-positioned-content.html [ Failure ]
css3/scroll-snap/scroll-padding-mainframe-paging.html [ Failure ]
css3/scroll-snap/scroll-padding-overflow-paging.html [ Failure ]
+css3/scroll-snap/scroll-snap-click-scrollbar-gutter.html [ Failure ]
# SVG tests that time out (these require EventSender)
svg/animations/animVal-basics.html
Modified: trunk/Source/WebCore/ChangeLog (273689 => 273690)
--- trunk/Source/WebCore/ChangeLog 2021-03-01 21:29:20 UTC (rev 273689)
+++ trunk/Source/WebCore/ChangeLog 2021-03-01 21:32:19 UTC (rev 273690)
@@ -1,3 +1,40 @@
+2021-03-01 Martin Robinson <[email protected]>
+
+ Scroll snapping doesn't kick in when dragging scrollbars
+ https://bugs.webkit.org/show_bug.cgi?id=146696
+
+ Reviewed by Simon Fraser.
+
+ This change adds support for scroll snap when the scrollbar thumb is
+ released from a drag operation. This animation is currently done with
+ the non-native scroll animator for all platforms, since that is also
+ what is used for smooth scrolling.
+
+ This change adjusts the non-native scroll animator's smoothness factor,
+ because it is too slow for short scroll snaps. I have verified that the
+ new smoothness factor is also a good selection for smooth scrolling
+ operations (still an experimental feature). A further change should use
+ "native" animations when possible for both smooth scrolling and scroll
+ snap after thumb drags. This is tracked by the following bug:
+ https://bugs.webkit.org/show_bug.cgi?id=218857
+
+ Tests: css3/scroll-snap/scroll-snap-click-scrollbar-gutter.html
+ css3/scroll-snap/scroll-snap-drag-scrollbar-thumb.html
+
+ * platform/ScrollAnimationSmooth.cpp: Modify smoothFactorForProgrammaticScroll to
+ a value that is good for both scroll snapping and smooth scrolling.
+ * platform/ScrollAnimator.cpp: The tick method for the non-native scroll animation
+ should continually update the current active snap point.
+ (WebCore::ScrollAnimator::adjustScrollOffsetForSnappingIfNeeded): Split this into
+ two methods. One that handles a single axis and one that handles both.
+ * platform/ScrollAnimator.h: Update method declarations.
+ * platform/ScrollableArea.cpp:
+ (WebCore::ScrollableArea::doPostThumbDragSnapping): Added this method which does
+ axial snapping after a scrollbar thum drag.
+ * platform/ScrollableArea.h:
+ * platform/Scrollbar.cpp:
+ (WebCore::Scrollbar::mouseUp): Use the new doPostThumbDragSnapping method.
+
2021-03-01 Sam Weinig <[email protected]>
Add alternate, non-named-getter based, implementation of CSSStyleDeclaration back into WebCore
Modified: trunk/Source/WebCore/platform/ScrollAnimationSmooth.cpp (273689 => 273690)
--- trunk/Source/WebCore/platform/ScrollAnimationSmooth.cpp 2021-03-01 21:29:20 UTC (rev 273689)
+++ trunk/Source/WebCore/platform/ScrollAnimationSmooth.cpp 2021-03-01 21:32:19 UTC (rev 273690)
@@ -40,7 +40,7 @@
static const double frameRate = 60;
static const Seconds tickTime = 1_s / frameRate;
static const Seconds minimumTimerInterval { 1_ms };
-static const double smoothFactorForProgrammaticScroll = 5;
+static const double smoothFactorForProgrammaticScroll = 1;
ScrollAnimationSmooth::PerAxisData::PerAxisData(ScrollbarOrientation orientation, const FloatPoint& position, ScrollExtentsCallback& extentsCallback)
{
Modified: trunk/Source/WebCore/platform/ScrollAnimator.cpp (273689 => 273690)
--- trunk/Source/WebCore/platform/ScrollAnimator.cpp 2021-03-01 21:29:20 UTC (rev 273689)
+++ trunk/Source/WebCore/platform/ScrollAnimator.cpp 2021-03-01 21:32:19 UTC (rev 273690)
@@ -66,6 +66,7 @@
FloatSize delta = position - m_currentPosition;
m_currentPosition = WTFMove(position);
notifyPositionChanged(delta);
+ updateActiveScrollSnapIndexForOffset();
},
[this] {
m_scrollableArea.setScrollBehaviorStatus(ScrollBehaviorStatus::NotInAnimation);
@@ -362,23 +363,36 @@
if (!m_scrollController.usesScrollSnap())
return offset;
- Optional<float> originalXOffset, originalYOffset;
- FloatSize velocity;
+ FloatPoint newOffset = offset;
+ newOffset.setX(adjustScrollOffsetForSnappingIfNeeded(ScrollEventAxis::Horizontal, newOffset.x(), method));
+ newOffset.setY(adjustScrollOffsetForSnappingIfNeeded(ScrollEventAxis::Vertical, newOffset.y(), method));
+ return newOffset;
+#else
+ UNUSED_PARAM(method);
+ return offset;
+#endif
+}
+
+float ScrollAnimator::adjustScrollOffsetForSnappingIfNeeded(ScrollEventAxis axis, float newOffset, ScrollSnapPointSelectionMethod method)
+{
+#if ENABLE(CSS_SCROLL_SNAP)
+ if (!m_scrollController.usesScrollSnap())
+ return newOffset;
+
+ Optional<float> originalOffset;
+ float velocity = 0.;
if (method == ScrollSnapPointSelectionMethod::Directional) {
FloatSize scrollOrigin = toFloatSize(m_scrollableArea.scrollOrigin());
auto currentOffset = ScrollableArea::scrollOffsetFromPosition(this->currentPosition(), scrollOrigin);
- originalXOffset = currentOffset.x();
- originalYOffset = currentOffset.y();
- velocity = { offset.x() - currentOffset.x(), offset.y() - currentOffset.y() };
+ originalOffset = axis == ScrollEventAxis::Horizontal ? currentOffset.x() : currentOffset.y();
+ velocity = newOffset - (axis == ScrollEventAxis::Horizontal ? currentOffset.x() : currentOffset.y());
}
- FloatPoint newOffset = offset;
- newOffset.setX(m_scrollController.adjustScrollDestination(ScrollEventAxis::Horizontal, newOffset.x(), velocity.width(), originalXOffset));
- newOffset.setY(m_scrollController.adjustScrollDestination(ScrollEventAxis::Vertical, newOffset.y(), velocity.height(), originalYOffset));
- return newOffset;
+ return m_scrollController.adjustScrollDestination(axis, newOffset, velocity, originalOffset);
#else
UNUSED_PARAM(method);
- return offset;
+ UNUSED_PARAM(axis);
+ return newOffset;
#endif
}
Modified: trunk/Source/WebCore/platform/ScrollAnimator.h (273689 => 273690)
--- trunk/Source/WebCore/platform/ScrollAnimator.h 2021-03-01 21:29:20 UTC (rev 273689)
+++ trunk/Source/WebCore/platform/ScrollAnimator.h 2021-03-01 21:32:19 UTC (rev 273690)
@@ -142,6 +142,7 @@
void setWheelEventTestMonitor(RefPtr<WheelEventTestMonitor>&& testMonitor) { m_wheelEventTestMonitor = testMonitor; }
FloatPoint adjustScrollOffsetForSnappingIfNeeded(const FloatPoint& offset, ScrollSnapPointSelectionMethod);
+ float adjustScrollOffsetForSnappingIfNeeded(ScrollEventAxis, float newOffset, ScrollSnapPointSelectionMethod);
#if ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING)
std::unique_ptr<ScrollControllerTimer> createTimer(Function<void()>&&) final;
Modified: trunk/Source/WebCore/platform/ScrollableArea.cpp (273689 => 273690)
--- trunk/Source/WebCore/platform/ScrollableArea.cpp 2021-03-01 21:29:20 UTC (rev 273689)
+++ trunk/Source/WebCore/platform/ScrollableArea.cpp 2021-03-01 21:32:19 UTC (rev 273690)
@@ -557,10 +557,31 @@
scrollToPositionWithoutAnimation(correctedPosition);
}
}
+
+void ScrollableArea::doPostThumbMoveSnapping(ScrollbarOrientation orientation)
+{
+ if (!usesScrollSnap())
+ return;
+
+ auto currentOffset = scrollOffset();
+ auto newOffset = currentOffset;
+ if (orientation == HorizontalScrollbar)
+ newOffset.setX(m_scrollAnimator->adjustScrollOffsetForSnappingIfNeeded(ScrollEventAxis::Horizontal, currentOffset.x(), ScrollSnapPointSelectionMethod::Closest));
+ else
+ newOffset.setY(m_scrollAnimator->adjustScrollOffsetForSnappingIfNeeded(ScrollEventAxis::Vertical, currentOffset.y(), ScrollSnapPointSelectionMethod::Closest));
+ if (newOffset == currentOffset)
+ return;
+
+ scrollAnimator().scrollToOffsetWithAnimation(newOffset);
+}
#else
void ScrollableArea::updateScrollSnapState()
{
}
+
+void ScrollableArea::doPostThumbMoveSnapping(ScrollbarOrientation)
+{
+}
#endif
bool ScrollableArea::isPinnedForScrollDeltaOnAxis(float scrollDelta, ScrollEventAxis axis) const
Modified: trunk/Source/WebCore/platform/ScrollableArea.h (273689 => 273690)
--- trunk/Source/WebCore/platform/ScrollableArea.h 2021-03-01 21:29:20 UTC (rev 273689)
+++ trunk/Source/WebCore/platform/ScrollableArea.h 2021-03-01 21:32:19 UTC (rev 273690)
@@ -103,6 +103,7 @@
#endif
void updateScrollSnapState();
+ void doPostThumbMoveSnapping(ScrollbarOrientation);
#if ENABLE(TOUCH_EVENTS)
virtual bool handleTouchEvent(const PlatformTouchEvent&);
Modified: trunk/Source/WebCore/platform/Scrollbar.cpp (273689 => 273690)
--- trunk/Source/WebCore/platform/Scrollbar.cpp 2021-03-01 21:29:20 UTC (rev 273689)
+++ trunk/Source/WebCore/platform/Scrollbar.cpp 2021-03-01 21:32:19 UTC (rev 273690)
@@ -356,6 +356,7 @@
bool Scrollbar::mouseUp(const PlatformMouseEvent& mouseEvent)
{
+ auto previouslyPressedPart = m_pressedPart;
setPressedPart(NoPart);
m_pressedPos = 0;
m_draggingDocument = false;
@@ -369,6 +370,9 @@
if (part == NoPart)
m_scrollableArea.mouseExitedScrollbar(this);
+ if (previouslyPressedPart == ThumbPart)
+ m_scrollableArea.doPostThumbMoveSnapping(m_orientation);
+
return true;
}