Changeset 284136 in webkit
- Timestamp:
- Oct 13, 2021, 5:18:01 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 10 edited
-
ChangeLog (modified) (1 diff)
-
SourcesCocoa.txt (modified) (1 diff)
-
WebCore.xcodeproj/project.pbxproj (modified) (2 diffs)
-
page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h (modified) (1 diff)
-
page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm (modified) (2 diffs)
-
platform/ScrollAnimation.cpp (modified) (1 diff)
-
platform/ScrollAnimation.h (modified) (3 diffs)
-
platform/ScrollingEffectsController.cpp (modified) (7 diffs)
-
platform/ScrollingEffectsController.h (modified) (5 diffs)
-
platform/mac/ScrollAnimationRubberBand.h (added)
-
platform/mac/ScrollAnimationRubberBand.mm (added)
-
platform/mac/ScrollingEffectsController.mm (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r284135 r284136 1 2021-10-13 Simon Fraser <simon.fraser@apple.com> 2 3 Use a ScrollAnimation for rubber-banding 4 https://bugs.webkit.org/show_bug.cgi?id=231695 5 6 Reviewed by Tim Horton. 7 8 The animation that runs when rubber-banding (when you momentum-scroll into an edge, 9 or stretch and release) was code in updateRubberBandAnimatingState(). Repackage 10 that code as a ScrollAnimation subclass, which allows it to share code with other 11 types of scroll animation. 12 13 ScrollAnimationRubberBand needs to do non-clamped scrolls, so add a way for ScrollAnimations 14 to state that they allow this. 15 16 Standardize the capitalization of RubberBand. 17 18 * SourcesCocoa.txt: 19 * WebCore.xcodeproj/project.pbxproj: 20 * page/scrolling/ScrollingTreeScrollingNode.cpp: 21 (WebCore::ScrollingTreeScrollingNode::scrollTo): 22 * page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h: 23 * page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm: 24 (WebCore::ScrollingTreeScrollingNodeDelegateMac::willDoProgrammaticScroll): 25 (WebCore::ScrollingTreeScrollingNodeDelegateMac::didStopRubberBandAnimation): 26 (WebCore::ScrollingTreeScrollingNodeDelegateMac::didStopRubberbandSnapAnimation): Deleted. 27 * platform/ScrollAnimation.cpp: 28 (WebCore::operator<<): 29 * platform/ScrollAnimation.h: 30 (WebCore::ScrollAnimation::clamping const): 31 * platform/ScrollingEffectsController.cpp: 32 (WebCore::ScrollingEffectsController::startMomentumScrollWithInitialVelocity): Need to be sure 33 to stop() any existing animation. 34 (WebCore::ScrollingEffectsController::scrollAnimationDidUpdate): 35 (WebCore::ScrollingEffectsController::scrollAnimationWillStart): 36 (WebCore::ScrollingEffectsController::scrollAnimationDidEnd): 37 * platform/ScrollingEffectsController.h: 38 (WebCore::ScrollingEffectsControllerClient::willStartRubberBandAnimation): 39 (WebCore::ScrollingEffectsControllerClient::didStopRubberBandAnimation): 40 (WebCore::ScrollingEffectsControllerClient::willStartRubberBandSnapAnimation): Deleted. 41 (WebCore::ScrollingEffectsControllerClient::didStopRubberbandSnapAnimation): Deleted. 42 * platform/mac/ScrollAnimationRubberBand.h: Added. 43 * platform/mac/ScrollAnimationRubberBand.mm: Added. 44 (elasticDeltaForTimeDelta): 45 (WebCore::roundTowardZero): 46 (WebCore::roundToDevicePixelTowardZero): 47 (WebCore::ScrollAnimationRubberBand::ScrollAnimationRubberBand): 48 (WebCore::ScrollAnimationRubberBand::startRubberBandAnimation): 49 (WebCore::ScrollAnimationRubberBand::retargetActiveAnimation): 50 (WebCore::ScrollAnimationRubberBand::updateScrollExtents): 51 (WebCore::ScrollAnimationRubberBand::serviceAnimation): 52 * platform/mac/ScrollingEffectsController.mm: 53 (WebCore::ScrollingEffectsController::handleWheelEvent): 54 (WebCore::ScrollingEffectsController::updateRubberBandAnimatingState): 55 (WebCore::ScrollingEffectsController::stopRubberBanding): 56 (WebCore::ScrollingEffectsController::startRubberBandAnimation): 57 (WebCore::ScrollingEffectsController::stopRubberBandAnimation): 58 (WebCore::ScrollingEffectsController::willStartRubberBandAnimation): 59 (WebCore::ScrollingEffectsController::didStopRubberBandAnimation): 60 (WebCore::ScrollingEffectsController::startRubberBandAnimationIfNecessary): 61 (WebCore::elasticDeltaForTimeDelta): Deleted. 62 (WebCore::roundTowardZero): Deleted. 63 (WebCore::roundToDevicePixelTowardZero): Deleted. 64 (WebCore::ScrollingEffectsController::stopRubberbanding): Deleted. 65 (WebCore::ScrollingEffectsController::startRubberbandAnimation): Deleted. 66 (WebCore::ScrollingEffectsController::stopRubberbandAnimation): Deleted. 67 (WebCore::ScrollingEffectsController::startRubberbandAnimationIfNecessary): Deleted. 68 1 69 2021-10-13 Jean-Yves Avenard <jya@apple.com> 2 70 -
trunk/Source/WebCore/SourcesCocoa.txt
r283703 r284136 492 492 platform/mac/SSLKeyGeneratorMac.mm 493 493 platform/mac/ScrollAnimatorMac.mm @no-unify 494 platform/mac/Scroll ingEffectsController.mm494 platform/mac/ScrollAnimationRubberBand.mm 495 495 platform/mac/ScrollViewMac.mm 496 496 platform/mac/ScrollbarsControllerMac.mm @no-unify 497 497 platform/mac/ScrollbarThemeMac.mm @no-unify 498 platform/mac/ScrollingEffectsController.mm 498 499 platform/mac/ScrollingMomentumCalculatorMac.mm 499 500 platform/mac/SerializedPlatformDataCueMac.mm -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r284085 r284136 6215 6215 0F37F0832202AC8F00A89C0B /* ScrollingTreeScrollingNodeDelegateMac.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollingTreeScrollingNodeDelegateMac.mm; sourceTree = "<group>"; }; 6216 6216 0F37F0842202ACB700A89C0B /* ScrollingTreeScrollingNodeDelegateMac.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScrollingTreeScrollingNodeDelegateMac.h; sourceTree = "<group>"; }; 6217 0F38186A2708D20100414F32 /* ScrollAnimationRubberBand.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollAnimationRubberBand.mm; sourceTree = "<group>"; }; 6218 0F38186C2708D20200414F32 /* ScrollAnimationRubberBand.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScrollAnimationRubberBand.h; sourceTree = "<group>"; }; 6217 6219 0F3DD44D12F5EA1B000D9190 /* ShadowBlur.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShadowBlur.cpp; sourceTree = "<group>"; }; 6218 6220 0F3DD44E12F5EA1B000D9190 /* ShadowBlur.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShadowBlur.h; sourceTree = "<group>"; }; … … 22353 22355 46DBB64E1AB8C96F00D9A813 /* PowerObserverMac.h */, 22354 22356 0081FEFE16B0A2B6008AAA7A /* PublicSuffixMac.mm */, 22357 0F38186C2708D20200414F32 /* ScrollAnimationRubberBand.h */, 22358 0F38186A2708D20100414F32 /* ScrollAnimationRubberBand.mm */, 22355 22359 BCAE1FA512939DB7004CB026 /* ScrollAnimatorMac.h */, 22356 22360 BC51156D12B1749C00C96754 /* ScrollAnimatorMac.mm */, -
trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h
r283793 r284136 88 88 bool shouldRubberBandOnSide(BoxSide) const final; 89 89 void immediateScrollBy(const FloatSize&, ScrollClamping = ScrollClamping::Clamped) final; 90 void didStopRubber bandSnapAnimation() final;90 void didStopRubberBandAnimation() final; 91 91 void rubberBandingStateChanged(bool) final; 92 92 void adjustScrollPositionToBoundsIfNecessary() final; -
trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm
r283983 r284136 132 132 if (scrollPositionIsNotRubberbandingEdge(targetPosition)) { 133 133 LOG(Scrolling, "ScrollingTreeScrollingNodeDelegateMac::willDoProgrammaticScroll() - scrolling away from rubberbanding edge so stopping rubberbanding"); 134 m_scrollController.stopRubber banding();134 m_scrollController.stopRubberBanding(); 135 135 } 136 136 } … … 340 340 } 341 341 342 void ScrollingTreeScrollingNodeDelegateMac::didStopRubber bandSnapAnimation()342 void ScrollingTreeScrollingNodeDelegateMac::didStopRubberBandAnimation() 343 343 { 344 344 // Since the rubberband timer has stopped, totalContentsSizeForRubberBand can be synchronized with totalContentsSize. -
trunk/Source/WebCore/platform/ScrollAnimation.cpp
r283072 r284136 37 37 case ScrollAnimation::Type::Kinetic: ts << "kinetic"; break; 38 38 case ScrollAnimation::Type::Momentum: ts << "momentum"; break; 39 case ScrollAnimation::Type::RubberBand: ts << "rubber-band"; break; 39 40 } 40 41 return ts; -
trunk/Source/WebCore/platform/ScrollAnimation.h
r283851 r284136 55 55 Kinetic, 56 56 Momentum, 57 RubberBand, 57 58 }; 58 59 … … 64 65 65 66 Type type() const { return m_animationType; } 67 68 virtual ScrollClamping clamping() const { return ScrollClamping::Clamped; } 66 69 67 70 virtual bool retargetActiveAnimation(const FloatPoint& newDestinationOffset) = 0; … … 76 79 77 80 FloatPoint currentOffset() const { return m_currentOffset; } 78 81 79 82 virtual void serviceAnimation(MonotonicTime) = 0; 80 83 -
trunk/Source/WebCore/platform/ScrollingEffectsController.cpp
r283851 r284136 42 42 #endif 43 43 44 #if HAVE(RUBBER_BANDING) 45 #include "ScrollAnimationRubberBand.h" 46 #endif 47 44 48 namespace WebCore { 45 49 … … 59 63 } 60 64 61 updateRubberBandAnimatingState( currentTime);65 updateRubberBandAnimatingState(); 62 66 updateKeyboardScrollingAnimatingState(currentTime); 63 67 … … 126 130 { 127 131 if (m_currentAnimation) { 128 if (is<ScrollAnimationMomentum>(m_currentAnimation.get())) 129 m_currentAnimation->stop(); 130 else 132 m_currentAnimation->stop(); 133 if (!is<ScrollAnimationMomentum>(m_currentAnimation.get())) 131 134 m_currentAnimation = nullptr; 132 135 } … … 430 433 } 431 434 432 void ScrollingEffectsController::scrollAnimationDidUpdate(ScrollAnimation& animation, const FloatPoint& currentOffset) 433 { 434 auto scrollDelta = currentOffset - m_client.scrollOffset(); 435 436 LOG_WITH_STREAM(ScrollAnimations, stream << "ScrollingEffectsController " << this << " scrollAnimationDidUpdate " << animation << " (main thread " << isMainThread() << ") scrolling by " << scrollDelta); 435 void ScrollingEffectsController::scrollAnimationDidUpdate(ScrollAnimation& animation, const FloatPoint& scrollOffset) 436 { 437 LOG_WITH_STREAM(ScrollAnimations, stream << "ScrollingEffectsController " << this << " scrollAnimationDidUpdate " << animation << " (main thread " << isMainThread() << ") scrolling to " << scrollOffset); 438 439 auto currentOffset = m_client.scrollOffset(); 440 auto scrollDelta = scrollOffset - currentOffset; 441 442 m_client.immediateScrollBy(scrollDelta, animation.clamping()); 443 } 444 445 void ScrollingEffectsController::scrollAnimationWillStart(ScrollAnimation& animation) 446 { 447 LOG_WITH_STREAM(ScrollAnimations, stream << "ScrollingEffectsController " << this << " scrollAnimationWillStart " << animation); 448 449 #if HAVE(RUBBER_BANDING) 450 if (is<ScrollAnimationRubberBand>(animation)) 451 willStartRubberBandAnimation(); 452 #else 437 453 UNUSED_PARAM(animation); 438 439 m_client.immediateScrollBy(scrollDelta); 440 } 441 442 void ScrollingEffectsController::scrollAnimationWillStart(ScrollAnimation& animation) 443 { 444 LOG_WITH_STREAM(ScrollAnimations, stream << "ScrollingEffectsController " << this << " scrollAnimationWillStart " << animation); 445 UNUSED_PARAM(animation); 454 #endif 446 455 447 456 startOrStopAnimationCallbacks(); … … 451 460 { 452 461 LOG_WITH_STREAM(ScrollAnimations, stream << "ScrollingEffectsController " << this << " scrollAnimationDidEnd " << animation); 453 UNUSED_PARAM(animation);454 462 455 463 if (usesScrollSnap() && m_isAnimatingScrollSnap) { … … 457 465 stopScrollSnapAnimation(); 458 466 } 467 468 #if HAVE(RUBBER_BANDING) 469 if (is<ScrollAnimationRubberBand>(animation)) 470 didStopRubberBandAnimation(); 471 #else 472 UNUSED_PARAM(animation); 473 #endif 459 474 460 475 // FIXME: Need to track state better and only call this when the running animation is for CSS smooth scrolling. Calling should be harmless, though. … … 483 498 } 484 499 485 void ScrollingEffectsController::updateRubberBandAnimatingState( MonotonicTime)500 void ScrollingEffectsController::updateRubberBandAnimatingState() 486 501 { 487 502 } -
trunk/Source/WebCore/platform/ScrollingEffectsController.h
r283851 r284136 101 101 virtual bool shouldRubberBandOnSide(BoxSide) const = 0; 102 102 103 virtual void willStartRubberBand SnapAnimation() { }104 virtual void didStopRubber bandSnapAnimation() { }103 virtual void willStartRubberBandAnimation() { } 104 virtual void didStopRubberBandAnimation() { } 105 105 106 106 virtual void rubberBandingStateChanged(bool) { } … … 175 175 bool processWheelEventForScrollSnap(const PlatformWheelEvent&); 176 176 177 void stopRubber banding();177 void stopRubberBanding(); 178 178 bool isRubberBandInProgress() const; 179 179 RectEdges<bool> rubberBandingEdges() const { return m_rubberBandingEdges; } … … 181 181 182 182 private: 183 void updateRubberBandAnimatingState( MonotonicTime);183 void updateRubberBandAnimatingState(); 184 184 void updateKeyboardScrollingAnimatingState(MonotonicTime); 185 185 … … 201 201 bool applyScrollDeltaWithStretching(const PlatformWheelEvent&, FloatSize, bool isHorizontallyStretched, bool isVerticallyStretched); 202 202 203 void startRubberbandAnimationIfNecessary(); 204 void startRubberbandAnimation(); 205 void stopRubberbandAnimation(); 203 void startRubberBandAnimationIfNecessary(); 204 205 void startRubberBandAnimation(const FloatPoint& targetOffset, const FloatSize& initialVelocity, const FloatSize& initialOverscroll); 206 void stopRubberBandAnimation(); 207 208 void willStartRubberBandAnimation(); 209 void didStopRubberBandAnimation(); 206 210 207 211 bool shouldRubberBandOnSide(BoxSide) const; … … 255 259 256 260 #if HAVE(RUBBER_BANDING) 257 // Rubber band state.258 MonotonicTime m_startTime;259 FloatSize m_startStretch;260 FloatSize m_origVelocity;261 261 RectEdges<bool> m_rubberBandingEdges; 262 262 #endif -
trunk/Source/WebCore/platform/mac/ScrollingEffectsController.mm
r283851 r284136 29 29 #import "Logging.h" 30 30 #import "PlatformWheelEvent.h" 31 #import "ScrollAnimationRubberBand.h" 31 32 #import "ScrollExtents.h" 32 33 #import "WheelEventTestMonitor.h" … … 44 45 static const float rubberbandMinimumRequiredDeltaBeforeStretch = 10; 45 46 46 static float elasticDeltaForTimeDelta(float initialPosition, float initialVelocity, Seconds elapsedTime)47 {48 return _NSElasticDeltaForTimeDelta(initialPosition, initialVelocity, elapsedTime.seconds());49 }50 51 47 static float elasticDeltaForReboundDelta(float delta) 52 48 { … … 143 139 m_unappliedOverscrollDelta = { }; 144 140 145 stopRubber bandAnimation();141 stopRubberBandAnimation(); 146 142 updateRubberBandingState(); 147 143 return true; … … 150 146 if (wheelEvent.phase() == PlatformWheelEventPhase::Ended) { 151 147 // FIXME: This triggers the rubberband timer even when we don't start rubberbanding. 152 startRubber bandAnimationIfNecessary();148 startRubberBandAnimationIfNecessary(); 153 149 updateRubberBandingState(); 154 150 return true; … … 214 210 m_ignoreMomentumScrolls = true; 215 211 m_momentumScrollInProgress = false; 216 startRubber bandAnimationIfNecessary();212 startRubberBandAnimationIfNecessary(); 217 213 } 218 214 } … … 347 343 } 348 344 349 static inline float roundTowardZero(float num) 350 { 351 return num > 0 ? ceilf(num - 0.5f) : floorf(num + 0.5f); 352 } 353 354 static inline float roundToDevicePixelTowardZero(float num) 355 { 356 float roundedNum = roundf(num); 357 if (fabs(num - roundedNum) < 0.125) 358 num = roundedNum; 359 360 return roundTowardZero(num); 361 } 362 363 void ScrollingEffectsController::updateRubberBandAnimatingState(MonotonicTime currentTime) 345 void ScrollingEffectsController::updateRubberBandAnimatingState() 364 346 { 365 347 if (!m_isAnimatingRubberBand) … … 369 351 return; 370 352 371 if (!m_momentumScrollInProgress || m_ignoreMomentumScrolls) { 372 auto timeDelta = currentTime - m_startTime; 373 374 if (m_startStretch.isZero()) { 375 m_startStretch = m_client.stretchAmount(); 376 if (m_startStretch.isZero()) { 377 stopRubberbanding(); 378 return; 379 } 380 381 m_origVelocity = m_momentumVelocity; 382 383 // Just like normal scrolling, prefer vertical rubberbanding 384 if (fabsf(m_origVelocity.height()) >= fabsf(m_origVelocity.width())) 385 m_origVelocity.setWidth(0); 386 387 // Don't rubber-band horizontally if it's not possible to scroll horizontally 388 if (!m_client.allowsHorizontalScrolling()) 389 m_origVelocity.setWidth(0); 390 391 // Don't rubber-band vertically if it's not possible to scroll vertically 392 if (!m_client.allowsVerticalScrolling()) 393 m_origVelocity.setHeight(0); 394 395 LOG_WITH_STREAM(ScrollAnimations, stream << "ScrollingEffectsController::updateRubberBandAnimatingState() - starting rubbberband with m_origVelocity" << m_origVelocity << " m_startStretch " << m_startStretch); 396 } 397 398 auto rubberBandDelta = FloatSize { 399 roundToDevicePixelTowardZero(elasticDeltaForTimeDelta(m_startStretch.width(), -m_origVelocity.width(), timeDelta)), 400 roundToDevicePixelTowardZero(elasticDeltaForTimeDelta(m_startStretch.height(), -m_origVelocity.height(), timeDelta)) 401 }; 402 403 if (fabs(rubberBandDelta.width()) >= 1 || fabs(rubberBandDelta.height()) >= 1) { 404 auto stretchDelta = rubberBandDelta - FloatSize(m_client.stretchAmount()); 405 406 LOG_WITH_STREAM(ScrollAnimations, stream << "ScrollingEffectsController::updateRubberBandAnimatingState() - rubberBandDelta " << rubberBandDelta << " stretched " << m_client.stretchAmount() << " moving by " << stretchDelta); 407 408 m_client.immediateScrollBy(stretchDelta, ScrollClamping::Unclamped); 409 410 FloatSize newStretch = m_client.stretchAmount(); 411 412 m_stretchScrollForce.setWidth(reboundDeltaForElasticDelta(newStretch.width())); 413 m_stretchScrollForce.setHeight(reboundDeltaForElasticDelta(newStretch.height())); 414 } else { 415 LOG_WITH_STREAM(ScrollAnimations, stream << "ScrollingEffectsController::updateRubberBandAnimatingState() - rubber band complete"); 416 m_client.adjustScrollPositionToBoundsIfNecessary(); 417 stopRubberbanding(); 418 } 419 } else { 353 if (m_momentumScrollInProgress && !m_ignoreMomentumScrolls) { 420 354 LOG_WITH_STREAM(ScrollAnimations, stream << "ScrollingEffectsController::updateRubberBandAnimatingState() - not animating, momentumScrollInProgress " << m_momentumScrollInProgress << " ignoreMomentumScrolls " << m_ignoreMomentumScrolls); 421 m_startTime = currentTime;422 m_startStretch = { };423 355 if (!isRubberBandInProgressInternal()) 424 stopRubber bandAnimation();356 stopRubberBandAnimation(); 425 357 } 426 358 … … 454 386 } 455 387 456 void ScrollingEffectsController::stopRubberbanding() 457 { 458 stopRubberbandAnimation(); 388 void ScrollingEffectsController::stopRubberBanding() 389 { 390 stopRubberBandAnimation(); 391 updateRubberBandingState(); 392 } 393 394 void ScrollingEffectsController::startRubberBandAnimation(const FloatPoint& targetOffset, const FloatSize& initialVelocity, const FloatSize& initialOverscroll) 395 { 396 if (m_currentAnimation) 397 m_currentAnimation->stop(); 398 399 m_currentAnimation = makeUnique<ScrollAnimationRubberBand>(*this); 400 LOG_WITH_STREAM(ScrollAnimations, stream << "ScrollingEffectsController::startRubberBandAnimation() - starting rubbberband with targetOffset " << targetOffset << " initialVelocity " << initialVelocity << " initialOverscroll " << initialOverscroll); 401 downcast<ScrollAnimationRubberBand>(*m_currentAnimation).startRubberBandAnimation(targetOffset, initialVelocity, initialOverscroll); 402 } 403 404 void ScrollingEffectsController::stopRubberBandAnimation() 405 { 406 if (m_isAnimatingRubberBand) 407 stopAnimatedScroll(); 408 459 409 m_stretchScrollForce = { }; 460 m_startTime = { }; 461 m_startStretch = { }; 462 m_origVelocity = { }; 463 updateRubberBandingState(); 464 } 465 466 void ScrollingEffectsController::startRubberbandAnimation() 467 { 468 m_client.willStartRubberBandSnapAnimation(); 469 470 setIsAnimatingRubberBand(true); 471 410 } 411 412 void ScrollingEffectsController::willStartRubberBandAnimation() 413 { 414 m_isAnimatingRubberBand = true; 415 m_client.willStartRubberBandAnimation(); 472 416 m_client.deferWheelEventTestCompletionForReason(reinterpret_cast<WheelEventTestMonitor::ScrollableAreaIdentifier>(this), WheelEventTestMonitor::RubberbandInProgress); 473 417 } 474 418 475 void ScrollingEffectsController::stopRubberbandAnimation() 476 { 477 m_client.didStopRubberbandSnapAnimation(); 478 479 setIsAnimatingRubberBand(false); 480 419 void ScrollingEffectsController::didStopRubberBandAnimation() 420 { 421 m_isAnimatingRubberBand = false; 422 m_client.didStopRubberBandAnimation(); 481 423 m_client.removeWheelEventTestCompletionDeferralForReason(reinterpret_cast<WheelEventTestMonitor::ScrollableAreaIdentifier>(this), WheelEventTestMonitor::RubberbandInProgress); 482 424 } 483 425 484 void ScrollingEffectsController::startRubber bandAnimationIfNecessary()426 void ScrollingEffectsController::startRubberBandAnimationIfNecessary() 485 427 { 486 428 auto timeDelta = WallTime::now() - m_lastMomentumScrollTimestamp; … … 491 433 return; 492 434 493 m_startTime = MonotonicTime::now(); 494 m_startStretch = { }; 495 m_origVelocity = { }; 496 497 startRubberbandAnimation(); 435 auto extents = m_client.scrollExtents(); 436 auto targetOffset = m_client.scrollOffset(); 437 auto contrainedOffset = targetOffset.constrainedBetween(extents.minimumScrollOffset(), extents.maximumScrollOffset()); 438 bool willOverscroll = targetOffset != contrainedOffset; 439 440 auto stretchAmount = m_client.stretchAmount(); 441 442 LOG_WITH_STREAM(ScrollAnimations, stream << "ScrollingEffectsController::startRubberBandAnimationIfNecessary() - rubberBandAnimationRunning " << m_isAnimatingRubberBand << " stretchAmount " << stretchAmount << " targetOffset " << targetOffset); 443 444 if (stretchAmount.isZero() && !willOverscroll) 445 return; 446 447 auto initialVelocity = m_momentumVelocity; 448 449 // Just like normal scrolling, prefer vertical rubberbanding 450 if (fabsf(initialVelocity.height()) >= fabsf(initialVelocity.width())) 451 initialVelocity.setWidth(0); 452 453 // Don't rubber-band horizontally if it's not possible to scroll horizontally 454 if (!m_client.allowsHorizontalScrolling()) 455 initialVelocity.setWidth(0); 456 457 // Don't rubber-band vertically if it's not possible to scroll vertically 458 if (!m_client.allowsVerticalScrolling()) 459 initialVelocity.setHeight(0); 460 461 startRubberBandAnimation(contrainedOffset, initialVelocity, stretchAmount); 498 462 } 499 463
Note:
See TracChangeset
for help on using the changeset viewer.