Changeset 273275 in webkit
- Timestamp:
- Feb 22, 2021 1:39:40 PM (3 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r273272 r273275 1 2021-02-22 Martin Robinson <mrobinson@webkit.org> 2 3 Clean up ScrollableArea and ScrollAnimator API and convert less between offsets and positions 4 https://bugs.webkit.org/show_bug.cgi?id=222111 5 6 Reviewed by Simon Fraser. 7 8 Clean up the APIs exposed by ScrollableArea and ScrollAnimator to make them more 9 consistent. With this change it should be a bit easier to tell if a particular 10 method will trigger an animation or not. In addition, we accept positions (as 11 opposed to offsets) everywhere, which allows us to reduce the number of 12 offset <-> position conversions. 13 14 Finally, this change is also interesting for scroll snap, because it will 15 make it easier to use a native animation on MacOS to use for snapping after 16 scrollbar thumb dragging. 17 18 No new tests. This should not change behavior. 19 20 * page/FrameView.cpp: 21 (WebCore::FrameView::setScrollPosition): Use new ScrollableArea APIs that 22 accept positions. 23 (WebCore::FrameView::scrollToPositionWithAnimation): Added this version 24 of the method that uses positions. 25 (WebCore::FrameView::scrollToOffsetWithAnimation): Deleted. 26 * page/FrameView.h: Update method declaration. 27 * platform/ScrollAnimator.cpp: 28 (WebCore::ScrollAnimator::scroll): Simplified a little bit the code that handles 29 scroll snapping here. Unified scroll snap and non-scroll snap compilation paths. 30 (WebCore::ScrollAnimator::scrollToOffsetWithoutAnimation): This method 31 now converts to a position and then calls scrollToPositionWithoutAnimation. 32 (WebCore::ScrollAnimator::scrollToPositionWithoutAnimation): Split this out 33 from scrollToOffsetWithoutAnimation. 34 (WebCore::ScrollAnimator::scrollToOffsetWithAnimation): This method now 35 converts to a position and calls scrollToPositionWithAnimation. 36 (WebCore::ScrollAnimator::scrollToPositionWithAnimation): Split this 37 out from scrollToOffsetWithAnimation. 38 (WebCore::ScrollAnimator::handleWheelEvent): Call scrollToPositionWithAnimation 39 instead of using the scroll(...) method. 40 (WebCore::ScrollAnimator::notifyPositionChanged): Eliminate a conversion here. 41 (WebCore::ScrollAnimator::scrollWithoutAnimation): Deleted. 42 (WebCore::ScrollAnimator::scrollToOffset): Deleted. 43 * platform/ScrollAnimator.h: Update method list. 44 * platform/ScrollView.cpp: 45 (WebCore::ScrollView::updateScrollbars): Eliminate a conversion here. 46 * platform/ScrollableArea.cpp: 47 Removed scrollToOffsetWithAnimation and added two new methods scrollToPositionWithAnimation 48 and scrollToPositionWithoutAnimation. scrollToOffsetWithoutAnimation is still used 49 in quite a few places, so we maintain this. 50 (WebCore::ScrollableArea::setScrollOffsetFromInternals): Use setScrollPositionFromAnimation now. 51 (WebCore::ScrollableArea::setScrollPositionFromAnimation): Renamed from setScrollOffsetFromAnimation 52 and eliminated a mandatory cnoversion. 53 (WebCore::ScrollableArea::scrollToOffsetWithAnimation): Deleted. 54 (WebCore::ScrollableArea::setScrollOffsetFromAnimation): Deleted. 55 * platform/ScrollableArea.h: Update method declarations. 56 * platform/mac/ScrollAnimatorMac.h: Ditto. 57 * platform/mac/ScrollAnimatorMac.mm: 58 (WebCore::ScrollAnimatorMac::scroll): Handle calling into scrollToPositionWithoutAnimation 59 and scrollToPositionWithAnimation ourselves now that we have this API. This simplifies 60 program flow a bit. 61 (WebCore::ScrollAnimatorMac::scrollToPositionWithAnimation): 62 (WebCore::ScrollAnimatorMac::scrollToPositionWithoutAnimation): Expose these two new 63 methods which are part of the base class API now. 64 (WebCore::ScrollAnimatorMac::immediateScrollToPositionForScrollAnimation): Use 65 ScrollAnimator::scrollToPositionWithoutAnimation because it was the same as 66 immediateScrollToPosition. 67 (WebCore::ScrollAnimatorMac::scrollToOffsetWithoutAnimation): Deleted. 68 (WebCore::ScrollAnimatorMac::immediateScrollToPosition): Deleted. No longer used. 69 * rendering/RenderLayerScrollableArea.cpp: 70 (WebCore::RenderLayerScrollableArea::scrollToOffset): Unconditionally convert to a position 71 here. 72 (WebCore::RenderLayerScrollableArea::updateScrollInfoAfterLayout): Use ScrollableArea::scrollToPositionWithoutAnimation 73 because it eliminates one conversion between units. 74 1 75 2021-02-22 Peng Liu <peng.liu6@apple.com> 2 76 -
trunk/Source/WebCore/page/FrameView.cpp
r273220 r273275 2328 2328 2329 2329 ScrollOffset snappedOffset = ceiledIntPoint(scrollAnimator().adjustScrollOffsetForSnappingIfNeeded(scrollOffsetFromPosition(scrollPosition), options.snapPointSelectionMethod)); 2330 auto snappedPosition = scrollPositionFromOffset(snappedOffset); 2330 2331 2331 2332 if (options.animated == AnimatedScroll::Yes) 2332 scrollTo OffsetWithAnimation(snappedOffset, currentScrollType(), options.clamping);2333 scrollToPositionWithAnimation(snappedPosition, currentScrollType(), options.clamping); 2333 2334 else 2334 ScrollView::setScrollPosition(s crollPositionFromOffset(snappedOffset), options);2335 ScrollView::setScrollPosition(snappedPosition, options); 2335 2336 2336 2337 setCurrentScrollType(oldScrollType); … … 3764 3765 } 3765 3766 3766 void FrameView::scrollTo OffsetWithAnimation(const ScrollOffset& offset, ScrollType scrollType, ScrollClamping)3767 void FrameView::scrollToPositionWithAnimation(const ScrollPosition& position, ScrollType scrollType, ScrollClamping) 3767 3768 { 3768 3769 auto previousScrollType = currentScrollType(); … … 3771 3772 if (currentScrollBehaviorStatus() == ScrollBehaviorStatus::InNonNativeAnimation) 3772 3773 scrollAnimator().cancelAnimations(); 3773 if ( offset != this->scrollOffset())3774 ScrollableArea::scrollTo OffsetWithAnimation(offset);3774 if (position != this->scrollPosition()) 3775 ScrollableArea::scrollToPositionWithAnimation(position); 3775 3776 3776 3777 setCurrentScrollType(previousScrollType); -
trunk/Source/WebCore/page/FrameView.h
r273220 r273275 676 676 void renderLayerDidScroll(const RenderLayer&); 677 677 678 WEBCORE_EXPORT void scrollTo OffsetWithAnimation(const ScrollOffset&, ScrollType = ScrollType::Programmatic, ScrollClamping = ScrollClamping::Clamped);678 WEBCORE_EXPORT void scrollToPositionWithAnimation(const ScrollPosition&, ScrollType = ScrollType::Programmatic, ScrollClamping = ScrollClamping::Clamped); 679 679 680 680 bool inUpdateEmbeddedObjects() const { return m_inUpdateEmbeddedObjects; } -
trunk/Source/WebCore/platform/ScrollAnimator.cpp
r271496 r273275 84 84 { 85 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.adjustScrollDestination(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); 86 if (behavior == ScrollBehavior::DoDirectionalSnapping) { 87 auto newOffset = ScrollableArea::scrollOffsetFromPosition(positionFromStep(orientation, step, multiplier), toFloatSize(m_scrollableArea.scrollOrigin())); 88 auto currentOffset = m_scrollableArea.scrollOffset(); 89 if (orientation == HorizontalScrollbar) { 90 newOffset.setX(m_scrollController.adjustScrollDestination(ScrollEventAxis::Horizontal, newOffset.x(), multiplier, currentOffset.x())); 91 return scroll(HorizontalScrollbar, granularity, newOffset.x() - currentOffset.x(), 1.0); 92 } 93 newOffset.setY(m_scrollController.adjustScrollDestination(ScrollEventAxis::Vertical, newOffset.y(), multiplier, currentOffset.y())); 94 return scroll(VerticalScrollbar, granularity, newOffset.y() - currentOffset.y(), 1.0); 97 95 } 98 99 newOffset.setY(m_scrollController.adjustScrollDestination(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 96 #else 103 97 UNUSED_PARAM(granularity); 104 98 UNUSED_PARAM(behavior); 105 return scrollWithoutAnimation(orientation, step, multiplier); 106 #endif 107 } 108 109 bool ScrollAnimator::scrollWithoutAnimation(ScrollbarOrientation orientation, float step, float multiplier) 99 #endif 100 101 return scrollToPositionWithoutAnimation(positionFromStep(orientation, step, multiplier)); 102 } 103 104 bool ScrollAnimator::scrollToOffsetWithoutAnimation(const FloatPoint& offset, ScrollClamping clamping) 105 { 106 return scrollToPositionWithoutAnimation(ScrollableArea::scrollPositionFromOffset(offset, toFloatSize(scrollableArea().scrollOrigin())), clamping); 107 } 108 109 bool ScrollAnimator::scrollToPositionWithoutAnimation(const FloatPoint& position, ScrollClamping clamping) 110 110 { 111 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) 112 auto adjustedPosition = clamping == ScrollClamping::Clamped ? position.constrainedBetween(scrollableArea().minimumScrollPosition(), scrollableArea().maximumScrollPosition()) : position; 113 114 // FIXME: In some cases on iOS the ScrollableArea position is out of sync with the ScrollAnimator position. 115 // When these cases are fixed, this extra check against the ScrollableArea position can be removed. 116 if (adjustedPosition == currentPosition && adjustedPosition == scrollableArea().scrollPosition() && !scrollableArea().scrollOriginChanged()) 115 117 return false; 116 118 117 m_currentPosition = newPosition; 118 notifyPositionChanged(newPosition - currentPosition); 119 m_currentPosition = adjustedPosition; 120 notifyPositionChanged(adjustedPosition - currentPosition); 121 updateActiveScrollSnapIndexForOffset(); 119 122 return true; 120 123 } 121 124 122 void ScrollAnimator::scrollToOffset(const FloatPoint& offset) 123 { 125 bool ScrollAnimator::scrollToOffsetWithAnimation(const FloatPoint& offset) 126 { 127 return scrollToPositionWithAnimation(ScrollableArea::scrollPositionFromOffset(offset, toFloatSize(scrollableArea().scrollOrigin()))); 128 } 129 130 bool ScrollAnimator::scrollToPositionWithAnimation(const FloatPoint& newPosition) 131 { 132 bool positionChanged = newPosition != currentPosition(); 133 if (!positionChanged && !scrollableArea().scrollOriginChanged()) 134 return false; 135 124 136 m_animationProgrammaticScroll->setCurrentPosition(m_currentPosition); 125 auto newPosition = ScrollableArea::scrollPositionFromOffset(offset, toFloatSize(m_scrollableArea.scrollOrigin()));126 137 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(); 138 scrollableArea().setScrollBehaviorStatus(ScrollBehaviorStatus::InNonNativeAnimation); 139 return true; 137 140 } 138 141 … … 209 212 } 210 213 if (e.hasPreciseScrollingDeltas()) 211 scroll WithoutAnimation(VerticalScrollbar, verticalScrollbar->pixelStep(), -deltaY);214 scrollToPositionWithoutAnimation(positionFromStep(VerticalScrollbar, verticalScrollbar->pixelStep(), -deltaY)); 212 215 else 213 216 scroll(VerticalScrollbar, granularity, verticalScrollbar->pixelStep(), -deltaY); … … 222 225 } 223 226 if (e.hasPreciseScrollingDeltas()) 224 scroll WithoutAnimation(HorizontalScrollbar, horizontalScrollbar->pixelStep(), -deltaX);227 scrollToPositionWithoutAnimation(positionFromStep(HorizontalScrollbar, horizontalScrollbar->pixelStep(), -deltaX)); 225 228 else 226 229 scroll(HorizontalScrollbar, granularity, horizontalScrollbar->pixelStep(), -deltaX); … … 258 261 { 259 262 UNUSED_PARAM(delta); 260 // FIXME: need to not map back and forth all the time. 261 m_scrollableArea.setScrollOffsetFromAnimation(m_scrollableArea.scrollOffsetFromPosition(roundedIntPoint(currentPosition()))); 263 m_scrollableArea.setScrollPositionFromAnimation(roundedIntPoint(currentPosition())); 262 264 263 265 #if ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING) -
trunk/Source/WebCore/platform/ScrollAnimator.h
r271439 r273275 79 79 // The base class implementation always scrolls immediately, never animates. 80 80 virtual bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier, ScrollBehavior = ScrollBehavior::Default); 81 bool scrollWithoutAnimation(ScrollbarOrientation, float step, float multiplier);82 81 83 void scrollToOffset(const FloatPoint&); 84 virtual void scrollToOffsetWithoutAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped); 82 bool scrollToOffsetWithoutAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped); 83 virtual bool scrollToPositionWithoutAnimation(const FloatPoint& position, ScrollClamping = ScrollClamping::Clamped); 84 85 bool scrollToOffsetWithAnimation(const FloatPoint&); 86 virtual bool scrollToPositionWithAnimation(const FloatPoint&); 85 87 86 88 ScrollableArea& scrollableArea() const { return m_scrollableArea; } -
trunk/Source/WebCore/platform/ScrollView.cpp
r271788 r273275 598 598 599 599 if (adjustedScrollPosition != scrollPosition() || scrollOriginChanged()) { 600 ScrollableArea::scrollTo OffsetWithoutAnimation(scrollOffsetFromPosition(adjustedScrollPosition));600 ScrollableArea::scrollToPositionWithoutAnimation(adjustedScrollPosition); 601 601 resetScrollOriginChanged(); 602 602 } -
trunk/Source/WebCore/platform/ScrollableArea.cpp
r272610 r273275 144 144 } 145 145 146 void ScrollableArea::scrollToOffsetWithAnimation(const FloatPoint& offset, ScrollClamping) 147 { 148 LOG_WITH_STREAM(Scrolling, stream << "ScrollableArea " << this << " scrollToOffsetWithAnimation " << offset); 149 scrollAnimator().scrollToOffset(offset); 146 void ScrollableArea::scrollToPositionWithoutAnimation(const FloatPoint& position, ScrollClamping clamping) 147 { 148 LOG_WITH_STREAM(Scrolling, stream << "ScrollableArea " << this << " scrollToPositionWithoutAnimation " << position); 149 scrollAnimator().scrollToPositionWithoutAnimation(position, clamping); 150 } 151 152 void ScrollableArea::scrollToPositionWithAnimation(const FloatPoint& position, ScrollClamping) 153 { 154 LOG_WITH_STREAM(Scrolling, stream << "ScrollableArea " << this << " scrollToPositionWithAnimation " << position); 155 scrollAnimator().scrollToPositionWithAnimation(position); 150 156 } 151 157 … … 160 166 auto currentOffset = scrollOffsetFromPosition(IntPoint(scrollAnimator().currentPosition())); 161 167 if (orientation == HorizontalScrollbar) 162 scroll ToOffsetWithoutAnimation(FloatPoint(offset, currentOffset.y()));168 scrollAnimator().scrollToOffsetWithoutAnimation(FloatPoint(offset, currentOffset.y())); 163 169 else 164 scroll ToOffsetWithoutAnimation(FloatPoint(currentOffset.x(), offset));170 scrollAnimator().scrollToOffsetWithoutAnimation(FloatPoint(currentOffset.x(), offset)); 165 171 } 166 172 … … 231 237 void ScrollableArea::setScrollOffsetFromInternals(const ScrollOffset& offset) 232 238 { 233 setScrollOffsetFromAnimation(offset); 234 } 235 236 void ScrollableArea::setScrollOffsetFromAnimation(const ScrollOffset& offset) 237 { 238 ScrollPosition position = scrollPositionFromOffset(offset); 239 239 setScrollPositionFromAnimation(scrollPositionFromOffset(offset)); 240 } 241 242 void ScrollableArea::setScrollPositionFromAnimation(const ScrollPosition& position) 243 { 240 244 auto scrollType = currentScrollType(); 241 245 auto clamping = scrollType == ScrollType::User ? ScrollClamping::Unclamped : ScrollClamping::Clamped; … … 551 555 if (correctedPosition != currentPosition) { 552 556 LOG_WITH_STREAM(ScrollSnap, stream << " adjusting position from " << currentPosition << " to " << correctedPosition); 553 scrollTo OffsetWithoutAnimation(correctedPosition);557 scrollToPositionWithoutAnimation(correctedPosition); 554 558 } 555 559 } -
trunk/Source/WebCore/platform/ScrollableArea.h
r272610 r273275 72 72 73 73 WEBCORE_EXPORT bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1); 74 WEBCORE_EXPORT void scrollToOffsetWithAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped); 74 WEBCORE_EXPORT void scrollToPositionWithAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped); 75 WEBCORE_EXPORT void scrollToPositionWithoutAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped); 76 75 77 WEBCORE_EXPORT void scrollToOffsetWithoutAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped); 76 78 void scrollToOffsetWithoutAnimation(ScrollbarOrientation, float offset); … … 374 376 // NOTE: Only called from the ScrollAnimator. 375 377 friend class ScrollAnimator; 376 void setScroll OffsetFromAnimation(const ScrollOffset&);378 void setScrollPositionFromAnimation(const ScrollPosition&); 377 379 378 380 // This function should be overridden by subclasses to perform the actual -
trunk/Source/WebCore/platform/generic/ScrollAnimatorGeneric.cpp
r273070 r273275 110 110 #endif 111 111 112 void ScrollAnimatorGeneric::scrollToOffsetWithoutAnimation(const FloatPoint& offset, ScrollClamping clamping) 113 { 114 FloatPoint position = ScrollableArea::scrollPositionFromOffset(offset, toFloatSize(m_scrollableArea.scrollOrigin())); 112 bool ScrollAnimatorGeneric::scrollToPositionWithoutAnimation(const FloatPoint& position, ScrollClamping clamping) 113 { 115 114 m_kineticAnimation->stop(); 116 115 m_kineticAnimation->clearScrollHistory(); … … 121 120 #endif 122 121 123 ScrollAnimator::scrollToOffsetWithoutAnimation(offset, clamping);122 return ScrollAnimator::scrollToPositionWithoutAnimation(position, clamping); 124 123 } 125 124 -
trunk/Source/WebCore/platform/generic/ScrollAnimatorGeneric.h
r270838 r273275 48 48 bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier, ScrollBehavior) override; 49 49 #endif 50 void scrollToOffsetWithoutAnimation(const FloatPoint&, ScrollClamping) override;50 bool scrollToPositionWithoutAnimation(const FloatPoint&, ScrollClamping) override; 51 51 void willEndLiveResize() override; 52 52 -
trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h
r271081 r273275 81 81 82 82 bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier, ScrollBehavior) override; 83 void scrollToOffsetWithoutAnimation(const FloatPoint&, ScrollClamping) override; 83 bool scrollToPositionWithAnimation(const FloatPoint&) override; 84 bool scrollToPositionWithoutAnimation(const FloatPoint& position, ScrollClamping = ScrollClamping::Clamped) override; 84 85 85 86 #if ENABLE(RUBBER_BANDING) … … 133 134 FloatPoint adjustScrollPositionIfNecessary(const FloatPoint&) const; 134 135 135 void immediateScrollToPosition(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped);136 137 136 bool isUserScrollInProgress() const override; 138 137 bool isRubberBandInProgress() const override; -
trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm
r271658 r273275 788 788 m_haveScrolledSincePageLoad = true; 789 789 790 if (!scrollAnimationEnabledForSystem() || !m_scrollableArea.scrollAnimatorEnabled())791 return ScrollAnimator::scroll(orientation, granularity, step, multiplier, behavior);792 793 if (granularity == ScrollByPixel)794 return ScrollAnimator::scroll(orientation, granularity, step, multiplier, behavior);795 796 790 // This method doesn't do directional snapping, but our base class does. It will call into 797 791 // ScrollAnimatorMac::scroll again with the snapped positions and ScrollBehavior::Default. … … 799 793 return ScrollAnimator::scroll(orientation, granularity, step, multiplier, behavior); 800 794 801 FloatPoint currentPosition = this->currentPosition();795 bool shouldAnimate = scrollAnimationEnabledForSystem() && m_scrollableArea.scrollAnimatorEnabled() && granularity != ScrollByPixel; 802 796 FloatPoint newPosition = positionFromStep(orientation, step, multiplier); 803 newPosition = newPosition.constrainedBetween(m_scrollableArea.minimumScrollPosition(), m_scrollableArea.maximumScrollPosition()); 804 if (currentPosition == newPosition) 805 return false; 797 newPosition = newPosition.constrainedBetween(scrollableArea().minimumScrollPosition(), scrollableArea().maximumScrollPosition()); 798 799 LOG_WITH_STREAM(Scrolling, stream << "ScrollAnimatorMac::scroll from " << currentPosition() << " to " << newPosition); 800 801 if (!shouldAnimate) 802 return scrollToPositionWithoutAnimation(newPosition); 806 803 807 804 if ([m_scrollAnimationHelper _isAnimating]) { … … 813 810 } 814 811 815 LOG_WITH_STREAM(Scrolling, stream << "ScrollAnimatorMac::scroll " << " from " << currentPosition << " to " << newPosition);812 LOG_WITH_STREAM(Scrolling, stream << "ScrollAnimatorMac::scroll " << " from " << currentPosition() << " to " << newPosition); 816 813 [m_scrollAnimationHelper scrollToPoint:newPosition]; 817 814 return true; 818 815 } 819 816 820 // FIXME: Maybe this should take a position. 821 void ScrollAnimatorMac::scrollToOffsetWithoutAnimation(const FloatPoint& offset, ScrollClamping clamping) 822 { 817 bool ScrollAnimatorMac::scrollToPositionWithAnimation(const FloatPoint& newPosition) 818 { 819 bool positionChanged = newPosition != currentPosition(); 820 if (!positionChanged && !scrollableArea().scrollOriginChanged()) 821 return false; 822 823 // FIXME: This is used primarily by smooth scrolling. This should ideally use native scroll animations. 824 // See: https://bugs.webkit.org/show_bug.cgi?id=218857 823 825 [m_scrollAnimationHelper _stopRun]; 824 immediateScrollToPosition(ScrollableArea::scrollPositionFromOffset(offset, toFloatSize(m_scrollableArea.scrollOrigin())), clamping); 826 return ScrollAnimator::scrollToPositionWithAnimation(newPosition); 827 } 828 829 bool ScrollAnimatorMac::scrollToPositionWithoutAnimation(const FloatPoint& position, ScrollClamping clamping) 830 { 831 [m_scrollAnimationHelper _stopRun]; 832 return ScrollAnimator::scrollToPositionWithoutAnimation(position, clamping); 825 833 } 826 834 … … 843 851 844 852 m_scrollableArea.setConstrainsScrollingToContentEdge(currentlyConstrainsToContentEdge); 845 }846 847 void ScrollAnimatorMac::immediateScrollToPosition(const FloatPoint& newPosition, ScrollClamping clamping)848 {849 FloatPoint currentPosition = this->currentPosition();850 FloatPoint adjustedPosition = clamping == ScrollClamping::Clamped ? adjustScrollPositionIfNecessary(newPosition) : newPosition;851 852 bool positionChanged = adjustedPosition != currentPosition;853 if (!positionChanged && !scrollableArea().scrollOriginChanged())854 return;855 856 FloatSize delta = adjustedPosition - currentPosition;857 m_currentPosition = adjustedPosition;858 notifyPositionChanged(delta);859 updateActiveScrollSnapIndexForOffset();860 853 } 861 854 … … 923 916 { 924 917 ASSERT(m_scrollAnimationHelper); 925 immediateScrollToPosition(newPosition);918 ScrollAnimator::scrollToPositionWithoutAnimation(newPosition); 926 919 } 927 920 -
trunk/Source/WebCore/rendering/RenderLayerScrollableArea.cpp
r271814 r273275 266 266 267 267 ScrollOffset snappedOffset = ceiledIntPoint(scrollAnimator().adjustScrollOffsetForSnappingIfNeeded(clampedScrollOffset, options.snapPointSelectionMethod)); 268 auto snappedPosition = scrollPositionFromOffset(snappedOffset); 268 269 if (options.animated == AnimatedScroll::Yes) 269 ScrollableArea::scrollTo OffsetWithAnimation(snappedOffset);270 ScrollableArea::scrollToPositionWithAnimation(snappedPosition); 270 271 else { 271 auto snappedPosition = scrollPositionFromOffset(snappedOffset);272 272 if (!requestScrollPositionUpdate(snappedPosition, options.type, options.clamping)) 273 scrollTo OffsetWithoutAnimation(snappedOffset, options.clamping);273 scrollToPositionWithoutAnimation(snappedPosition, options.clamping); 274 274 setScrollBehaviorStatus(ScrollBehaviorStatus::NotInAnimation); 275 275 } … … 1158 1158 1159 1159 m_scrollDimensionsDirty = true; 1160 Scroll Offset originalScrollOffset = scrollOffset();1160 ScrollPosition originalScrollPosition = scrollPosition(); 1161 1161 1162 1162 computeScrollDimensions(); … … 1189 1189 updateScrollbarsAfterLayout(); 1190 1190 1191 if (originalScroll Offset != scrollOffset())1192 scrollTo OffsetWithoutAnimation(IntPoint(scrollOffset()));1191 if (originalScrollPosition != scrollPosition()) 1192 scrollToPositionWithoutAnimation(IntPoint(scrollPosition())); 1193 1193 1194 1194 if (m_layer.isComposited()) {
Note: See TracChangeset
for help on using the changeset viewer.