Changeset 274381 in webkit
- Timestamp:
- Mar 13, 2021 1:31:19 AM (16 months ago)
- Location:
- trunk
- Files:
-
- 2 added
- 8 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/css3/scroll-snap/scroll-snap-wheel-event-expected.txt (added)
-
LayoutTests/css3/scroll-snap/scroll-snap-wheel-event.html (added)
-
LayoutTests/platform/ios-wk2/TestExpectations (modified) (2 diffs)
-
LayoutTests/platform/mac-wk1/fast/scrolling/latching/scroll-snap-latching-expected.txt (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/platform/ScrollAnimator.cpp (modified) (8 diffs)
-
Source/WebCore/platform/ScrollAnimator.h (modified) (3 diffs)
-
Source/WebCore/platform/mac/ScrollAnimatorMac.h (modified) (2 diffs)
-
Source/WebCore/platform/mac/ScrollAnimatorMac.mm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r274379 r274381 1 2021-03-13 Martin Robinson <mrobinson@webkit.org> 2 3 Add basic (non-momentum) wheel event handling for scroll snap 4 https://bugs.webkit.org/show_bug.cgi?id=222594 5 Reviewed by Simon Fraser. 6 7 * css3/scroll-snap/scroll-snap-wheel-event-expected.txt: Added. 8 * css3/scroll-snap/scroll-snap-wheel-event.html: Added. 9 * platform/ios-wk2/TestExpectations: Skip new test because it uses mouse event simulation. 10 Move existing classification to better section as well. 11 * platform/mac-wk1/fast/scrolling/latching/scroll-snap-latching-expected.txt: Rebased this previous failing test. 12 1 13 2021-03-13 Alexey Shvayka <shvaikalesh@gmail.com> 2 14 -
trunk/LayoutTests/platform/ios-wk2/TestExpectations
r273932 r274381 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 ]141 140 142 141 # SVG tests that time out (these require EventSender) … … 934 933 editing/selection/select-out-of-floated-non-editable-11.html [ Skip ] 935 934 editing/selection/select-out-of-floated-non-editable-12.html [ Skip ] 935 css3/scroll-snap/scroll-snap-click-scrollbar-gutter.html [ Skip ] 936 css3/scroll-snap/scroll-snap-wheel-event.html [ Skip ] 936 937 937 938 webkit.org/b/192088 media/no-fullscreen-when-hidden.html [ Failure Pass ] -
trunk/LayoutTests/platform/mac-wk1/fast/scrolling/latching/scroll-snap-latching-expected.txt
r271072 r274381 5 5 6 6 PASS overflowScrollEventCount > 0 is true 7 FAIL windowScrollEventCount should be 0. Was 7.7 FAIL windowScrollEventCount should be 0. Was 11. 8 8 PASS successfullyParsed is true 9 9 -
trunk/Source/WebCore/ChangeLog
r274379 r274381 1 2021-03-13 Martin Robinson <mrobinson@webkit.org> 2 3 Add basic (non-momentum) wheel event handling for scroll snap 4 https://bugs.webkit.org/show_bug.cgi?id=222594 5 6 Reviewed by Simon Fraser. 7 8 Test: css3/scroll-snap/scroll-snap-wheel-event.html 9 10 Enable scroll snapping for basic wheel events on GTK+ and WPE. The Mac port 11 has special wheel handling due to momentum scrolling. Other scroll-snap-enabled 12 ports can just use a basic version. 13 14 * platform/ScrollAnimator.cpp: 15 (WebCore::ScrollAnimator::scroll): Accept a bitmask of options now. This 16 will allow using this method when handling wheel events that do not animate. 17 (WebCore::ScrollAnimator::handleWheelEvent): Trigger ::scroll with 18 scroll snapping enabled and pass the appropriate option to disable animations. 19 (WebCore::ScrollAnimator::processWheelEventForScrollSnap): Deleted. 20 * platform/ScrollAnimator.h: 21 (WebCore::ScrollAnimator::ScrollAnimator::processWheelEventForScrollSnap): Made 22 this a method that can be overridden by subclasses. 23 * platform/mac/ScrollAnimatorMac.h: Added processWheelEventForScrollSnap. 24 * platform/mac/ScrollAnimatorMac.mm: 25 (WebCore::ScrollAnimatorMac::scroll): Pay attention to the NeverAnimate bitmask now. 26 (WebCore::ScrollAnimatorMac::processWheelEventForScrollSnap): Added. 27 1 28 2021-03-13 Alexey Shvayka <shvaikalesh@gmail.com> 2 29 -
trunk/Source/WebCore/platform/ScrollAnimator.cpp
r273733 r274381 82 82 } 83 83 84 bool ScrollAnimator::scroll(ScrollbarOrientation orientation, ScrollGranularity granularity, float step, float multiplier, ScrollBehaviorbehavior)85 { 86 #if ENABLE(CSS_SCROLL_SNAP) 87 if (behavior == ScrollBehavior::DoDirectionalSnapping) {84 bool ScrollAnimator::scroll(ScrollbarOrientation orientation, ScrollGranularity granularity, float step, float multiplier, OptionSet<ScrollBehavior> behavior) 85 { 86 #if ENABLE(CSS_SCROLL_SNAP) 87 if (behavior.contains(ScrollBehavior::DoDirectionalSnapping)) { 88 88 auto newOffset = ScrollableArea::scrollOffsetFromPosition(positionFromStep(orientation, step, multiplier), toFloatSize(m_scrollableArea.scrollOrigin())); 89 89 auto currentOffset = m_scrollableArea.scrollOffset(); 90 behavior.remove(ScrollBehavior::DoDirectionalSnapping); 90 91 if (orientation == HorizontalScrollbar) { 91 92 newOffset.setX(m_scrollController.adjustScrollDestination(ScrollEventAxis::Horizontal, newOffset.x(), multiplier, currentOffset.x())); 92 return scroll(HorizontalScrollbar, granularity, newOffset.x() - currentOffset.x(), 1.0 );93 return scroll(HorizontalScrollbar, granularity, newOffset.x() - currentOffset.x(), 1.0, behavior); 93 94 } 94 95 newOffset.setY(m_scrollController.adjustScrollDestination(ScrollEventAxis::Vertical, newOffset.y(), multiplier, currentOffset.y())); 95 return scroll(VerticalScrollbar, granularity, newOffset.y() - currentOffset.y(), 1.0 );96 return scroll(VerticalScrollbar, granularity, newOffset.y() - currentOffset.y(), 1.0, behavior); 96 97 } 97 98 #else … … 101 102 102 103 #if ENABLE(SMOOTH_SCROLLING) && !PLATFORM(IOS_FAMILY) 103 if (m_scrollableArea.scrollAnimatorEnabled() ) {104 if (m_scrollableArea.scrollAnimatorEnabled() && !behavior.contains(ScrollBehavior::NeverAnimate)) { 104 105 m_scrollAnimation->setCurrentPosition(m_currentPosition); 105 106 return m_scrollAnimation->scroll(orientation, granularity, step, multiplier); … … 161 162 #if ENABLE(CSS_SCROLL_SNAP) 162 163 #if PLATFORM(MAC) 163 bool ScrollAnimator::processWheelEventForScrollSnap(const PlatformWheelEvent& wheelEvent)164 {165 return m_scrollController.processWheelEventForScrollSnap(wheelEvent);166 }167 164 #endif 168 165 … … 180 177 bool ScrollAnimator::handleWheelEvent(const PlatformWheelEvent& e) 181 178 { 182 #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)183 if ( m_scrollController.processWheelEventForScrollSnap(e))179 #if ENABLE(CSS_SCROLL_SNAP) 180 if (processWheelEventForScrollSnap(e)) 184 181 return false; 185 182 #endif 183 186 184 #if PLATFORM(COCOA) 187 185 // Events in the PlatformWheelEventPhase::MayBegin phase have no deltas, and therefore never passes through the scroll handling logic below. … … 204 202 bool handled = false; 205 203 206 ScrollGranularity granularity = ScrollByPixel;207 204 IntSize maxForwardScrollDelta = m_scrollableArea.maximumScrollPosition() - m_scrollableArea.scrollPosition(); 208 205 IntSize maxBackwardScrollDelta = m_scrollableArea.scrollPosition() - m_scrollableArea.minimumScrollPosition(); … … 213 210 handled = true; 214 211 212 OptionSet<ScrollBehavior> behavior(ScrollBehavior::DoDirectionalSnapping); 213 if (e.hasPreciseScrollingDeltas()) 214 behavior.add(ScrollBehavior::NeverAnimate); 215 215 216 if (deltaY) { 216 217 if (e.granularity() == ScrollByPageWheelEvent) { … … 220 221 deltaY = -deltaY; 221 222 } 222 if (e.hasPreciseScrollingDeltas()) 223 scrollToPositionWithoutAnimation(positionFromStep(VerticalScrollbar, verticalScrollbar->pixelStep(), -deltaY)); 224 else 225 scroll(VerticalScrollbar, granularity, verticalScrollbar->pixelStep(), -deltaY); 223 scroll(VerticalScrollbar, ScrollByPixel, verticalScrollbar->pixelStep(), -deltaY, behavior); 226 224 } 227 225 … … 233 231 deltaX = -deltaX; 234 232 } 235 if (e.hasPreciseScrollingDeltas()) 236 scrollToPositionWithoutAnimation(positionFromStep(HorizontalScrollbar, horizontalScrollbar->pixelStep(), -deltaX)); 237 else 238 scroll(HorizontalScrollbar, granularity, horizontalScrollbar->pixelStep(), -deltaX); 233 scroll(HorizontalScrollbar, ScrollByPixel, horizontalScrollbar->pixelStep(), -deltaX, behavior); 239 234 } 240 235 } -
trunk/Source/WebCore/platform/ScrollAnimator.h
r273733 r274381 70 70 71 71 enum ScrollBehavior { 72 Default, 73 DoDirectionalSnapping, 72 Default = 0, 73 DoDirectionalSnapping = 1 << 1, 74 NeverAnimate = 1 << 2, 74 75 }; 75 76 … … 78 79 // destination and returns true. Scrolling may be immediate or animated. 79 80 // The base class implementation always scrolls immediately, never animates. 80 virtual bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier, ScrollBehavior = ScrollBehavior::Default);81 virtual bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier, OptionSet<ScrollBehavior>); 81 82 82 83 bool scrollToOffsetWithoutAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped); … … 150 151 151 152 #if ENABLE(CSS_SCROLL_SNAP) 152 #if PLATFORM(MAC) 153 bool processWheelEventForScrollSnap(const PlatformWheelEvent&); 154 #endif 153 virtual bool processWheelEventForScrollSnap(const PlatformWheelEvent&) { return false; } 155 154 void updateScrollSnapState(); 156 155 bool activeScrollSnapIndexDidChange() const; -
trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h
r273275 r274381 80 80 FloatSize m_contentAreaScrolledTimerScrollDelta; 81 81 82 bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier, ScrollBehavior) override;82 bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier, OptionSet<ScrollBehavior>) override; 83 83 bool scrollToPositionWithAnimation(const FloatPoint&) override; 84 84 bool scrollToPositionWithoutAnimation(const FloatPoint& position, ScrollClamping = ScrollClamping::Clamped) override; … … 141 141 String verticalScrollbarStateForTesting() const final; 142 142 143 bool processWheelEventForScrollSnap(const PlatformWheelEvent&) override; 144 143 145 // ScrollControllerClient. 144 146 #if ENABLE(RUBBER_BANDING) -
trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm
r273657 r274381 752 752 #endif 753 753 754 bool ScrollAnimatorMac::scroll(ScrollbarOrientation orientation, ScrollGranularity granularity, float step, float multiplier, ScrollBehaviorbehavior)754 bool ScrollAnimatorMac::scroll(ScrollbarOrientation orientation, ScrollGranularity granularity, float step, float multiplier, OptionSet<ScrollBehavior> behavior) 755 755 { 756 756 m_haveScrolledSincePageLoad = true; … … 758 758 // This method doesn't do directional snapping, but our base class does. It will call into 759 759 // ScrollAnimatorMac::scroll again with the snapped positions and ScrollBehavior::Default. 760 if (behavior == ScrollBehavior::DoDirectionalSnapping)760 if (behavior.contains(ScrollBehavior::DoDirectionalSnapping)) 761 761 return ScrollAnimator::scroll(orientation, granularity, step, multiplier, behavior); 762 762 763 bool shouldAnimate = scrollAnimationEnabledForSystem() && m_scrollableArea.scrollAnimatorEnabled() && granularity != ScrollByPixel; 763 bool shouldAnimate = scrollAnimationEnabledForSystem() && m_scrollableArea.scrollAnimatorEnabled() && granularity != ScrollByPixel 764 && !behavior.contains(ScrollBehavior::NeverAnimate); 764 765 FloatPoint newPosition = positionFromStep(orientation, step, multiplier); 765 766 newPosition = newPosition.constrainedBetween(scrollableArea().minimumScrollPosition(), scrollableArea().maximumScrollPosition()); … … 1501 1502 } 1502 1503 1504 bool ScrollAnimatorMac::processWheelEventForScrollSnap(const PlatformWheelEvent& wheelEvent) 1505 { 1506 return m_scrollController.processWheelEventForScrollSnap(wheelEvent); 1507 } 1508 1503 1509 } // namespace WebCore 1504 1510
Note: See TracChangeset
for help on using the changeset viewer.