Modified: trunk/Source/WebCore/ChangeLog (264145 => 264146)
--- trunk/Source/WebCore/ChangeLog 2020-07-09 02:49:33 UTC (rev 264145)
+++ trunk/Source/WebCore/ChangeLog 2020-07-09 03:19:09 UTC (rev 264146)
@@ -1,3 +1,20 @@
+2020-07-08 Simon Fraser <[email protected]>
+
+ Clean up time values in ScrollController
+ https://bugs.webkit.org/show_bug.cgi?id=214117
+
+ Reviewed by Wenson Hsieh.
+
+ ScrollController used a mixture of [NSDate timeIntervalSinceReferenceDate], [NSProcessInfo processInfo].systemUptime
+ and wheelEvent.timestamp().secondsSinceEpoch(). Standardize on Seconds/MonotonicTime/WallTime.
+
+ * platform/cocoa/ScrollController.h:
+ * platform/cocoa/ScrollController.mm:
+ (WebCore::elasticDeltaForTimeDelta):
+ (WebCore::ScrollController::handleWheelEvent):
+ (WebCore::ScrollController::snapRubberBandTimerFired):
+ (WebCore::ScrollController::snapRubberBand):
+
2020-07-08 Brady Eidson <[email protected]>
Aggressively prime GameController.framework gamepad provider.
Modified: trunk/Source/WebCore/platform/cocoa/ScrollController.h (264145 => 264146)
--- trunk/Source/WebCore/platform/cocoa/ScrollController.h 2020-07-09 02:49:33 UTC (rev 264145)
+++ trunk/Source/WebCore/platform/cocoa/ScrollController.h 2020-07-09 03:19:09 UTC (rev 264146)
@@ -190,7 +190,7 @@
ScrollControllerClient& m_client;
#if PLATFORM(MAC)
- CFTimeInterval m_lastMomentumScrollTimestamp { 0 };
+ WallTime m_lastMomentumScrollTimestamp;
#endif
FloatSize m_overflowScrollDelta;
FloatSize m_stretchScrollForce;
@@ -198,7 +198,7 @@
#if ENABLE(RUBBER_BANDING)
// Rubber band state.
- CFTimeInterval m_startTime { 0 };
+ MonotonicTime m_startTime;
FloatSize m_startStretch;
FloatSize m_origVelocity;
std::unique_ptr<ScrollControllerTimer> m_snapRubberbandTimer;
Modified: trunk/Source/WebCore/platform/cocoa/ScrollController.mm (264145 => 264146)
--- trunk/Source/WebCore/platform/cocoa/ScrollController.mm 2020-07-09 02:49:33 UTC (rev 264145)
+++ trunk/Source/WebCore/platform/cocoa/ScrollController.mm 2020-07-09 03:19:09 UTC (rev 264146)
@@ -48,15 +48,15 @@
namespace WebCore {
#if ENABLE(RUBBER_BANDING)
-static const float scrollVelocityZeroingTimeout = 0.10f;
+static const Seconds scrollVelocityZeroingTimeout = 100_ms;
static const float rubberbandDirectionLockStretchRatio = 1;
static const float rubberbandMinimumRequiredDeltaBeforeStretch = 10;
#endif
#if PLATFORM(MAC)
-static float elasticDeltaForTimeDelta(float initialPosition, float initialVelocity, float elapsedTime)
+static float elasticDeltaForTimeDelta(float initialPosition, float initialVelocity, Seconds elapsedTime)
{
- return _NSElasticDeltaForTimeDelta(initialPosition, initialVelocity, elapsedTime);
+ return _NSElasticDeltaForTimeDelta(initialPosition, initialVelocity, elapsedTime.seconds());
}
static float elasticDeltaForReboundDelta(float delta)
@@ -140,8 +140,8 @@
m_inScrollGesture = true;
m_momentumScrollInProgress = false;
m_ignoreMomentumScrolls = false;
- m_lastMomentumScrollTimestamp = 0;
- m_momentumVelocity = FloatSize();
+ m_lastMomentumScrollTimestamp = { };
+ m_momentumVelocity = { };
IntSize stretchAmount = m_client.stretchAmount();
m_stretchScrollForce.setWidth(reboundDeltaForElasticDelta(stretchAmount.width()));
@@ -206,14 +206,14 @@
if (!m_momentumScrollInProgress && (momentumPhase == PlatformWheelEventPhaseBegan || momentumPhase == PlatformWheelEventPhaseChanged))
m_momentumScrollInProgress = true;
- CFTimeInterval timeDelta = wheelEvent.timestamp().secondsSinceEpoch().value() - m_lastMomentumScrollTimestamp;
+ auto timeDelta = wheelEvent.timestamp() - m_lastMomentumScrollTimestamp;
if (m_inScrollGesture || m_momentumScrollInProgress) {
- if (m_lastMomentumScrollTimestamp && timeDelta > 0 && timeDelta < scrollVelocityZeroingTimeout) {
- m_momentumVelocity.setWidth(eventCoalescedDeltaX / (float)timeDelta);
- m_momentumVelocity.setHeight(eventCoalescedDeltaY / (float)timeDelta);
- m_lastMomentumScrollTimestamp = wheelEvent.timestamp().secondsSinceEpoch().value();
+ if (m_lastMomentumScrollTimestamp && timeDelta > 0_s && timeDelta < scrollVelocityZeroingTimeout) {
+ m_momentumVelocity.setWidth(eventCoalescedDeltaX / timeDelta.seconds());
+ m_momentumVelocity.setHeight(eventCoalescedDeltaY / timeDelta.seconds());
+ m_lastMomentumScrollTimestamp = wheelEvent.timestamp();
} else {
- m_lastMomentumScrollTimestamp = wheelEvent.timestamp().secondsSinceEpoch().value();
+ m_lastMomentumScrollTimestamp = wheelEvent.timestamp();
m_momentumVelocity = FloatSize();
}
@@ -311,7 +311,7 @@
if (m_momentumScrollInProgress && momentumPhase == PlatformWheelEventPhaseEnded) {
m_momentumScrollInProgress = false;
m_ignoreMomentumScrolls = false;
- m_lastMomentumScrollTimestamp = 0;
+ m_lastMomentumScrollTimestamp = { };
}
return handled;
@@ -398,15 +398,15 @@
return;
if (!m_momentumScrollInProgress || m_ignoreMomentumScrolls) {
- CFTimeInterval timeDelta = [NSDate timeIntervalSinceReferenceDate] - m_startTime;
+ auto timeDelta = MonotonicTime::now() - m_startTime;
- if (m_startStretch == FloatSize()) {
+ if (m_startStretch.isZero()) {
m_startStretch = m_client.stretchAmount();
if (m_startStretch == FloatSize()) {
stopSnapRubberbandTimer();
m_stretchScrollForce = { };
- m_startTime = 0;
+ m_startTime = { };
m_startStretch = { };
m_origVelocity = { };
return;
@@ -427,8 +427,8 @@
m_origVelocity.setHeight(0);
}
- FloatPoint delta(roundToDevicePixelTowardZero(elasticDeltaForTimeDelta(m_startStretch.width(), -m_origVelocity.width(), (float)timeDelta)),
- roundToDevicePixelTowardZero(elasticDeltaForTimeDelta(m_startStretch.height(), -m_origVelocity.height(), (float)timeDelta)));
+ FloatPoint delta(roundToDevicePixelTowardZero(elasticDeltaForTimeDelta(m_startStretch.width(), -m_origVelocity.width(), timeDelta)),
+ roundToDevicePixelTowardZero(elasticDeltaForTimeDelta(m_startStretch.height(), -m_origVelocity.height(), timeDelta)));
if (fabs(delta.x()) >= 1 || fabs(delta.y()) >= 1) {
m_client.immediateScrollByWithoutContentEdgeConstraints(FloatSize(delta.x(), delta.y()) - m_client.stretchAmount());
@@ -442,12 +442,12 @@
stopSnapRubberbandTimer();
m_stretchScrollForce = { };
- m_startTime = 0;
+ m_startTime = { };
m_startStretch = { };
m_origVelocity = { };
}
} else {
- m_startTime = [NSDate timeIntervalSinceReferenceDate];
+ m_startTime = MonotonicTime::now();
m_startStretch = { };
if (!isRubberBandInProgress())
stopSnapRubberbandTimer();
@@ -504,9 +504,9 @@
void ScrollController::snapRubberBand()
{
- CFTimeInterval timeDelta = [NSProcessInfo processInfo].systemUptime - m_lastMomentumScrollTimestamp;
+ auto timeDelta = WallTime::now() - m_lastMomentumScrollTimestamp;
if (m_lastMomentumScrollTimestamp && timeDelta >= scrollVelocityZeroingTimeout)
- m_momentumVelocity = FloatSize();
+ m_momentumVelocity = { };
m_inScrollGesture = false;
@@ -513,7 +513,7 @@
if (m_snapRubberbandTimer)
return;
- m_startTime = [NSDate timeIntervalSinceReferenceDate];
+ m_startTime = MonotonicTime::now();
m_startStretch = { };
m_origVelocity = { };