Title: [285943] branches/safari-613.1.9.0-branch/Source/WebCore
- Revision
- 285943
- Author
- [email protected]
- Date
- 2021-11-17 11:14:41 -0800 (Wed, 17 Nov 2021)
Log Message
Cherry-pick r285883. rdar://problem/85512520
Use IOHIDEvent timestamps for momentum velocity computation
https://bugs.webkit.org/show_bug.cgi?id=233168
Reviewed by Tim Horton.
NSEvent timetamps can have some jitter on some devices (rdar://85309639) so drop
down to IOHIDEvent timestamps when computing the initial velocity for a momentum
scroll animation, for improved accuracy.
* page/mac/WheelEventDeltaFilterMac.h:
* page/mac/WheelEventDeltaFilterMac.mm:
(WebCore::WheelEventDeltaFilterMac::updateFromEvent):
(WebCore::WheelEventDeltaFilterMac::reset):
* page/scrolling/ThreadedScrollingTree.cpp:
(WebCore::ThreadedScrollingTree::willStartRenderingUpdate):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@285883 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Modified Paths
Diff
Modified: branches/safari-613.1.9.0-branch/Source/WebCore/ChangeLog (285942 => 285943)
--- branches/safari-613.1.9.0-branch/Source/WebCore/ChangeLog 2021-11-17 19:14:37 UTC (rev 285942)
+++ branches/safari-613.1.9.0-branch/Source/WebCore/ChangeLog 2021-11-17 19:14:41 UTC (rev 285943)
@@ -1,5 +1,46 @@
2021-11-17 Alan Coon <[email protected]>
+ Cherry-pick r285883. rdar://problem/85512520
+
+ Use IOHIDEvent timestamps for momentum velocity computation
+ https://bugs.webkit.org/show_bug.cgi?id=233168
+
+ Reviewed by Tim Horton.
+
+ NSEvent timetamps can have some jitter on some devices (rdar://85309639) so drop
+ down to IOHIDEvent timestamps when computing the initial velocity for a momentum
+ scroll animation, for improved accuracy.
+
+ * page/mac/WheelEventDeltaFilterMac.h:
+ * page/mac/WheelEventDeltaFilterMac.mm:
+ (WebCore::WheelEventDeltaFilterMac::updateFromEvent):
+ (WebCore::WheelEventDeltaFilterMac::reset):
+ * page/scrolling/ThreadedScrollingTree.cpp:
+ (WebCore::ThreadedScrollingTree::willStartRenderingUpdate):
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@285883 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-11-16 Simon Fraser <[email protected]>
+
+ Use IOHIDEvent timestamps for momentum velocity computation
+ https://bugs.webkit.org/show_bug.cgi?id=233168
+
+ Reviewed by Tim Horton.
+
+ NSEvent timetamps can have some jitter on some devices (rdar://85309639) so drop
+ down to IOHIDEvent timestamps when computing the initial velocity for a momentum
+ scroll animation, for improved accuracy.
+
+ * page/mac/WheelEventDeltaFilterMac.h:
+ * page/mac/WheelEventDeltaFilterMac.mm:
+ (WebCore::WheelEventDeltaFilterMac::updateFromEvent):
+ (WebCore::WheelEventDeltaFilterMac::reset):
+ * page/scrolling/ThreadedScrollingTree.cpp:
+ (WebCore::ThreadedScrollingTree::willStartRenderingUpdate):
+
+2021-11-17 Alan Coon <[email protected]>
+
Cherry-pick r285797. rdar://problem/85512520
Fingers down on the trackpad should stop an animated scroll
Modified: branches/safari-613.1.9.0-branch/Source/WebCore/page/mac/WheelEventDeltaFilterMac.h (285942 => 285943)
--- branches/safari-613.1.9.0-branch/Source/WebCore/page/mac/WheelEventDeltaFilterMac.h 2021-11-17 19:14:37 UTC (rev 285942)
+++ branches/safari-613.1.9.0-branch/Source/WebCore/page/mac/WheelEventDeltaFilterMac.h 2021-11-17 19:14:41 UTC (rev 285943)
@@ -47,6 +47,7 @@
RetainPtr<_NSScrollingPredominantAxisFilter> m_predominantAxisFilter;
WallTime m_initialWallTime;
+ WallTime m_lastIOHIDEventTimestamp;
};
} // namespace WebCore
Modified: branches/safari-613.1.9.0-branch/Source/WebCore/page/mac/WheelEventDeltaFilterMac.mm (285942 => 285943)
--- branches/safari-613.1.9.0-branch/Source/WebCore/page/mac/WheelEventDeltaFilterMac.mm 2021-11-17 19:14:37 UTC (rev 285942)
+++ branches/safari-613.1.9.0-branch/Source/WebCore/page/mac/WheelEventDeltaFilterMac.mm 2021-11-17 19:14:41 UTC (rev 285943)
@@ -29,6 +29,7 @@
#import "WheelEventDeltaFilterMac.h"
#import "FloatPoint.h"
+#import "Logging.h"
#import "PlatformWheelEvent.h"
#import <pal/spi/mac/NSScrollingInputFilterSPI.h>
@@ -43,8 +44,10 @@
void WheelEventDeltaFilterMac::updateFromEvent(const PlatformWheelEvent& event)
{
- if (event.momentumPhase() != PlatformWheelEventPhase::None)
+ if (event.momentumPhase() != PlatformWheelEventPhase::None) {
+ m_lastIOHIDEventTimestamp = event.ioHIDEventTimestamp();
return;
+ }
// The absolute value of timestamp doesn't matter; the filter looks at deltas from the previous event.
auto timestamp = event.timestamp() - m_initialWallTime;
@@ -51,25 +54,42 @@
switch (event.phase()) {
case PlatformWheelEventPhase::None:
+ case PlatformWheelEventPhase::Ended:
break;
case PlatformWheelEventPhase::Began:
+ reset();
+ FALLTHROUGH;
case PlatformWheelEventPhase::Changed: {
NSPoint filteredDeltaResult;
NSPoint filteredVelocityResult;
[m_predominantAxisFilter filterInputDelta:toFloatPoint(event.delta()) timestamp:timestamp.seconds() outputDelta:&filteredDeltaResult velocity:&filteredVelocityResult];
- m_currentFilteredVelocity = toFloatSize(filteredVelocityResult);
+ auto axisFilteredVelocity = toFloatSize(filteredVelocityResult);
m_currentFilteredDelta = toFloatSize(filteredDeltaResult);
+
+ // Use a 1ms minimum to avoid divide by zero. The usual cadence of these events matches screen refresh rate.
+ auto deltaFromLastEvent = std::max(event.ioHIDEventTimestamp() - m_lastIOHIDEventTimestamp, 1_ms);
+ m_currentFilteredVelocity = event.delta() / deltaFromLastEvent.seconds();
+
+ // Apply the axis-locking that m_predominantAxisFilter does.
+ if (!axisFilteredVelocity.width())
+ m_currentFilteredVelocity.setWidth(0);
+ if (!axisFilteredVelocity.height())
+ m_currentFilteredVelocity.setHeight(0);
+
+ LOG(ScrollAnimations, "WheelEventDeltaFilterMac::updateFromEvent: _NSScrollingPredominantAxisFilter velocity %.2f, %2f, IOHIDEvent velocity %.2f,%.2f",
+ axisFilteredVelocity.width(), axisFilteredVelocity.height(), m_currentFilteredVelocity.width(), m_currentFilteredVelocity.height());
break;
}
case PlatformWheelEventPhase::MayBegin:
case PlatformWheelEventPhase::Cancelled:
case PlatformWheelEventPhase::Stationary:
- case PlatformWheelEventPhase::Ended:
reset();
break;
}
+
+ m_lastIOHIDEventTimestamp = event.ioHIDEventTimestamp();
}
void WheelEventDeltaFilterMac::reset()
@@ -77,6 +97,7 @@
[m_predominantAxisFilter reset];
m_currentFilteredVelocity = { };
m_currentFilteredDelta = { };
+ m_lastIOHIDEventTimestamp = { };
}
}
Modified: branches/safari-613.1.9.0-branch/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp (285942 => 285943)
--- branches/safari-613.1.9.0-branch/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp 2021-11-17 19:14:37 UTC (rev 285942)
+++ branches/safari-613.1.9.0-branch/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp 2021-11-17 19:14:41 UTC (rev 285943)
@@ -337,8 +337,6 @@
{
ASSERT(isMainThread());
- LOG_WITH_STREAM(ScrollAnimations, stream << "ThreadedScrollingTree::willStartRenderingUpdate - scrollingThreadIsActive " << scrollingThreadIsActive());
-
if (!scrollingThreadIsActive())
return;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes