Changeset 273690 in webkit
- Timestamp:
- Mar 1, 2021 1:32:19 PM (17 months ago)
- Location:
- trunk
- Files:
-
- 4 added
- 10 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/css3/scroll-snap/scroll-snap-click-scrollbar-gutter-expected.txt (added)
-
LayoutTests/css3/scroll-snap/scroll-snap-click-scrollbar-gutter.html (added)
-
LayoutTests/css3/scroll-snap/scroll-snap-drag-scrollbar-thumb-expected.txt (added)
-
LayoutTests/css3/scroll-snap/scroll-snap-drag-scrollbar-thumb.html (added)
-
LayoutTests/platform/ios-wk2/TestExpectations (modified) (1 diff)
-
LayoutTests/platform/ios/TestExpectations (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/platform/ScrollAnimationSmooth.cpp (modified) (1 diff)
-
Source/WebCore/platform/ScrollAnimator.cpp (modified) (3 diffs)
-
Source/WebCore/platform/ScrollAnimator.h (modified) (1 diff)
-
Source/WebCore/platform/ScrollableArea.cpp (modified) (1 diff)
-
Source/WebCore/platform/ScrollableArea.h (modified) (1 diff)
-
Source/WebCore/platform/Scrollbar.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r273687 r273690 1 2021-03-01 Martin Robinson <mrobinson@webkit.org> 2 3 Scroll snapping doesn't kick in when dragging scrollbars 4 https://bugs.webkit.org/show_bug.cgi?id=146696 5 6 Reviewed by Simon Fraser. 7 8 Add support for scroll snap after dragging scrollbar thumb 9 10 This change adds support for scroll snap when the scrollbar thumb is 11 released from a drag operation. This animation is currently done with 12 the non-native scroll animator for all platforms, since that is also 13 what is used for smooth scrolling. 14 15 This change adjusts the non-native scroll animator's smoothness factor, 16 because it is too slow for short scroll snaps. I have verified that the 17 new smoothness factor is also a good selection for smooth scrolling 18 operations (still an experimental feature). A further change should use 19 "native" animations when possible for both smooth scrolling and scroll 20 snap after thumb drags. This is tracked by the following bug: 21 https://bugs.webkit.org/show_bug.cgi?id=218857 22 23 * css3/scroll-snap/scroll-snap-click-scrollbar-gutter-expected.txt: Added. 24 * css3/scroll-snap/scroll-snap-click-scrollbar-gutter.html: Added. 25 * css3/scroll-snap/scroll-snap-drag-scrollbar-thumb-expected.txt: Added. 26 * css3/scroll-snap/scroll-snap-drag-scrollbar-thumb.html: Added. 27 * platform/ios-wk2/TestExpectations: Mark new test as failing on iOS 28 which has issues with scrollbars. 29 * platform/ios/TestExpectations: Skip the new test on iOS which does not 30 support scrolling by dragging the scrollbar. 31 1 32 2021-03-01 Truitt Savell <tsavell@apple.com> 2 33 -
trunk/LayoutTests/platform/ios-wk2/TestExpectations
r273559 r273690 138 138 css3/scroll-snap/scroll-padding-mainframe-paging.html [ Failure ] 139 139 css3/scroll-snap/scroll-padding-overflow-paging.html [ Failure ] 140 css3/scroll-snap/scroll-snap-click-scrollbar-gutter.html [ Failure ] 140 141 141 142 # SVG tests that time out (these require EventSender) -
trunk/LayoutTests/platform/ios/TestExpectations
r273684 r273690 2349 2349 # iOS does not allow you to scroll by dragging the scrollbar thumb. 2350 2350 webkit.org/b/157201 fast/scrolling/rtl-drag-vertical-scroller.html [ Failure ] 2351 webkit.org/b/157201 css3/scroll-snap/scroll-snap-drag-scrollbar-thumb.html [ Failure ] 2351 2352 2352 2353 # DumpRenderTree doesn't support logging calls to runOpenPanel and iOS's WebKitTestRunner doesn't support eventSender.mouseDown. -
trunk/Source/WebCore/ChangeLog
r273688 r273690 1 2021-03-01 Martin Robinson <mrobinson@webkit.org> 2 3 Scroll snapping doesn't kick in when dragging scrollbars 4 https://bugs.webkit.org/show_bug.cgi?id=146696 5 6 Reviewed by Simon Fraser. 7 8 This change adds support for scroll snap when the scrollbar thumb is 9 released from a drag operation. This animation is currently done with 10 the non-native scroll animator for all platforms, since that is also 11 what is used for smooth scrolling. 12 13 This change adjusts the non-native scroll animator's smoothness factor, 14 because it is too slow for short scroll snaps. I have verified that the 15 new smoothness factor is also a good selection for smooth scrolling 16 operations (still an experimental feature). A further change should use 17 "native" animations when possible for both smooth scrolling and scroll 18 snap after thumb drags. This is tracked by the following bug: 19 https://bugs.webkit.org/show_bug.cgi?id=218857 20 21 Tests: css3/scroll-snap/scroll-snap-click-scrollbar-gutter.html 22 css3/scroll-snap/scroll-snap-drag-scrollbar-thumb.html 23 24 * platform/ScrollAnimationSmooth.cpp: Modify smoothFactorForProgrammaticScroll to 25 a value that is good for both scroll snapping and smooth scrolling. 26 * platform/ScrollAnimator.cpp: The tick method for the non-native scroll animation 27 should continually update the current active snap point. 28 (WebCore::ScrollAnimator::adjustScrollOffsetForSnappingIfNeeded): Split this into 29 two methods. One that handles a single axis and one that handles both. 30 * platform/ScrollAnimator.h: Update method declarations. 31 * platform/ScrollableArea.cpp: 32 (WebCore::ScrollableArea::doPostThumbDragSnapping): Added this method which does 33 axial snapping after a scrollbar thum drag. 34 * platform/ScrollableArea.h: 35 * platform/Scrollbar.cpp: 36 (WebCore::Scrollbar::mouseUp): Use the new doPostThumbDragSnapping method. 37 1 38 2021-03-01 Sam Weinig <weinig@apple.com> 2 39 -
trunk/Source/WebCore/platform/ScrollAnimationSmooth.cpp
r268522 r273690 41 41 static const Seconds tickTime = 1_s / frameRate; 42 42 static const Seconds minimumTimerInterval { 1_ms }; 43 static const double smoothFactorForProgrammaticScroll = 5;43 static const double smoothFactorForProgrammaticScroll = 1; 44 44 45 45 ScrollAnimationSmooth::PerAxisData::PerAxisData(ScrollbarOrientation orientation, const FloatPoint& position, ScrollExtentsCallback& extentsCallback) -
trunk/Source/WebCore/platform/ScrollAnimator.cpp
r273275 r273690 67 67 m_currentPosition = WTFMove(position); 68 68 notifyPositionChanged(delta); 69 updateActiveScrollSnapIndexForOffset(); 69 70 }, 70 71 [this] { … … 363 364 return offset; 364 365 365 Optional<float> originalXOffset, originalYOffset;366 FloatSize velocity;367 if (method == ScrollSnapPointSelectionMethod::Directional) {368 FloatSize scrollOrigin = toFloatSize(m_scrollableArea.scrollOrigin());369 auto currentOffset = ScrollableArea::scrollOffsetFromPosition(this->currentPosition(), scrollOrigin);370 originalXOffset = currentOffset.x();371 originalYOffset = currentOffset.y();372 velocity = { offset.x() - currentOffset.x(), offset.y() - currentOffset.y() };373 }374 375 366 FloatPoint newOffset = offset; 376 newOffset.setX( m_scrollController.adjustScrollDestination(ScrollEventAxis::Horizontal, newOffset.x(), velocity.width(), originalXOffset));377 newOffset.setY( m_scrollController.adjustScrollDestination(ScrollEventAxis::Vertical, newOffset.y(), velocity.height(), originalYOffset));367 newOffset.setX(adjustScrollOffsetForSnappingIfNeeded(ScrollEventAxis::Horizontal, newOffset.x(), method)); 368 newOffset.setY(adjustScrollOffsetForSnappingIfNeeded(ScrollEventAxis::Vertical, newOffset.y(), method)); 378 369 return newOffset; 379 370 #else … … 383 374 } 384 375 376 float ScrollAnimator::adjustScrollOffsetForSnappingIfNeeded(ScrollEventAxis axis, float newOffset, ScrollSnapPointSelectionMethod method) 377 { 378 #if ENABLE(CSS_SCROLL_SNAP) 379 if (!m_scrollController.usesScrollSnap()) 380 return newOffset; 381 382 Optional<float> originalOffset; 383 float velocity = 0.; 384 if (method == ScrollSnapPointSelectionMethod::Directional) { 385 FloatSize scrollOrigin = toFloatSize(m_scrollableArea.scrollOrigin()); 386 auto currentOffset = ScrollableArea::scrollOffsetFromPosition(this->currentPosition(), scrollOrigin); 387 originalOffset = axis == ScrollEventAxis::Horizontal ? currentOffset.x() : currentOffset.y(); 388 velocity = newOffset - (axis == ScrollEventAxis::Horizontal ? currentOffset.x() : currentOffset.y()); 389 } 390 391 return m_scrollController.adjustScrollDestination(axis, newOffset, velocity, originalOffset); 392 #else 393 UNUSED_PARAM(method); 394 UNUSED_PARAM(axis); 395 return newOffset; 396 #endif 397 } 398 385 399 386 400 } // namespace WebCore -
trunk/Source/WebCore/platform/ScrollAnimator.h
r273275 r273690 143 143 144 144 FloatPoint adjustScrollOffsetForSnappingIfNeeded(const FloatPoint& offset, ScrollSnapPointSelectionMethod); 145 float adjustScrollOffsetForSnappingIfNeeded(ScrollEventAxis, float newOffset, ScrollSnapPointSelectionMethod); 145 146 146 147 #if ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING) -
trunk/Source/WebCore/platform/ScrollableArea.cpp
r273275 r273690 558 558 } 559 559 } 560 561 void ScrollableArea::doPostThumbMoveSnapping(ScrollbarOrientation orientation) 562 { 563 if (!usesScrollSnap()) 564 return; 565 566 auto currentOffset = scrollOffset(); 567 auto newOffset = currentOffset; 568 if (orientation == HorizontalScrollbar) 569 newOffset.setX(m_scrollAnimator->adjustScrollOffsetForSnappingIfNeeded(ScrollEventAxis::Horizontal, currentOffset.x(), ScrollSnapPointSelectionMethod::Closest)); 570 else 571 newOffset.setY(m_scrollAnimator->adjustScrollOffsetForSnappingIfNeeded(ScrollEventAxis::Vertical, currentOffset.y(), ScrollSnapPointSelectionMethod::Closest)); 572 if (newOffset == currentOffset) 573 return; 574 575 scrollAnimator().scrollToOffsetWithAnimation(newOffset); 576 } 560 577 #else 561 578 void ScrollableArea::updateScrollSnapState() 579 { 580 } 581 582 void ScrollableArea::doPostThumbMoveSnapping(ScrollbarOrientation) 562 583 { 563 584 } -
trunk/Source/WebCore/platform/ScrollableArea.h
r273275 r273690 104 104 105 105 void updateScrollSnapState(); 106 void doPostThumbMoveSnapping(ScrollbarOrientation); 106 107 107 108 #if ENABLE(TOUCH_EVENTS) -
trunk/Source/WebCore/platform/Scrollbar.cpp
r259761 r273690 357 357 bool Scrollbar::mouseUp(const PlatformMouseEvent& mouseEvent) 358 358 { 359 auto previouslyPressedPart = m_pressedPart; 359 360 setPressedPart(NoPart); 360 361 m_pressedPos = 0; … … 369 370 if (part == NoPart) 370 371 m_scrollableArea.mouseExitedScrollbar(this); 372 373 if (previouslyPressedPart == ThumbPart) 374 m_scrollableArea.doPostThumbMoveSnapping(m_orientation); 371 375 372 376 return true;
Note: See TracChangeset
for help on using the changeset viewer.