mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1063224 - Make some more things strongly typed in APZ code. r=kats
--HG-- extra : source : 57467bc253cd033260d086d52fe65069cffbe720
This commit is contained in:
parent
f9d0811336
commit
469a8cdd21
@ -1544,7 +1544,7 @@ nsEventStatus AsyncPanZoomController::OnPan(const PanGestureInput& aEvent, bool
|
||||
mX.UpdateWithTouchAtDevicePoint(aEvent.mPanStartPoint.x, aEvent.mTime);
|
||||
mY.UpdateWithTouchAtDevicePoint(aEvent.mPanStartPoint.y, aEvent.mTime);
|
||||
|
||||
HandlePanningUpdate(aEvent.mPanDisplacement.x, aEvent.mPanDisplacement.y);
|
||||
HandlePanningUpdate(aEvent.mPanDisplacement);
|
||||
|
||||
// TODO: Handle pan events sent without pan begin / pan end events properly.
|
||||
if (mPanGestureState) {
|
||||
@ -1772,16 +1772,16 @@ void AsyncPanZoomController::HandlePanning(double aAngle) {
|
||||
}
|
||||
}
|
||||
|
||||
void AsyncPanZoomController::HandlePanningUpdate(float aDX, float aDY) {
|
||||
void AsyncPanZoomController::HandlePanningUpdate(const ScreenPoint& aDelta) {
|
||||
// If we're axis-locked, check if the user is trying to break the lock
|
||||
if (GetAxisLockMode() == STICKY && !mPanDirRestricted) {
|
||||
|
||||
double angle = atan2(aDY, aDX); // range [-pi, pi]
|
||||
double angle = atan2(aDelta.y, aDelta.x); // range [-pi, pi]
|
||||
angle = fabs(angle); // range [0, pi]
|
||||
|
||||
float breakThreshold = gfxPrefs::APZAxisBreakoutThreshold() * APZCTreeManager::GetDPI();
|
||||
|
||||
if (fabs(aDX) > breakThreshold || fabs(aDY) > breakThreshold) {
|
||||
if (fabs(aDelta.x) > breakThreshold || fabs(aDelta.y) > breakThreshold) {
|
||||
if (mState == PANNING_LOCKED_X || mState == CROSS_SLIDING_X) {
|
||||
if (!IsCloseToHorizontal(angle, gfxPrefs::APZAxisBreakoutAngle())) {
|
||||
mY.SetAxisLocked(false);
|
||||
@ -2026,9 +2026,9 @@ void AsyncPanZoomController::TrackTouch(const MultiTouchInput& aEvent) {
|
||||
ScreenPoint prevTouchPoint(mX.GetPos(), mY.GetPos());
|
||||
ScreenPoint touchPoint = GetFirstTouchScreenPoint(aEvent);
|
||||
|
||||
float dx = mX.PanDistance(touchPoint.x);
|
||||
float dy = mY.PanDistance(touchPoint.y);
|
||||
HandlePanningUpdate(dx, dy);
|
||||
ScreenPoint delta(mX.PanDistance(touchPoint.x),
|
||||
mY.PanDistance(touchPoint.y));
|
||||
HandlePanningUpdate(delta);
|
||||
|
||||
UpdateWithTouchAtDevicePoint(aEvent);
|
||||
|
||||
|
@ -490,7 +490,7 @@ protected:
|
||||
/**
|
||||
* Update the panning state and axis locks.
|
||||
*/
|
||||
void HandlePanningUpdate(float aDX, float aDY);
|
||||
void HandlePanningUpdate(const ScreenPoint& aDelta);
|
||||
|
||||
/**
|
||||
* Sets up anything needed for panning. This takes us out of the "TOUCHING"
|
||||
|
@ -207,12 +207,12 @@ void Axis::ClearOverscroll() {
|
||||
mOverscroll = 0;
|
||||
}
|
||||
|
||||
float Axis::PanDistance() const {
|
||||
return fabsf((mPos - mStartPos).value);
|
||||
ScreenCoord Axis::PanDistance() const {
|
||||
return fabs(mPos - mStartPos);
|
||||
}
|
||||
|
||||
float Axis::PanDistance(ScreenCoord aPos) const {
|
||||
return fabsf((aPos - mStartPos).value);
|
||||
ScreenCoord Axis::PanDistance(ScreenCoord aPos) const {
|
||||
return fabs(aPos - mStartPos);
|
||||
}
|
||||
|
||||
void Axis::EndTouch(uint32_t aTimestampMs) {
|
||||
|
@ -123,13 +123,13 @@ public:
|
||||
* startTouch() and the current touch from the last
|
||||
* updateWithTouchAtDevicePoint().
|
||||
*/
|
||||
float PanDistance() const;
|
||||
ScreenCoord PanDistance() const;
|
||||
|
||||
/**
|
||||
* Gets the distance between the starting position of the touch supplied in
|
||||
* startTouch() and the supplied position.
|
||||
*/
|
||||
float PanDistance(ScreenCoord aPos) const;
|
||||
ScreenCoord PanDistance(ScreenCoord aPos) const;
|
||||
|
||||
/**
|
||||
* Applies friction during a fling, or cancels the fling if the velocity is
|
||||
|
Loading…
Reference in New Issue
Block a user