Changeset 264190 in webkit
- Timestamp:
- Jul 9, 2020, 1:01:53 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 8 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/scrolling/mac/adjust-scroll-snap-after-gesture-expected.txt (added)
-
LayoutTests/fast/scrolling/mac/adjust-scroll-snap-after-gesture.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm (modified) (1 diff)
-
Source/WebCore/platform/ScrollableArea.cpp (modified) (2 diffs)
-
Source/WebCore/platform/ScrollableArea.h (modified) (1 diff)
-
Source/WebCore/platform/cocoa/ScrollController.h (modified) (4 diffs)
-
Source/WebCore/platform/cocoa/ScrollController.mm (modified) (18 diffs)
-
Source/WebCore/platform/mac/ScrollAnimatorMac.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r264187 r264190 1 2020-07-09 Simon Fraser <simon.fraser@apple.com> 2 3 After a scroll gesture, content changes don't trigger re-snapping with scroll snap 4 https://bugs.webkit.org/show_bug.cgi?id=214123 5 6 Reviewed by Wenson Hsieh. 7 8 * fast/scrolling/mac/adjust-scroll-snap-after-gesture-expected.txt: Added. 9 * fast/scrolling/mac/adjust-scroll-snap-after-gesture.html: Added. 10 1 11 2020-07-09 Wenson Hsieh <wenson_hsieh@apple.com> 2 12 -
trunk/Source/WebCore/ChangeLog
r264188 r264190 1 2020-07-09 Simon Fraser <simon.fraser@apple.com> 2 3 After a scroll gesture, content changes don't trigger re-snapping with scroll snap 4 https://bugs.webkit.org/show_bug.cgi?id=214123 5 6 Reviewed by Wenson Hsieh. 7 8 ScrollController::m_inScrollGesture could get stuck as true after a scroll gesture, because 9 ScrollAnimatorMac::handleWheelEvent() didn't reliably call m_scrollController.handleWheelEvent() for 10 the event event based on the hokey shouldForwardWheelEventsToParent() code. 11 12 Fix by explicitly calling m_scrollController.updateGestureInProgressState() which maintains 13 m_inScrollGesture. 14 15 When m_inScrollGesture was stuck as true, ScrollableArea::updateScrollSnapState() would return early 16 because isScrollSnapInProgress() would return true. In addition, 17 ScrollController::isScrollSnapInProgress() was a lie for non-scroll-snapping scrollable areas, so 18 explicitly check for snap points there, using an explicit usesScrollSnap() function. 19 20 Rename some WheelEventStatus values to use "momentum" rather than "inertia". 21 22 Test: fast/scrolling/mac/adjust-scroll-snap-after-gesture.html 23 24 * page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm: 25 (WebCore::ScrollingTreeScrollingNodeDelegateMac::handleWheelEvent): 26 * platform/ScrollableArea.cpp: 27 (WebCore::ScrollableArea::usesScrollSnap const): 28 (WebCore::ScrollableArea::updateScrollSnapState): 29 * platform/ScrollableArea.h: 30 * platform/cocoa/ScrollController.h: 31 * platform/cocoa/ScrollController.mm: 32 (WebCore::ScrollController::handleWheelEvent): 33 (WebCore::ScrollController::usesScrollSnap const): 34 (WebCore::ScrollController::isScrollSnapInProgress const): 35 (WebCore::ScrollController::snapRubberBand): 36 (WebCore::toWheelEventStatus): 37 (WebCore::operator<<): 38 (WebCore::ScrollController::shouldOverrideMomentumScrolling const): 39 (WebCore::ScrollController::scheduleStatelessScrollSnap): 40 (WebCore::ScrollController::statelessSnapTransitionTimerFired): 41 (WebCore::ScrollController::processWheelEventForScrollSnap): 42 (WebCore::ScrollController::updateGestureInProgressState): 43 (WebCore::ScrollController::scrollSnapTimerFired): 44 (WebCore::ScrollController::activeScrollSnapIndexForAxis const): 45 (WebCore::ScrollController::setActiveScrollSnapIndexForAxis): 46 (WebCore::ScrollController::setNearestScrollSnapIndexForAxisAndOffset): 47 (WebCore::ScrollController::setActiveScrollSnapIndicesForOffset): 48 (WebCore::ScrollController::shouldOverrideInertialScrolling const): Deleted. 49 * platform/mac/ScrollAnimatorMac.mm: 50 (WebCore::ScrollAnimatorMac::handleWheelEvent): 51 1 52 2020-07-09 Fujii Hironori <Hironori.Fujii@sony.com> 2 53 -
trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm
r264008 r264190 140 140 #endif 141 141 142 m_scrollController.updateGestureInProgressState(wheelEvent); 143 142 144 // PlatformWheelEventPhaseMayBegin fires when two fingers touch the trackpad, and is used to flash overlay scrollbars. 143 145 // We know we're scrollable at this point, so handle the event. -
trunk/Source/WebCore/platform/ScrollableArea.cpp
r264151 r264190 537 537 } 538 538 539 bool ScrollableArea::usesScrollSnap() const 540 { 541 return !!m_snapOffsetsInfo; 542 } 543 539 544 IntPoint ScrollableArea::nearestActiveSnapPoint(const IntPoint& currentPosition) 540 545 { … … 571 576 scrollAnimator->updateScrollSnapState(); 572 577 578 if (!usesScrollSnap()) 579 return; 580 573 581 LOG_WITH_STREAM(ScrollSnap, stream << *this << " updateScrollSnapState: isScrollSnapInProgress " << isScrollSnapInProgress() << " isUserScrollInProgress " << isUserScrollInProgress()); 574 582 -
trunk/Source/WebCore/platform/ScrollableArea.h
r264151 r264190 89 89 WEBCORE_EXPORT bool handleWheelEvent(const PlatformWheelEvent&); 90 90 91 bool usesScrollSnap() const; 92 91 93 #if ENABLE(CSS_SCROLL_SNAP) 92 94 WEBCORE_EXPORT const Vector<LayoutUnit>* horizontalSnapOffsets() const; -
trunk/Source/WebCore/platform/cocoa/ScrollController.h
r264151 r264190 120 120 UserScrolling, 121 121 UserScrollEnd, 122 InertialScrollBegin,123 InertialScrolling,124 InertialScrollEnd,122 MomentumScrollBegin, 123 MomentumScrolling, 124 MomentumScrollEnd, 125 125 StatelessScrollEvent, 126 126 Unknown … … 137 137 bool handleWheelEvent(const PlatformWheelEvent&); 138 138 #endif 139 140 bool usesScrollSnap() const; 139 141 140 142 bool isUserScrollInProgress() const; … … 150 152 unsigned activeScrollSnapIndexForAxis(ScrollEventAxis) const; 151 153 void updateScrollSnapState(const ScrollableArea&); 154 155 void updateGestureInProgressState(const PlatformWheelEvent&); 156 152 157 #if PLATFORM(MAC) 153 158 bool processWheelEventForScrollSnap(const PlatformWheelEvent&); … … 180 185 void stopScrollSnapTimer(); 181 186 182 bool shouldOverride InertialScrolling() const;187 bool shouldOverrideMomentumScrolling() const; 183 188 void statelessSnapTransitionTimerFired(); 184 189 void scheduleStatelessScrollSnap(); -
trunk/Source/WebCore/platform/cocoa/ScrollController.mm
r264151 r264190 138 138 return false; 139 139 140 m_inScrollGesture = true;141 140 m_momentumScrollInProgress = false; 142 141 m_ignoreMomentumScrolls = false; … … 456 455 #endif 457 456 457 bool ScrollController::usesScrollSnap() const 458 { 459 #if ENABLE(CSS_SCROLL_SNAP) 460 return !!m_scrollSnapState; 461 #else 462 return false; 463 #endif 464 } 465 458 466 bool ScrollController::isUserScrollInProgress() const 459 467 { … … 479 487 bool ScrollController::isScrollSnapInProgress() const 480 488 { 489 if (!usesScrollSnap()) 490 return false; 491 481 492 #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC) 482 493 if (m_inScrollGesture || m_momentumScrollInProgress || m_scrollSnapTimer) … … 518 529 m_momentumVelocity = { }; 519 530 520 m_inScrollGesture = false;521 522 531 if (m_snapRubberbandTimer) 523 532 return; … … 554 563 switch (momentumPhase) { 555 564 case PlatformWheelEventPhaseBegan: 556 return WheelEventStatus:: InertialScrollBegin;565 return WheelEventStatus::MomentumScrollBegin; 557 566 558 567 case PlatformWheelEventPhaseChanged: 559 return WheelEventStatus:: InertialScrolling;568 return WheelEventStatus::MomentumScrolling; 560 569 561 570 case PlatformWheelEventPhaseEnded: 562 return WheelEventStatus:: InertialScrollEnd;571 return WheelEventStatus::MomentumScrollEnd; 563 572 564 573 case PlatformWheelEventPhaseNone: … … 596 605 case WheelEventStatus::UserScrolling: ts << "UserScrolling"; break; 597 606 case WheelEventStatus::UserScrollEnd: ts << "UserScrollEnd"; break; 598 case WheelEventStatus:: InertialScrollBegin: ts << "InertialScrollBegin"; break;599 case WheelEventStatus:: InertialScrolling: ts << "InertialScrolling"; break;600 case WheelEventStatus:: InertialScrollEnd: ts << "InertialScrollEnd"; break;607 case WheelEventStatus::MomentumScrollBegin: ts << "MomentumScrollBegin"; break; 608 case WheelEventStatus::MomentumScrolling: ts << "MomentumScrolling"; break; 609 case WheelEventStatus::MomentumScrollEnd: ts << "MomentumScrollEnd"; break; 601 610 case WheelEventStatus::StatelessScrollEvent: ts << "StatelessScrollEvent"; break; 602 611 case WheelEventStatus::Unknown: ts << "Unknown"; break; … … 606 615 #endif 607 616 608 bool ScrollController::shouldOverride InertialScrolling() const609 { 610 if (! m_scrollSnapState)617 bool ScrollController::shouldOverrideMomentumScrolling() const 618 { 619 if (!usesScrollSnap()) 611 620 return false; 612 621 … … 622 631 m_statelessSnapTransitionTimer = nullptr; 623 632 } 624 if (! m_scrollSnapState)633 if (!usesScrollSnap()) 625 634 return; 626 635 … … 637 646 m_statelessSnapTransitionTimer = nullptr; 638 647 639 if (! m_scrollSnapState)648 if (!usesScrollSnap()) 640 649 return; 641 650 … … 656 665 bool ScrollController::processWheelEventForScrollSnap(const PlatformWheelEvent& wheelEvent) 657 666 { 658 if (! m_scrollSnapState)667 if (!usesScrollSnap()) 659 668 return true; 660 669 … … 662 671 return true; 663 672 664 WheelEventStatusstatus = toWheelEventStatus(wheelEvent.phase(), wheelEvent.momentumPhase());673 auto status = toWheelEventStatus(wheelEvent.phase(), wheelEvent.momentumPhase()); 665 674 666 675 LOG_WITH_STREAM(ScrollSnap, stream << "ScrollController " << this << " processWheelEventForScrollSnap: status " << status); 667 676 668 bool is InertialScrolling = false;677 bool isMomentumScrolling = false; 669 678 switch (status) { 670 679 case WheelEventStatus::UserScrollBegin: … … 678 687 startScrollSnapTimer(); 679 688 break; 680 case WheelEventStatus:: InertialScrollBegin:689 case WheelEventStatus::MomentumScrollBegin: 681 690 m_scrollSnapState->transitionToGlideAnimationState(m_client.scrollExtent(), m_client.viewportSize(), m_client.pageScaleFactor(), m_client.scrollOffset(), m_dragEndedScrollingVelocity, FloatSize(-wheelEvent.deltaX(), -wheelEvent.deltaY())); 682 691 m_dragEndedScrollingVelocity = { }; 683 is InertialScrolling = true;692 isMomentumScrolling = true; 684 693 break; 685 case WheelEventStatus:: InertialScrolling:686 case WheelEventStatus:: InertialScrollEnd:687 is InertialScrolling = true;694 case WheelEventStatus::MomentumScrolling: 695 case WheelEventStatus::MomentumScrollEnd: 696 isMomentumScrolling = true; 688 697 break; 689 698 case WheelEventStatus::StatelessScrollEvent: … … 696 705 } 697 706 698 return !(isInertialScrolling && shouldOverrideInertialScrolling()); 707 return !(isMomentumScrolling && shouldOverrideMomentumScrolling()); 708 } 709 710 void ScrollController::updateGestureInProgressState(const PlatformWheelEvent& wheelEvent) 711 { 712 if (wheelEvent.isGestureBegin() || wheelEvent.isTransitioningToMomentumScroll()) 713 m_inScrollGesture = true; 714 else if (wheelEvent.isEndOfNonMomentumScroll() || wheelEvent.isGestureCancel() || wheelEvent.isEndOfMomentumScroll()) 715 m_inScrollGesture = false; 699 716 } 700 717 … … 730 747 void ScrollController::scrollSnapTimerFired() 731 748 { 732 if (! m_scrollSnapState) {749 if (!usesScrollSnap()) { 733 750 ASSERT_NOT_REACHED(); 734 751 return; … … 787 804 unsigned ScrollController::activeScrollSnapIndexForAxis(ScrollEventAxis axis) const 788 805 { 789 if (! m_scrollSnapState)806 if (!usesScrollSnap()) 790 807 return 0; 791 808 … … 795 812 void ScrollController::setActiveScrollSnapIndexForAxis(ScrollEventAxis axis, unsigned index) 796 813 { 797 if (! m_scrollSnapState)814 if (!usesScrollSnap()) 798 815 return; 799 816 … … 803 820 void ScrollController::setNearestScrollSnapIndexForAxisAndOffset(ScrollEventAxis axis, int offset) 804 821 { 805 if (! m_scrollSnapState)822 if (!usesScrollSnap()) 806 823 return; 807 824 … … 827 844 void ScrollController::setActiveScrollSnapIndicesForOffset(int x, int y) 828 845 { 829 if (! m_scrollSnapState)846 if (!usesScrollSnap()) 830 847 return; 831 848 -
trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm
r264151 r264190 1273 1273 return ScrollAnimator::handleWheelEvent(wheelEvent); 1274 1274 1275 m_scrollController.updateGestureInProgressState(wheelEvent); 1276 1275 1277 // FIXME: This is somewhat roundabout hack to allow forwarding wheel events 1276 1278 // up to the parent scrollable area. It takes advantage of the fact that
Note:
See TracChangeset
for help on using the changeset viewer.