зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1063224 - Use global screen coordinates when working with quantities in inches. r=kats
--HG-- extra : source : 065a1d3bc7f99562b2f41847d76b4c6196825b7b
This commit is contained in:
Родитель
44c80fc4f3
Коммит
d8ba2553d7
|
@ -1542,7 +1542,9 @@ nsEventStatus AsyncPanZoomController::OnPan(const PanGestureInput& aEvent, bool
|
|||
mX.UpdateWithTouchAtDevicePoint(aEvent.mPanStartPoint.x, aEvent.mTime);
|
||||
mY.UpdateWithTouchAtDevicePoint(aEvent.mPanStartPoint.y, aEvent.mTime);
|
||||
|
||||
HandlePanningUpdate(aEvent.mPanDisplacement);
|
||||
ScreenPoint panDisplacement = aEvent.mPanDisplacement;
|
||||
ToGlobalScreenCoordinates(&panDisplacement, aEvent.mPanStartPoint);
|
||||
HandlePanningUpdate(panDisplacement);
|
||||
|
||||
// TODO: Handle pan events sent without pan begin / pan end events properly.
|
||||
if (mPanGestureState) {
|
||||
|
@ -1722,8 +1724,15 @@ void AsyncPanZoomController::ToLocalScreenCoordinates(ScreenPoint* aVector,
|
|||
}
|
||||
|
||||
float AsyncPanZoomController::PanDistance() const {
|
||||
ReentrantMonitorAutoEnter lock(mMonitor);
|
||||
return NS_hypot(mX.PanDistance(), mY.PanDistance());
|
||||
ScreenPoint panVector;
|
||||
ScreenPoint panStart;
|
||||
{
|
||||
ReentrantMonitorAutoEnter lock(mMonitor);
|
||||
panVector = ScreenPoint(mX.PanDistance(), mY.PanDistance());
|
||||
panStart = PanStart();
|
||||
}
|
||||
ToGlobalScreenCoordinates(&panVector, panStart);
|
||||
return NS_hypot(panVector.x, panVector.y);
|
||||
}
|
||||
|
||||
ScreenPoint AsyncPanZoomController::PanStart() const {
|
||||
|
@ -2059,6 +2068,8 @@ void AsyncPanZoomController::TrackTouch(const MultiTouchInput& aEvent) {
|
|||
|
||||
ScreenPoint delta(mX.PanDistance(touchPoint.x),
|
||||
mY.PanDistance(touchPoint.y));
|
||||
const ScreenPoint panStart = PanStart();
|
||||
ToGlobalScreenCoordinates(&delta, panStart);
|
||||
HandlePanningUpdate(delta);
|
||||
|
||||
UpdateWithTouchAtDevicePoint(aEvent);
|
||||
|
|
|
@ -88,6 +88,7 @@ public:
|
|||
* device DPI, before we start panning the screen. This is to prevent us from
|
||||
* accidentally processing taps as touch moves, and from very short/accidental
|
||||
* touches moving the screen.
|
||||
* Note: this distance is in global screen coordinates.
|
||||
*/
|
||||
static float GetTouchStartTolerance();
|
||||
|
||||
|
@ -484,7 +485,9 @@ protected:
|
|||
* Gets the displacement of the current touch since it began. That is, it is
|
||||
* the distance between the current position and the initial position of the
|
||||
* current touch (this only makes sense if a touch is currently happening and
|
||||
* OnTouchMove() is being invoked).
|
||||
* OnTouchMove() or the equivalent for pan gestures is being invoked).
|
||||
* Note: This function returns a distance in global screen coordinates,
|
||||
* not the local screen coordinates of this APZC.
|
||||
*/
|
||||
float PanDistance() const;
|
||||
|
||||
|
@ -521,6 +524,7 @@ protected:
|
|||
|
||||
/**
|
||||
* Update the panning state and axis locks.
|
||||
* Note: |aDelta| is expected to be in global screen coordinates.
|
||||
*/
|
||||
void HandlePanningUpdate(const ScreenPoint& aDelta);
|
||||
|
||||
|
|
|
@ -49,7 +49,9 @@ void Axis::UpdateWithTouchAtDevicePoint(ScreenCoord aPos, uint32_t aTimestampMs)
|
|||
|
||||
float newVelocity = mAxisLocked ? 0.0f : (float)(mPos - aPos) / (float)(aTimestampMs - mPosTimeMs);
|
||||
if (gfxPrefs::APZMaxVelocity() > 0.0f) {
|
||||
newVelocity = std::min(newVelocity, gfxPrefs::APZMaxVelocity() * APZCTreeManager::GetDPI());
|
||||
ScreenPoint maxVelocity = MakePoint(gfxPrefs::APZMaxVelocity() * APZCTreeManager::GetDPI());
|
||||
mAsyncPanZoomController->ToLocalScreenCoordinates(&maxVelocity, mAsyncPanZoomController->PanStart());
|
||||
newVelocity = std::min(newVelocity, maxVelocity.Length());
|
||||
}
|
||||
|
||||
mVelocity = newVelocity;
|
||||
|
|
|
@ -197,8 +197,10 @@ nsEventStatus GestureEventListener::HandleInputTouchMultiStart()
|
|||
|
||||
bool GestureEventListener::MoveDistanceIsLarge()
|
||||
{
|
||||
ScreenIntPoint delta = mLastTouchInput.mTouches[0].mScreenPoint - mTouchStartPosition;
|
||||
return (NS_hypot(delta.x, delta.y) > AsyncPanZoomController::GetTouchStartTolerance());
|
||||
const ScreenPoint start = mLastTouchInput.mTouches[0].mScreenPoint;
|
||||
ScreenPoint delta = start - mTouchStartPosition;
|
||||
mAsyncPanZoomController->ToGlobalScreenCoordinates(&delta, start);
|
||||
return (delta.Length() > AsyncPanZoomController::GetTouchStartTolerance());
|
||||
}
|
||||
|
||||
nsEventStatus GestureEventListener::HandleInputTouchMove()
|
||||
|
|
Загрузка…
Ссылка в новой задаче