Changeset 285953 in webkit
- Timestamp:
- Nov 17, 2021, 2:21:59 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 10 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/page/WheelEventDeltaFilter.cpp (modified) (1 diff)
-
WebCore/page/WheelEventDeltaFilter.h (modified) (2 diffs)
-
WebCore/page/mac/WheelEventDeltaFilterMac.h (modified) (1 diff)
-
WebCore/page/mac/WheelEventDeltaFilterMac.mm (modified) (3 diffs)
-
WebCore/platform/PlatformWheelEvent.h (modified) (1 diff)
-
WebCore/platform/ScrollingEffectsController.h (modified) (1 diff)
-
WebCore/platform/mac/ScrollingEffectsController.mm (modified) (2 diffs)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/WebProcess/WebPage/EventDispatcher.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r285949 r285953 1 2021-11-17 Tim Horton <timothy_horton@apple.com> 2 3 Momentum animator sometimes starts the animation at a very high velocity 4 https://bugs.webkit.org/show_bug.cgi?id=233245 5 <rdar://problem/85307115> 6 7 Reviewed by Simon Fraser. 8 9 * page/WheelEventDeltaFilter.cpp: 10 (WebCore::WheelEventDeltaFilter::eventCopyWithVelocity const): 11 * page/WheelEventDeltaFilter.h: 12 * platform/PlatformWheelEvent.h: 13 (WebCore::PlatformWheelEvent::copyWithVelocity const): 14 Make it possible to ask the delta filter to only add velocity data without filtering deltas. 15 We should later make ScrollingEffectsController talk directly to the 16 WheelEventDeltaFilter to get the velocity, but that requires a great 17 deal of scrolling thread plumbing. 18 19 * page/mac/WheelEventDeltaFilterMac.h: 20 * page/mac/WheelEventDeltaFilterMac.mm: 21 (WebCore::WheelEventDeltaFilterMac::updateFromEvent): 22 Factor updateCurrentVelocityFromEvent out. 23 Update the current velocity for momentum begin phase events as well. 24 25 (WebCore::WheelEventDeltaFilterMac::updateCurrentVelocityFromEvent): 26 27 * platform/ScrollingEffectsController.h: 28 * platform/mac/ScrollingEffectsController.mm: 29 (WebCore::ScrollingEffectsController::handleWheelEvent): 30 Start the momentum animation with the velocity provided by the momentum 31 begin phase, instead of a potentially incorrect delta from an earlier change phase. 32 1 33 2021-11-17 Wenson Hsieh <wenson_hsieh@apple.com> 2 34 -
trunk/Source/WebCore/page/WheelEventDeltaFilter.cpp
r285787 r285953 63 63 } 64 64 65 bool WheelEventDeltaFilter::shouldIncludeVelocityForEvent(const PlatformWheelEvent& event) 66 { 67 #if ENABLE(KINETIC_SCROLLING) 68 // Include velocity on momentum-began phases so that the momentum animator can use it. 69 if (event.momentumPhase() == PlatformWheelEventPhase::Began) 70 return true; 71 #endif 72 return shouldApplyFilteringForEvent(event); 73 } 74 65 75 PlatformWheelEvent WheelEventDeltaFilter::eventCopyWithFilteredDeltas(const PlatformWheelEvent& event) const 66 76 { 67 77 return event.copyWithDeltaAndVelocity(m_currentFilteredDelta, m_currentFilteredVelocity); 78 } 79 80 PlatformWheelEvent WheelEventDeltaFilter::eventCopyWithVelocity(const PlatformWheelEvent& event) const 81 { 82 return event.copyWithVelocity(m_currentFilteredVelocity); 68 83 } 69 84 -
trunk/Source/WebCore/page/WheelEventDeltaFilter.h
r285787 r285953 44 44 45 45 WEBCORE_EXPORT PlatformWheelEvent eventCopyWithFilteredDeltas(const PlatformWheelEvent&) const; 46 WEBCORE_EXPORT PlatformWheelEvent eventCopyWithVelocity(const PlatformWheelEvent&) const; 46 47 47 48 WEBCORE_EXPORT FloatSize filteredVelocity() const; … … 49 50 50 51 WEBCORE_EXPORT static bool shouldApplyFilteringForEvent(const PlatformWheelEvent&); 52 WEBCORE_EXPORT static bool shouldIncludeVelocityForEvent(const PlatformWheelEvent&); 51 53 52 54 protected: -
trunk/Source/WebCore/page/mac/WheelEventDeltaFilterMac.h
r285883 r285953 46 46 void reset(); 47 47 48 void updateCurrentVelocityFromEvent(const PlatformWheelEvent&); 49 48 50 RetainPtr<_NSScrollingPredominantAxisFilter> m_predominantAxisFilter; 49 51 WallTime m_initialWallTime; -
trunk/Source/WebCore/page/mac/WheelEventDeltaFilterMac.mm
r285883 r285953 46 46 { 47 47 if (event.momentumPhase() != PlatformWheelEventPhase::None) { 48 if (event.momentumPhase() == PlatformWheelEventPhase::Began) 49 updateCurrentVelocityFromEvent(event); 48 50 m_lastIOHIDEventTimestamp = event.ioHIDEventTimestamp(); 49 51 return; 50 52 } 51 52 // The absolute value of timestamp doesn't matter; the filter looks at deltas from the previous event.53 auto timestamp = event.timestamp() - m_initialWallTime;54 53 55 54 switch (event.phase()) { … … 60 59 case PlatformWheelEventPhase::Began: 61 60 reset(); 62 FALLTHROUGH; 63 case PlatformWheelEventPhase::Changed: { 64 NSPoint filteredDeltaResult; 65 NSPoint filteredVelocityResult; 61 updateCurrentVelocityFromEvent(event); 62 break; 66 63 67 [m_predominantAxisFilter filterInputDelta:toFloatPoint(event.delta()) timestamp:timestamp.seconds() outputDelta:&filteredDeltaResult velocity:&filteredVelocityResult];68 auto axisFilteredVelocity = toFloatSize(filteredVelocityResult);69 m_currentFilteredDelta = toFloatSize(filteredDeltaResult);64 case PlatformWheelEventPhase::Changed: 65 updateCurrentVelocityFromEvent(event); 66 break; 70 67 71 // Use a 1ms minimum to avoid divide by zero. The usual cadence of these events matches screen refresh rate.72 auto deltaFromLastEvent = std::max(event.ioHIDEventTimestamp() - m_lastIOHIDEventTimestamp, 1_ms);73 m_currentFilteredVelocity = event.delta() / deltaFromLastEvent.seconds();74 75 // Apply the axis-locking that m_predominantAxisFilter does.76 if (!axisFilteredVelocity.width())77 m_currentFilteredVelocity.setWidth(0);78 if (!axisFilteredVelocity.height())79 m_currentFilteredVelocity.setHeight(0);80 81 LOG(ScrollAnimations, "WheelEventDeltaFilterMac::updateFromEvent: _NSScrollingPredominantAxisFilter velocity %.2f, %2f, IOHIDEvent velocity %.2f,%.2f",82 axisFilteredVelocity.width(), axisFilteredVelocity.height(), m_currentFilteredVelocity.width(), m_currentFilteredVelocity.height());83 break;84 }85 68 case PlatformWheelEventPhase::MayBegin: 86 69 case PlatformWheelEventPhase::Cancelled: … … 91 74 92 75 m_lastIOHIDEventTimestamp = event.ioHIDEventTimestamp(); 76 } 77 78 void WheelEventDeltaFilterMac::updateCurrentVelocityFromEvent(const PlatformWheelEvent& event) 79 { 80 // The absolute value of timestamp doesn't matter; the filter looks at deltas from the previous event. 81 auto timestamp = event.timestamp() - m_initialWallTime; 82 83 NSPoint filteredDeltaResult; 84 NSPoint filteredVelocityResult; 85 86 [m_predominantAxisFilter filterInputDelta:toFloatPoint(event.delta()) timestamp:timestamp.seconds() outputDelta:&filteredDeltaResult velocity:&filteredVelocityResult]; 87 auto axisFilteredVelocity = toFloatSize(filteredVelocityResult); 88 m_currentFilteredDelta = toFloatSize(filteredDeltaResult); 89 90 // Use a 1ms minimum to avoid divide by zero. The usual cadence of these events matches screen refresh rate. 91 auto deltaFromLastEvent = std::max(event.ioHIDEventTimestamp() - m_lastIOHIDEventTimestamp, 1_ms); 92 m_currentFilteredVelocity = event.delta() / deltaFromLastEvent.seconds(); 93 94 // Apply the axis-locking that m_predominantAxisFilter does. 95 if (!axisFilteredVelocity.width()) 96 m_currentFilteredVelocity.setWidth(0); 97 if (!axisFilteredVelocity.height()) 98 m_currentFilteredVelocity.setHeight(0); 99 100 LOG(ScrollAnimations, "WheelEventDeltaFilterMac::updateFromEvent: _NSScrollingPredominantAxisFilter velocity %.2f, %2f, IOHIDEvent velocity %.2f,%.2f", 101 axisFilteredVelocity.width(), axisFilteredVelocity.height(), m_currentFilteredVelocity.width(), m_currentFilteredVelocity.height()); 93 102 } 94 103 -
trunk/Source/WebCore/platform/PlatformWheelEvent.h
r285790 r285953 130 130 } 131 131 132 PlatformWheelEvent copyWithVelocity(FloatSize velocity) const 133 { 134 PlatformWheelEvent copy = *this; 135 copy.m_scrollingVelocity = velocity; 136 return copy; 137 } 138 132 139 const IntPoint& position() const { return m_position; } // PlatformWindow coordinates. 133 140 const IntPoint& globalPosition() const { return m_globalPosition; } // Screen coordinates. -
trunk/Source/WebCore/platform/ScrollingEffectsController.h
r285917 r285953 261 261 FloatSize m_momentumVelocity; 262 262 263 FloatSize m_scrollingVelocityForMomentumAnimation; // Do we need both this, m_scrollingVelocityForScrollSnap and m_momentumVelocity?264 263 FloatSize m_scrollingVelocityForScrollSnap; 265 264 #if !LOG_DISABLED -
trunk/Source/WebCore/platform/mac/ScrollingEffectsController.mm
r285917 r285953 130 130 bool ScrollingEffectsController::handleWheelEvent(const PlatformWheelEvent& wheelEvent) 131 131 { 132 if (WheelEventDeltaFilter::shouldApplyFilteringForEvent(wheelEvent))133 m_scrollingVelocityForMomentumAnimation = -wheelEvent.scrollingVelocity(); // Note that event delta is reversed from scroll direction.134 135 132 if (processWheelEventForScrollSnap(wheelEvent)) 136 133 return true; … … 229 226 m_momentumScrollInProgress = true; 230 227 if (momentumScrollingAnimatorEnabled()) { 231 startMomentumScrollWithInitialVelocity(m_client.scrollOffset(), m_scrollingVelocityForMomentumAnimation, -wheelEvent.delta(), [](const FloatPoint& targetOffset) { return targetOffset; });228 startMomentumScrollWithInitialVelocity(m_client.scrollOffset(), -wheelEvent.scrollingVelocity(), -wheelEvent.delta(), [](const FloatPoint& targetOffset) { return targetOffset; }); 232 229 #if !LOG_DISABLED 233 230 m_eventDrivenScrollOffset = m_client.scrollOffset(); -
trunk/Source/WebKit/ChangeLog
r285949 r285953 1 2021-11-17 Tim Horton <timothy_horton@apple.com> 2 3 Momentum animator sometimes starts the animation at a very high velocity 4 https://bugs.webkit.org/show_bug.cgi?id=233245 5 <rdar://problem/85307115> 6 7 Reviewed by Simon Fraser. 8 9 * WebProcess/WebPage/EventDispatcher.cpp: 10 (WebKit::EventDispatcher::wheelEvent): 11 Ensure that wheel events always have velocities attached, even for 12 events that don't go through the delta filter. 13 1 14 2021-11-17 Wenson Hsieh <wenson_hsieh@apple.com> 2 15 -
trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp
r285375 r285953 107 107 if (WheelEventDeltaFilter::shouldApplyFilteringForEvent(platformWheelEvent)) 108 108 platformWheelEvent = m_recentWheelEventDeltaFilter->eventCopyWithFilteredDeltas(platformWheelEvent); 109 else if (WheelEventDeltaFilter::shouldIncludeVelocityForEvent(platformWheelEvent)) 110 platformWheelEvent = m_recentWheelEventDeltaFilter->eventCopyWithVelocity(platformWheelEvent); 109 111 #endif 110 112
Note:
See TracChangeset
for help on using the changeset viewer.