Changeset 270838 in webkit
- Timestamp:
- Dec 15, 2020 6:34:27 AM (19 months ago)
- Location:
- trunk
- Files:
-
- 14 added
- 16 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-with-keyboard-expected.txt (added)
-
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-with-keyboard-scaled-expected.txt (added)
-
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-with-keyboard-scaled.html (added)
-
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-with-keyboard.html (added)
-
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-with-keyboard-expected.txt (added)
-
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-with-keyboard-scaled-expected.txt (added)
-
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-with-keyboard-scaled.html (added)
-
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-with-keyboard.html (added)
-
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-mainframe-horizontal-with-keyboard-expected.txt (added)
-
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-mainframe-horizontal-with-keyboard.html (added)
-
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-mainframe-vertical-with-keyboard-expected.txt (added)
-
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-mainframe-vertical-with-keyboard.html (added)
-
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-overflow-rtl-with-keyboard-expected.txt (added)
-
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-overflow-rtl-with-keyboard.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/page/FrameView.cpp (modified) (1 diff)
-
Source/WebCore/page/FrameView.h (modified) (1 diff)
-
Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.cpp (modified) (2 diffs)
-
Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.h (modified) (2 diffs)
-
Source/WebCore/platform/ScrollAnimator.cpp (modified) (5 diffs)
-
Source/WebCore/platform/ScrollAnimator.h (modified) (4 diffs)
-
Source/WebCore/platform/ScrollableArea.cpp (modified) (1 diff)
-
Source/WebCore/platform/ScrollableArea.h (modified) (1 diff)
-
Source/WebCore/platform/cocoa/ScrollController.h (modified) (2 diffs)
-
Source/WebCore/platform/cocoa/ScrollController.mm (modified) (1 diff)
-
Source/WebCore/platform/generic/ScrollAnimatorGeneric.cpp (modified) (1 diff)
-
Source/WebCore/platform/generic/ScrollAnimatorGeneric.h (modified) (1 diff)
-
Source/WebCore/platform/mac/ScrollAnimatorMac.h (modified) (1 diff)
-
Source/WebCore/platform/mac/ScrollAnimatorMac.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r270837 r270838 1 2020-12-15 Martin Robinson <mrobinson@webkit.org> 2 3 CSS Scroll Snap is not in effect when the user scrolls via the keyboard 4 https://bugs.webkit.org/show_bug.cgi?id=198566 5 <rdar://problem/51488088> 6 7 Reviewed by Simon Fraser. 8 9 Add support for scroll snap for keyboard scrolling 10 11 This change adds support for the concept of directional scroll snapping, 12 which will never snap to a snap point that is away from the original 13 scroll offset in the opposite direction of the scroll direction. This 14 allows escaping snap points. 15 16 * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-with-keyboard-expected.txt: Added. 17 * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-with-keyboard-scaled-expected.txt: Added. 18 * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-with-keyboard-scaled.html: Added. 19 * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-with-keyboard.html: Added. 20 * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-with-keyboard-expected.txt: Added. 21 * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-with-keyboard-scaled-expected.txt: Added. 22 * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-with-keyboard-scaled.html: Added. 23 * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-with-keyboard.html: Added. 24 * tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-mainframe-horizontal-with-keyboard-expected.txt: Added. 25 * tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-mainframe-horizontal-with-keyboard.html: Added. 26 * tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-mainframe-vertical-with-keyboard-expected.txt: Added. 27 * tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-mainframe-vertical-with-keyboard.html: Added. 28 * tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-overflow-rtl-with-keyboard-expected.txt: Added. 29 * tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-overflow-rtl-with-keyboard.html: Added. 30 1 31 2020-12-15 Antoine Quint <graouts@webkit.org> 2 32 -
trunk/Source/WebCore/ChangeLog
r270837 r270838 1 2020-12-15 Martin Robinson <mrobinson@webkit.org> 2 3 CSS Scroll Snap is not in effect when the user scrolls via the keyboard 4 https://bugs.webkit.org/show_bug.cgi?id=198566 5 <rdar://problem/51488088> 6 7 Reviewed by Simon Fraser. 8 9 Add support for scroll snap for keyboard scrolling 10 11 This change adds support for the concept of directional scroll snapping, 12 which will never snap to a snap point that is away from the original 13 scroll offset in the opposite direction of the scroll direction. This 14 allows escaping snap points. 15 16 Tests: tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-with-keyboard-scaled.html 17 tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-with-keyboard.html 18 tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-with-keyboard-scaled.html 19 tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-with-keyboard.html 20 tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-mainframe-horizontal-with-keyboard.html 21 tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-mainframe-vertical-with-keyboard.html 22 tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-overflow-rtl-with-keyboard.html 23 24 * page/FrameView.cpp: 25 (WebCore::FrameView::pageScaleFactor const): Added. 26 * page/FrameView.h: Added scale factor getter. 27 * page/scrolling/ScrollSnapOffsetsInfo.cpp: 28 (WebCore::closestSnapOffset): Added a new optional argument that signals 29 directional snapping. This changes the behavior when choosing a snap offset 30 that is in the opposite direction as the scroll direction. 31 * page/scrolling/ScrollSnapOffsetsInfo.h: 32 * platform/ScrollAnimator.cpp: 33 (WebCore::ScrollAnimator::scroll): 34 * page/scrolling/ScrollSnapOffsetsInfo.h: 35 (WebCore::ScrollAnimator::scroll): No longer use the granularity argument. 36 (WebCore::ScrollAnimator::scrollWithoutAnimation): Remove the unused ScrollGranularity 37 argument and use the new positionFromStep helper. 38 (WebCore::ScrollAnimator::scrollWithDirectionalSnapping): Added. 39 (WebCore::ScrollAnimator::positionFromStep): Added this helper. 40 (WebCore::ScrollAnimator::handleWheelEvent): Remove the granularity argument. 41 (WebCore::ScrollAnimator::pageScaleFactor const): Added this implementation 42 of a ScrollControllerClient method. 43 * platform/ScrollAnimator.h: Update method declarations. 44 * platform/ScrollableArea.cpp: 45 (WebCore::ScrollableArea::scroll): Use the new argument to the scroll method. 46 * platform/cocoa/ScrollController.h: Added new method. 47 (WebCore::ScrollableArea::pageScaleFactor const): 48 * platform/cocoa/ScrollController.h: 49 * platform/cocoa/ScrollController.mm: 50 (WebCore::ScrollController::adjustScrollDestinationForDirectionalSnapping): Added. 51 * platform/mac/ScrollAnimatorMac.h: 52 * platform/mac/ScrollAnimatorMac.mm: 53 (WebCore::ScrollAnimatorMac::scroll): Use new positionFromStep helper. 54 1 55 2020-12-15 Antoine Quint <graouts@webkit.org> 2 56 -
trunk/Source/WebCore/page/FrameView.cpp
r270557 r270838 5533 5533 } 5534 5534 5535 float FrameView::pageScaleFactor() const 5536 { 5537 return frame().frameScaleFactor(); 5538 } 5539 5535 5540 } // namespace WebCore 5536 5541 -
trunk/Source/WebCore/page/FrameView.h
r270557 r270838 849 849 void didFinishProhibitingScrollingWhenChangingContentSize() final; 850 850 851 // ScrollableArea. 852 float pageScaleFactor() const override; 853 851 854 static MonotonicTime sCurrentPaintTimeStamp; // used for detecting decoded resource thrash in the cache 852 855 -
trunk/Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.cpp
r270390 r270838 101 101 102 102 template <typename LayoutType> 103 LayoutType closestSnapOffset(const Vector<LayoutType>& snapOffsets, const Vector<ScrollOffsetRange<LayoutType>>& snapOffsetRanges, LayoutType scrollDestination, float velocity, unsigned& activeSnapIndex)103 static LayoutType closestSnapOffset(const Vector<LayoutType>& snapOffsets, const Vector<ScrollOffsetRange<LayoutType>>& snapOffsetRanges, LayoutType scrollDestination, float velocity, unsigned& activeSnapIndex, Optional<LayoutType> originalPositionForDirectionalSnapping) 104 104 { 105 105 ASSERT(snapOffsets.size()); … … 133 133 134 134 // Non-zero velocity indicates a flick gesture. Even if another snap point is closer, we should choose the one in the direction of the flick gesture 135 // as long as a scroll snap offset range does not lie between the scroll destination and the targeted snap offset. 135 // as long as a scroll snap offset range does not lie between the scroll destination and the targeted snap offset. If we are doing directional 136 // snapping, we should never snap to a point that was on the other side of the original position in the opposite direction of this scroll. 137 // This allows directional scrolling to escape snap points. 136 138 if (velocity < 0) { 137 if (lowerSnapOffsetRangeIndex != invalidSnapOffsetIndex && lowerSnapPosition < snapOffsetRanges[lowerSnapOffsetRangeIndex].end) { 139 if (lowerSnapOffsetRangeIndex == invalidSnapOffsetIndex || lowerSnapPosition >= snapOffsetRanges[lowerSnapOffsetRangeIndex].end) { 140 activeSnapIndex = lowerIndex; 141 return lowerSnapPosition; 142 } 143 144 if (!originalPositionForDirectionalSnapping.hasValue() || *originalPositionForDirectionalSnapping > upperSnapPosition) { 138 145 activeSnapIndex = upperIndex; 139 146 return upperSnapPosition; 140 147 } 141 activeSnapIndex = lowerIndex; 142 return lowerSnapPosition; 143 } 144 145 if (upperSnapOffsetRangeIndex != invalidSnapOffsetIndex && snapOffsetRanges[upperSnapOffsetRangeIndex].start < upperSnapPosition) { 146 activeSnapIndex = lowerIndex; 147 return lowerSnapPosition; 148 } 149 activeSnapIndex = upperIndex; 150 return upperSnapPosition; 151 } 152 153 LayoutUnit closestSnapOffset(const Vector<LayoutUnit>& snapOffsets, const Vector<ScrollOffsetRange<LayoutUnit>>& snapOffsetRanges, LayoutUnit scrollDestination, float velocity, unsigned& activeSnapIndex) 154 { 155 return closestSnapOffset<LayoutUnit>(snapOffsets, snapOffsetRanges, scrollDestination, velocity, activeSnapIndex); 156 } 157 158 float closestSnapOffset(const Vector<float>& snapOffsets, const Vector<ScrollOffsetRange<float>>& snapOffsetRanges, float scrollDestination, float velocity, unsigned& activeSnapIndex) 159 { 160 return closestSnapOffset<float>(snapOffsets, snapOffsetRanges, scrollDestination, velocity, activeSnapIndex); 148 } else { 149 if (upperSnapOffsetRangeIndex == invalidSnapOffsetIndex || snapOffsetRanges[upperSnapOffsetRangeIndex].start >= upperSnapPosition) { 150 activeSnapIndex = upperIndex; 151 return upperSnapPosition; 152 } 153 154 if (!originalPositionForDirectionalSnapping.hasValue() || *originalPositionForDirectionalSnapping < lowerSnapPosition) { 155 activeSnapIndex = lowerIndex; 156 return lowerSnapPosition; 157 } 158 } 159 160 activeSnapIndex = invalidSnapOffsetIndex; 161 return scrollDestination; 162 } 163 164 LayoutUnit closestSnapOffset(const Vector<LayoutUnit>& snapOffsets, const Vector<ScrollOffsetRange<LayoutUnit>>& snapOffsetRanges, LayoutUnit scrollDestination, float velocity, unsigned& activeSnapIndex, Optional<LayoutUnit> originalPositionForDirectionalSnapping) 165 { 166 return closestSnapOffset<LayoutUnit>(snapOffsets, snapOffsetRanges, scrollDestination, velocity, activeSnapIndex, originalPositionForDirectionalSnapping); 167 } 168 169 float closestSnapOffset(const Vector<float>& snapOffsets, const Vector<ScrollOffsetRange<float>>& snapOffsetRanges, float scrollDestination, float velocity, unsigned& activeSnapIndex, Optional<float> originalPositionForDirectionalSnapping) 170 { 171 return closestSnapOffset<float>(snapOffsets, snapOffsetRanges, scrollDestination, velocity, activeSnapIndex, originalPositionForDirectionalSnapping); 161 172 } 162 173 -
trunk/Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.h
r270390 r270838 30 30 #include "LayoutUnit.h" 31 31 #include "StyleScrollSnapPoints.h" 32 #include <wtf/Optional.h> 32 33 #include <wtf/Vector.h> 33 34 … … 66 67 void updateSnapOffsetsForScrollableArea(ScrollableArea&, const RenderBox& scrollingElementBox, const RenderStyle& scrollingElementStyle, LayoutRect viewportRectInBorderBoxCoordinates); 67 68 68 WEBCORE_EXPORT LayoutUnit closestSnapOffset(const Vector<LayoutUnit>& snapOffsets, const Vector<ScrollOffsetRange<LayoutUnit>>& snapOffsetRanges, LayoutUnit scrollDestination, float velocity, unsigned& activeSnapIndex );69 WEBCORE_EXPORT float closestSnapOffset(const Vector<float>& snapOffsets, const Vector<ScrollOffsetRange<float>>& snapOffsetRanges, float scrollDestination, float velocity, unsigned& activeSnapIndex );69 WEBCORE_EXPORT LayoutUnit closestSnapOffset(const Vector<LayoutUnit>& snapOffsets, const Vector<ScrollOffsetRange<LayoutUnit>>& snapOffsetRanges, LayoutUnit scrollDestination, float velocity, unsigned& activeSnapIndex, Optional<LayoutUnit> originalPositionForDirectionalSnapping = WTF::nullopt); 70 WEBCORE_EXPORT float closestSnapOffset(const Vector<float>& snapOffsets, const Vector<ScrollOffsetRange<float>>& snapOffsetRanges, float scrollDestination, float velocity, unsigned& activeSnapIndex, Optional<float> originalPositionForDirectionalSnapping = WTF::nullopt); 70 71 71 72 }; // namespace WebCore -
trunk/Source/WebCore/platform/ScrollAnimator.cpp
r269659 r270838 81 81 } 82 82 83 bool ScrollAnimator::scroll(ScrollbarOrientation orientation, ScrollGranularity granularity, float step, float multiplier) 84 { 85 return scrollWithoutAnimation(orientation, granularity, step, multiplier); 86 } 87 88 bool ScrollAnimator::scrollWithoutAnimation(ScrollbarOrientation orientation, ScrollGranularity, float step, float multiplier) 83 bool ScrollAnimator::scroll(ScrollbarOrientation orientation, ScrollGranularity granularity, float step, float multiplier, ScrollBehavior behavior) 84 { 85 #if ENABLE(CSS_SCROLL_SNAP) 86 if (behavior != ScrollBehavior::DoDirectionalSnapping) 87 return scrollWithoutAnimation(orientation, step, multiplier); 88 89 FloatSize scrollOrigin = toFloatSize(m_scrollableArea.scrollOrigin()); 90 FloatPoint newPosition = positionFromStep(orientation, step, multiplier); 91 auto newOffset = ScrollableArea::scrollOffsetFromPosition(newPosition, scrollOrigin); 92 auto currentOffset = ScrollableArea::scrollOffsetFromPosition(this->currentPosition(), scrollOrigin); 93 if (orientation == HorizontalScrollbar) { 94 newOffset.setX(m_scrollController.adjustScrollDestinationForDirectionalSnapping(ScrollEventAxis::Horizontal, newOffset.x(), multiplier, currentOffset.x())); 95 newPosition = ScrollableArea::scrollPositionFromOffset(newOffset, scrollOrigin); 96 return scroll(HorizontalScrollbar, granularity, newPosition.x() - this->currentPosition().x(), 1.0); 97 } 98 99 newOffset.setY(m_scrollController.adjustScrollDestinationForDirectionalSnapping(ScrollEventAxis::Vertical, newPosition.y(), multiplier, currentOffset.y())); 100 newPosition = ScrollableArea::scrollPositionFromOffset(newOffset, scrollOrigin); 101 return scroll(VerticalScrollbar, granularity, newPosition.y() - this->currentPosition().y(), 1.0); 102 #else 103 UNUSED_PARAM(granularity); 104 UNUSED_PARAM(behavior); 105 return scrollWithoutAnimation(orientation, step, multiplier); 106 #endif 107 } 108 109 bool ScrollAnimator::scrollWithoutAnimation(ScrollbarOrientation orientation, float step, float multiplier) 89 110 { 90 111 FloatPoint currentPosition = this->currentPosition(); 112 FloatPoint newPosition = positionFromStep(orientation, step, multiplier); 113 newPosition = newPosition.constrainedBetween(m_scrollableArea.minimumScrollPosition(), m_scrollableArea.maximumScrollPosition()); 114 if (currentPosition == newPosition) 115 return false; 116 117 m_currentPosition = newPosition; 118 notifyPositionChanged(newPosition - currentPosition); 119 return true; 120 } 121 122 void ScrollAnimator::scrollToOffset(const FloatPoint& offset) 123 { 124 m_animationProgrammaticScroll->setCurrentPosition(m_currentPosition); 125 auto newPosition = ScrollableArea::scrollPositionFromOffset(offset, toFloatSize(m_scrollableArea.scrollOrigin())); 126 m_animationProgrammaticScroll->scroll(newPosition); 127 m_scrollableArea.setScrollBehaviorStatus(ScrollBehaviorStatus::InNonNativeAnimation); 128 } 129 130 void ScrollAnimator::scrollToOffsetWithoutAnimation(const FloatPoint& offset, ScrollClamping) 131 { 132 FloatPoint newPosition = ScrollableArea::scrollPositionFromOffset(offset, toFloatSize(m_scrollableArea.scrollOrigin())); 133 FloatSize delta = newPosition - currentPosition(); 134 m_currentPosition = newPosition; 135 notifyPositionChanged(delta); 136 updateActiveScrollSnapIndexForOffset(); 137 } 138 139 FloatPoint ScrollAnimator::positionFromStep(ScrollbarOrientation orientation, float step, float multiplier) 140 { 91 141 FloatSize delta; 92 142 if (orientation == HorizontalScrollbar) … … 94 144 else 95 145 delta.setHeight(step * multiplier); 96 97 FloatPoint newPosition = FloatPoint(currentPosition + delta).constrainedBetween(m_scrollableArea.minimumScrollPosition(), m_scrollableArea.maximumScrollPosition()); 98 if (currentPosition == newPosition) 99 return false; 100 101 m_currentPosition = newPosition; 102 notifyPositionChanged(newPosition - currentPosition); 103 return true; 104 } 105 106 void ScrollAnimator::scrollToOffset(const FloatPoint& offset) 107 { 108 m_animationProgrammaticScroll->setCurrentPosition(m_currentPosition); 109 auto newPosition = ScrollableArea::scrollPositionFromOffset(offset, toFloatSize(m_scrollableArea.scrollOrigin())); 110 m_animationProgrammaticScroll->scroll(newPosition); 111 m_scrollableArea.setScrollBehaviorStatus(ScrollBehaviorStatus::InNonNativeAnimation); 112 } 113 114 void ScrollAnimator::scrollToOffsetWithoutAnimation(const FloatPoint& offset, ScrollClamping) 115 { 116 FloatPoint newPosition = ScrollableArea::scrollPositionFromOffset(offset, toFloatSize(m_scrollableArea.scrollOrigin())); 117 FloatSize delta = newPosition - currentPosition(); 118 m_currentPosition = newPosition; 119 notifyPositionChanged(delta); 120 updateActiveScrollSnapIndexForOffset(); 146 return this->currentPosition() + delta; 121 147 } 122 148 … … 183 209 } 184 210 if (e.hasPreciseScrollingDeltas()) 185 scrollWithoutAnimation(VerticalScrollbar, granularity,verticalScrollbar->pixelStep(), -deltaY);211 scrollWithoutAnimation(VerticalScrollbar, verticalScrollbar->pixelStep(), -deltaY); 186 212 else 187 213 scroll(VerticalScrollbar, granularity, verticalScrollbar->pixelStep(), -deltaY); … … 196 222 } 197 223 if (e.hasPreciseScrollingDeltas()) 198 scrollWithoutAnimation(HorizontalScrollbar, granularity,horizontalScrollbar->pixelStep(), -deltaX);224 scrollWithoutAnimation(HorizontalScrollbar, horizontalScrollbar->pixelStep(), -deltaX); 199 225 else 200 226 scroll(HorizontalScrollbar, granularity, horizontalScrollbar->pixelStep(), -deltaX); … … 272 298 } 273 299 300 float ScrollAnimator::pageScaleFactor() const 301 { 302 return m_scrollableArea.pageScaleFactor(); 303 } 274 304 #endif 275 305 -
trunk/Source/WebCore/platform/ScrollAnimator.h
r269143 r270838 68 68 virtual ~ScrollAnimator(); 69 69 70 enum ScrollBehavior { 71 Default, 72 DoDirectionalSnapping, 73 }; 74 70 75 // Computes a scroll destination for the given parameters. Returns false if 71 76 // already at the destination. Otherwise, starts scrolling towards the 72 77 // destination and returns true. Scrolling may be immediate or animated. 73 78 // The base class implementation always scrolls immediately, never animates. 74 virtual bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier );75 bool scrollWithoutAnimation(ScrollbarOrientation, ScrollGranularity,float step, float multiplier);79 virtual bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier, ScrollBehavior = ScrollBehavior::Default); 80 bool scrollWithoutAnimation(ScrollbarOrientation, float step, float multiplier); 76 81 77 82 void scrollToOffset(const FloatPoint&); … … 134 139 void setWheelEventTestMonitor(RefPtr<WheelEventTestMonitor>&& testMonitor) { m_wheelEventTestMonitor = testMonitor; } 135 140 136 #if (ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING)) && PLATFORM(MAC)137 void deferWheelEventTestCompletionForReason(WheelEventTestMonitor::ScrollableAreaIdentifier, WheelEventTestMonitor::DeferReason) const override;138 void removeWheelEventTestCompletionDeferralForReason(WheelEventTestMonitor::ScrollableAreaIdentifier, WheelEventTestMonitor::DeferReason) const override;139 #endif140 141 141 #if ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING) 142 142 std::unique_ptr<ScrollControllerTimer> createTimer(Function<void()>&&) final; … … 148 148 #endif 149 149 void updateScrollSnapState(); 150 bool activeScrollSnapIndexDidChange() const; 151 unsigned activeScrollSnapIndexForAxis(ScrollEventAxis) const; 152 #endif 153 154 // ScrollControllerClient. 155 #if ENABLE(CSS_SCROLL_SNAP) 150 156 FloatPoint scrollOffset() const override; 151 157 void immediateScrollOnAxis(ScrollEventAxis, float delta) override; 152 bool activeScrollSnapIndexDidChange() const; 153 unsigned activeScrollSnapIndexForAxis(ScrollEventAxis) const; 158 float pageScaleFactor() const override; 154 159 LayoutSize scrollExtent() const override; 155 160 FloatSize viewportSize() const override; 161 #endif 162 #if (ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING)) && PLATFORM(MAC) 163 void deferWheelEventTestCompletionForReason(WheelEventTestMonitor::ScrollableAreaIdentifier, WheelEventTestMonitor::DeferReason) const override; 164 void removeWheelEventTestCompletionDeferralForReason(WheelEventTestMonitor::ScrollableAreaIdentifier, WheelEventTestMonitor::DeferReason) const override; 156 165 #endif 157 166 … … 159 168 virtual void notifyPositionChanged(const FloatSize& delta); 160 169 void updateActiveScrollSnapIndexForOffset(); 170 FloatPoint positionFromStep(ScrollbarOrientation, float step, float multiplier); 161 171 162 172 ScrollableArea& m_scrollableArea; -
trunk/Source/WebCore/platform/ScrollableArea.cpp
r270389 r270838 141 141 142 142 step = adjustScrollStepForFixedContent(step, orientation, granularity); 143 return scrollAnimator().scroll(orientation, granularity, step, multiplier );143 return scrollAnimator().scroll(orientation, granularity, step, multiplier, ScrollAnimator::ScrollBehavior::DoDirectionalSnapping); 144 144 } 145 145 -
trunk/Source/WebCore/platform/ScrollableArea.h
r270390 r270838 356 356 virtual String debugDescription() const = 0; 357 357 358 virtual float pageScaleFactor() const 359 { 360 return 1.0f; 361 } 362 358 363 protected: 359 364 WEBCORE_EXPORT ScrollableArea(); -
trunk/Source/WebCore/platform/cocoa/ScrollController.h
r269559 r270838 109 109 virtual void didStopScrollSnapAnimation() { } 110 110 111 virtual float pageScaleFactor() const 112 { 113 return 1.0f; 114 } 111 virtual float pageScaleFactor() const = 0; 115 112 116 113 virtual unsigned activeScrollOffsetIndex(ScrollEventAxis) const … … 168 165 unsigned activeScrollSnapIndexForAxis(ScrollEventAxis) const; 169 166 void updateScrollSnapState(const ScrollableArea&); 170 171 167 void updateGestureInProgressState(const PlatformWheelEvent&); 172 168 float adjustScrollDestinationForDirectionalSnapping(ScrollEventAxis, float destination, float velocity, float originalPosition); 173 169 #if PLATFORM(MAC) 174 170 bool processWheelEventForScrollSnap(const PlatformWheelEvent&); -
trunk/Source/WebCore/platform/cocoa/ScrollController.mm
r270389 r270838 906 906 } 907 907 908 float ScrollController::adjustScrollDestinationForDirectionalSnapping(ScrollEventAxis axis, float destination, float velocity, float originalPosition) 909 { 910 if (!usesScrollSnap()) 911 return destination; 912 913 ScrollSnapAnimatorState& snapState = *m_scrollSnapState; 914 auto snapOffsets = snapState.snapOffsetsForAxis(axis); 915 if (!snapOffsets.size()) 916 return destination; 917 918 unsigned snapIndex; 919 LayoutUnit offset = closestSnapOffset(snapState.snapOffsetsForAxis(axis), snapState.snapOffsetRangesForAxis(axis), LayoutUnit(destination / m_client.pageScaleFactor()), velocity, snapIndex, LayoutUnit(originalPosition / m_client.pageScaleFactor())); 920 return offset * m_client.pageScaleFactor(); 921 } 922 923 908 924 void ScrollController::setActiveScrollSnapIndicesForOffset(ScrollOffset offset) 909 925 { -
trunk/Source/WebCore/platform/generic/ScrollAnimatorGeneric.cpp
r268522 r270838 95 95 96 96 #if ENABLE(SMOOTH_SCROLLING) 97 bool ScrollAnimatorGeneric::scroll(ScrollbarOrientation orientation, ScrollGranularity granularity, float step, float multiplier )97 bool ScrollAnimatorGeneric::scroll(ScrollbarOrientation orientation, ScrollGranularity granularity, float step, float multiplier, ScrollBehavior behavior) 98 98 { 99 99 if (!m_scrollableArea.scrollAnimatorEnabled()) 100 100 return ScrollAnimator::scroll(orientation, granularity, step, multiplier); 101 102 // This method doesn't do directional snapping, but our base class does. It will call into 103 // ScrollAnimatorGeneric::scroll again with the snapped positions and ScrollBehavior::Default. 104 if (behavior == ScrollBehavior::DoDirectionalSnapping) 105 return ScrollAnimator::scroll(orientation, granularity, step, multiplier, behavior); 101 106 102 107 ensureSmoothScrollingAnimation(); -
trunk/Source/WebCore/platform/generic/ScrollAnimatorGeneric.h
r259112 r270838 46 46 private: 47 47 #if ENABLE(SMOOTH_SCROLLING) 48 bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier ) override;48 bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier, ScrollBehavior) override; 49 49 #endif 50 50 void scrollToOffsetWithoutAnimation(const FloatPoint&, ScrollClamping) override; -
trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h
r269373 r270838 80 80 FloatSize m_contentAreaScrolledTimerScrollDelta; 81 81 82 bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier ) override;82 bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier, ScrollBehavior) override; 83 83 void scrollToOffsetWithoutAnimation(const FloatPoint&, ScrollClamping) override; 84 84 -
trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm
r269659 r270838 780 780 #endif 781 781 782 bool ScrollAnimatorMac::scroll(ScrollbarOrientation orientation, ScrollGranularity granularity, float step, float multiplier )782 bool ScrollAnimatorMac::scroll(ScrollbarOrientation orientation, ScrollGranularity granularity, float step, float multiplier, ScrollBehavior behavior) 783 783 { 784 784 m_haveScrolledSincePageLoad = true; 785 785 786 786 if (!scrollAnimationEnabledForSystem() || !m_scrollableArea.scrollAnimatorEnabled()) 787 return ScrollAnimator::scroll(orientation, granularity, step, multiplier );787 return ScrollAnimator::scroll(orientation, granularity, step, multiplier, behavior); 788 788 789 789 if (granularity == ScrollByPixel) 790 return ScrollAnimator::scroll(orientation, granularity, step, multiplier); 790 return ScrollAnimator::scroll(orientation, granularity, step, multiplier, behavior); 791 792 // This method doesn't do directional snapping, but our base class does. It will call into 793 // ScrollAnimatorMac::scroll again with the snapped positions and ScrollBehavior::Default. 794 if (behavior == ScrollBehavior::DoDirectionalSnapping) 795 return ScrollAnimator::scroll(orientation, granularity, step, multiplier, behavior); 791 796 792 797 FloatPoint currentPosition = this->currentPosition(); 793 FloatSize delta; 794 if (orientation == HorizontalScrollbar) 795 delta.setWidth(step * multiplier); 796 else 797 delta.setHeight(step * multiplier); 798 799 FloatPoint newPosition = FloatPoint(currentPosition + delta).constrainedBetween(m_scrollableArea.minimumScrollPosition(), m_scrollableArea.maximumScrollPosition()); 798 FloatPoint newPosition = positionFromStep(orientation, step, multiplier); 799 newPosition = newPosition.constrainedBetween(m_scrollableArea.minimumScrollPosition(), m_scrollableArea.maximumScrollPosition()); 800 800 if (currentPosition == newPosition) 801 801 return false;
Note: See TracChangeset
for help on using the changeset viewer.