Bug 1457586 - Simplify Axis::UpdateWithTouchAtDevicePoint() by removing the aAdditionalDelta parameter. r=mstange
MozReview-Commit-ID: CBBPhfRkl97
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -1496,18 +1496,18 @@ nsEventStatus AsyncPanZoomController::On
ToScreenCoordinates(focusChange, focusPoint));
bool allowZoom = mZoomConstraints.mAllowZoom && !mPinchLocked;
// If zooming is not allowed, this is a two-finger pan.
// Tracking panning distance and velocity.
// UpdateWithTouchAtDevicePoint() acquires the tree lock, so
// it cannot be called while the mRecursiveMutex lock is held.
if (!allowZoom) {
- mX.UpdateWithTouchAtDevicePoint(aEvent.mLocalFocusPoint.x, 0, aEvent.mTime);
- mY.UpdateWithTouchAtDevicePoint(aEvent.mLocalFocusPoint.y, 0, aEvent.mTime);
+ mX.UpdateWithTouchAtDevicePoint(aEvent.mLocalFocusPoint.x, aEvent.mTime);
+ mY.UpdateWithTouchAtDevicePoint(aEvent.mLocalFocusPoint.y, aEvent.mTime);
}
if (!gfxPrefs::APZAllowZooming()) {
if (RefPtr<GeckoContentController> controller = GetGeckoContentController()) {
controller->NotifyPinchGesture(aEvent.mType, GetGuid(),
ViewAs<LayoutDevicePixel>(aEvent.mCurrentSpan - aEvent.mPreviousSpan,
PixelCastJustification::LayoutDeviceIsParentLayerForRCDRSF),
aEvent.modifiers);
@@ -2448,18 +2448,18 @@ nsEventStatus AsyncPanZoomController::On
MOZ_ASSERT(GetCurrentPanGestureBlock());
AdjustDeltaForAllowedScrollDirections(logicalPanDisplacement,
GetCurrentPanGestureBlock()->GetAllowedScrollDirections());
// We need to update the axis velocity in order to get a useful display port
// size and position. We need to do so even if this is a momentum pan (i.e.
// aFingersOnTouchpad == false); in that case the "with touch" part is not
// really appropriate, so we may want to rethink this at some point.
- mX.UpdateWithTouchAtDevicePoint(aEvent.mLocalPanStartPoint.x, logicalPanDisplacement.x, aEvent.mTime);
- mY.UpdateWithTouchAtDevicePoint(aEvent.mLocalPanStartPoint.y, logicalPanDisplacement.y, aEvent.mTime);
+ mX.UpdateWithTouchAtDevicePoint(mX.GetPos() + logicalPanDisplacement.x, aEvent.mTime);
+ mY.UpdateWithTouchAtDevicePoint(mY.GetPos() + logicalPanDisplacement.y, aEvent.mTime);
HandlePanningUpdate(physicalPanDisplacement);
ScreenPoint panDistance(fabs(physicalPanDisplacement.x), fabs(physicalPanDisplacement.y));
OverscrollHandoffState handoffState(
*GetCurrentPanGestureBlock()->GetOverscrollHandoffChain(),
panDistance,
ScrollSource::Wheel);
@@ -2886,18 +2886,18 @@ AsyncPanZoomController::StartPanning(con
return nsEventStatus_eConsumeNoDefault;
}
// Don't consume an event that didn't trigger a panning.
return nsEventStatus_eIgnore;
}
void AsyncPanZoomController::UpdateWithTouchAtDevicePoint(const MultiTouchInput& aEvent) {
ParentLayerPoint point = GetFirstTouchPoint(aEvent);
- mX.UpdateWithTouchAtDevicePoint(point.x, 0, aEvent.mTime);
- mY.UpdateWithTouchAtDevicePoint(point.y, 0, aEvent.mTime);
+ mX.UpdateWithTouchAtDevicePoint(point.x, aEvent.mTime);
+ mY.UpdateWithTouchAtDevicePoint(point.y, aEvent.mTime);
}
bool AsyncPanZoomController::AttemptScroll(ParentLayerPoint& aStartPoint,
ParentLayerPoint& aEndPoint,
OverscrollHandoffState& aOverscrollHandoffState) {
// "start - end" rather than "end - start" because e.g. moving your finger
// down (*positive* direction along y axis) causes the vertical scroll offset
--- a/gfx/layers/apz/src/Axis.cpp
+++ b/gfx/layers/apz/src/Axis.cpp
@@ -66,34 +66,34 @@ float Axis::ToLocalVelocity(float aVeloc
ScreenPoint panStart = mAsyncPanZoomController->ToScreenCoordinates(
mAsyncPanZoomController->PanStart(),
ParentLayerPoint());
ParentLayerPoint localVelocity =
mAsyncPanZoomController->ToParentLayerCoordinates(velocity, panStart);
return localVelocity.Length();
}
-void Axis::UpdateWithTouchAtDevicePoint(ParentLayerCoord aPos, ParentLayerCoord aAdditionalDelta, uint32_t aTimestampMs) {
+void Axis::UpdateWithTouchAtDevicePoint(ParentLayerCoord aPos, uint32_t aTimestampMs) {
// mVelocityQueue is controller-thread only
APZThreadUtils::AssertOnControllerThread();
if (aTimestampMs <= mVelocitySampleTimeMs + MIN_VELOCITY_SAMPLE_TIME_MS) {
// See also the comment on MIN_VELOCITY_SAMPLE_TIME_MS.
// We still update mPos so that the positioning is correct (and we don't run
// into problems like bug 1042734) but the velocity will remain where it was.
// In particular we don't update either mVelocitySampleTimeMs or
// mVelocitySamplePos so that eventually when we do get an event with the
// required time delta we use the corresponding distance delta as well.
AXIS_LOG("%p|%s skipping velocity computation for small time delta %dms\n",
mAsyncPanZoomController, Name(), (aTimestampMs - mVelocitySampleTimeMs));
mPos = aPos;
return;
}
- float newVelocity = mAxisLocked ? 0.0f : (float)(mVelocitySamplePos - aPos + aAdditionalDelta) / (float)(aTimestampMs - mVelocitySampleTimeMs);
+ float newVelocity = mAxisLocked ? 0.0f : (float)(mVelocitySamplePos - aPos) / (float)(aTimestampMs - mVelocitySampleTimeMs);
newVelocity = ApplyFlingCurveToVelocity(newVelocity);
AXIS_LOG("%p|%s updating velocity to %f with touch\n",
mAsyncPanZoomController, Name(), newVelocity);
mVelocity = newVelocity;
mPos = aPos;
mVelocitySampleTimeMs = aTimestampMs;
--- a/gfx/layers/apz/src/Axis.h
+++ b/gfx/layers/apz/src/Axis.h
@@ -41,21 +41,21 @@ class AsyncPanZoomController;
*/
class Axis {
public:
explicit Axis(AsyncPanZoomController* aAsyncPanZoomController);
/**
* Notify this Axis that a new touch has been received, including a timestamp
* for when the touch was received. This triggers a recalculation of velocity.
- * This can also used for pan gesture events. For those events, the "touch"
- * location is stationary and the scroll displacement is passed in as
- * aAdditionalDelta.
+ * This can also used for pan gesture events. For those events, |aPos| is
+ * an invented position corresponding to the mouse position plus any
+ * accumulated displacements over the course of the pan gesture.
*/
- void UpdateWithTouchAtDevicePoint(ParentLayerCoord aPos, ParentLayerCoord aAdditionalDelta, uint32_t aTimestampMs);
+ void UpdateWithTouchAtDevicePoint(ParentLayerCoord aPos, uint32_t aTimestampMs);
protected:
float ApplyFlingCurveToVelocity(float aVelocity) const;
void AddVelocityToQueue(uint32_t aTimestampMs, float aVelocity);
public:
void HandleTouchVelocity(uint32_t aTimestampMs, float aSpeed);
@@ -246,16 +246,23 @@ public:
virtual ParentLayerCoord GetRectOffset(const ParentLayerRect& aRect) const = 0;
virtual CSSToParentLayerScale GetScaleForAxis(const CSSToParentLayerScale2D& aScale) const = 0;
virtual ScreenPoint MakePoint(ScreenCoord aCoord) const = 0;
virtual const char* Name() const = 0;
protected:
+ // A position along the axis, used during input event processing to
+ // track velocities (and for touch gestures, to track the length of
+ // the gesture). For touch events, this represents the position of
+ // the finger (or in the case of two-finger scrolling, the midpoint
+ // of the two fingers). For pan gesture events, this represents an
+ // invented position corresponding to the mouse position at the start
+ // of the pan, plus deltas representing the displacement of the pan.
ParentLayerCoord mPos;
// mVelocitySampleTimeMs and mVelocitySamplePos are the time and position
// used in the last velocity sampling. They get updated when a new sample is
// taken (which may not happen on every input event, if the time delta is too
// small).
uint32_t mVelocitySampleTimeMs;
ParentLayerCoord mVelocitySamplePos;