Bug 1355944 - Back out cset 456dbb5c2b93 (bug 1180799) for causing unexpected behaviour. r=backout

MozReview-Commit-ID: FW1DDt7ax9U
This commit is contained in:
Kartikaya Gupta 2017-04-13 08:24:25 -04:00
Родитель 3a1b430f17
Коммит bdeb25f52a
3 изменённых файлов: 64 добавлений и 89 удалений

Просмотреть файл

@ -1150,19 +1150,17 @@ nsEventStatus AsyncPanZoomController::OnTouchMove(const MultiTouchInput& aEvent)
return nsEventStatus_eIgnore;
}
ParentLayerPoint touchPoint = GetFirstTouchPoint(aEvent);
MOZ_ASSERT(GetCurrentTouchBlock());
if (gfxPrefs::TouchActionEnabled() && GetCurrentTouchBlock()->TouchActionAllowsPanningXY()) {
// User tries to trigger a touch behavior. If allowed touch behavior is vertical pan
// + horizontal pan (touch-action value is equal to AUTO) we can return ConsumeNoDefault
// status immediately to trigger cancel event further. It should happen independent of
// the parent type (whether it is scrolling or not).
StartPanning(touchPoint);
StartPanning(aEvent);
return nsEventStatus_eConsumeNoDefault;
}
return StartPanning(touchPoint);
return StartPanning(aEvent);
}
case PANNING:
@ -1253,9 +1251,43 @@ nsEventStatus AsyncPanZoomController::OnTouchEnd(const MultiTouchInput& aEvent)
case PAN_MOMENTUM:
{
MOZ_ASSERT(GetCurrentTouchBlock());
GetCurrentTouchBlock()->GetOverscrollHandoffChain()->FlushRepaints();
mX.EndTouch(aEvent.mTime);
mY.EndTouch(aEvent.mTime);
return HandleEndOfPan();
ParentLayerPoint flingVelocity = GetVelocityVector();
// Clear our velocities; if DispatchFling() gives the fling to us,
// the fling velocity gets *added* to our existing velocity in
// AcceptFling().
mX.SetVelocity(0);
mY.SetVelocity(0);
// Clear our state so that we don't stay in the PANNING state
// if DispatchFling() gives the fling to somone else. However,
// don't send the state change notification until we've determined
// what our final state is to avoid notification churn.
StateChangeNotificationBlocker blocker(this);
SetState(NOTHING);
APZC_LOG("%p starting a fling animation if %f >= %f\n", this,
flingVelocity.Length().value, gfxPrefs::APZFlingMinVelocityThreshold());
if (flingVelocity.Length() < gfxPrefs::APZFlingMinVelocityThreshold()) {
// Relieve overscroll now if needed, since we will not transition to a fling
// animation and then an overscroll animation, and relieve it then.
GetCurrentTouchBlock()->GetOverscrollHandoffChain()->SnapBackOverscrolledApzc(this);
return nsEventStatus_eConsumeNoDefault;
}
// Make a local copy of the tree manager pointer and check that it's not
// null before calling DispatchFling(). This is necessary because Destroy(),
// which nulls out mTreeManager, could be called concurrently.
if (APZCTreeManager* treeManagerLocal = GetApzcTreeManager()) {
FlingHandoffState handoffState{flingVelocity,
GetCurrentTouchBlock()->GetOverscrollHandoffChain(),
false /* not handoff */,
GetCurrentTouchBlock()->GetScrolledApzc()};
treeManagerLocal->DispatchFling(this, handoffState);
}
return nsEventStatus_eConsumeNoDefault;
}
case PINCHING:
SetState(NOTHING);
@ -1286,8 +1318,6 @@ nsEventStatus AsyncPanZoomController::OnScaleBegin(const PinchGestureInput& aEve
APZC_LOG("%p got a scale-begin in state %d\n", this, mState);
mPinchPaintTimerSet = false;
mX.StartTouch(aEvent.mLocalFocusPoint.x, aEvent.mTime);
mY.StartTouch(aEvent.mLocalFocusPoint.y, aEvent.mTime);
// Note that there may not be a touch block at this point, if we received the
// PinchGestureEvent directly from widget code without any touch events.
if (HasReadyTouchBlock() && !GetCurrentTouchBlock()->TouchActionAllowsPinchZoom()) {
@ -1312,8 +1342,6 @@ nsEventStatus AsyncPanZoomController::OnScaleBegin(const PinchGestureInput& aEve
nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) {
APZC_LOG("%p got a scale in state %d\n", this, mState);
mX.UpdateWithTouchAtDevicePoint(aEvent.mLocalFocusPoint.x, 0, aEvent.mTime);
mY.UpdateWithTouchAtDevicePoint(aEvent.mLocalFocusPoint.y, 0, aEvent.mTime);
if (HasReadyTouchBlock() && !GetCurrentTouchBlock()->TouchActionAllowsPinchZoom()) {
return nsEventStatus_eIgnore;
@ -1449,6 +1477,8 @@ nsEventStatus AsyncPanZoomController::OnScaleEnd(const PinchGestureInput& aEvent
}
}
SetState(NOTHING);
{
ReentrantMonitorAutoEnter lock(mMonitor);
ScheduleComposite();
@ -1458,86 +1488,32 @@ nsEventStatus AsyncPanZoomController::OnScaleEnd(const PinchGestureInput& aEvent
// Non-negative focus point would indicate that one finger is still down
if (aEvent.mLocalFocusPoint.x != -1 && aEvent.mLocalFocusPoint.y != -1) {
if (mZoomConstraints.mAllowZoom) {
mPanDirRestricted = false;
SetState(TOUCHING);
} else {
StartPanning(aEvent.mLocalFocusPoint);
}
mPanDirRestricted = false;
mX.StartTouch(aEvent.mLocalFocusPoint.x, aEvent.mTime);
mY.StartTouch(aEvent.mLocalFocusPoint.y, aEvent.mTime);
SetState(TOUCHING);
} else {
// Otherwise, handle the fingers being lifted.
mX.EndTouch(aEvent.mTime);
mY.EndTouch(aEvent.mTime);
if (mZoomConstraints.mAllowZoom) {
ReentrantMonitorAutoEnter lock(mMonitor);
ReentrantMonitorAutoEnter lock(mMonitor);
// We can get into a situation where we are overscrolled at the end of a
// pinch if we go into overscroll with a two-finger pan, and then turn
// that into a pinch by increasing the span sufficiently. In such a case,
// there is no snap-back animation to get us out of overscroll, so we need
// to get out of it somehow.
// Moreover, in cases of scroll handoff, the overscroll can be on an APZC
// further up in the handoff chain rather than on the current APZC, so
// we need to clear overscroll along the entire handoff chain.
if (HasReadyTouchBlock()) {
GetCurrentTouchBlock()->GetOverscrollHandoffChain()->ClearOverscroll();
} else {
ClearOverscroll();
}
// Along with clearing the overscroll, we also want to snap to the nearest
// snap point as appropriate.
ScrollSnap();
// We can get into a situation where we are overscrolled at the end of a
// pinch if we go into overscroll with a two-finger pan, and then turn
// that into a pinch by increasing the span sufficiently. In such a case,
// there is no snap-back animation to get us out of overscroll, so we need
// to get out of it somehow.
// Moreover, in cases of scroll handoff, the overscroll can be on an APZC
// further up in the handoff chain rather than on the current APZC, so
// we need to clear overscroll along the entire handoff chain.
if (HasReadyTouchBlock()) {
GetCurrentTouchBlock()->GetOverscrollHandoffChain()->ClearOverscroll();
} else {
// when zoom is not allowed
if (mState == PINCHING) {
// still pinching
if (HasReadyTouchBlock()) {
return HandleEndOfPan();
}
}
ClearOverscroll();
}
}
return nsEventStatus_eConsumeNoDefault;
}
nsEventStatus AsyncPanZoomController::HandleEndOfPan()
{
MOZ_ASSERT(GetCurrentTouchBlock());
GetCurrentTouchBlock()->GetOverscrollHandoffChain()->FlushRepaints();
ParentLayerPoint flingVelocity = GetVelocityVector();
// Clear our velocities; if DispatchFling() gives the fling to us,
// the fling velocity gets *added* to our existing velocity in
// AcceptFling().
mX.SetVelocity(0);
mY.SetVelocity(0);
// Clear our state so that we don't stay in the PANNING state
// if DispatchFling() gives the fling to somone else. However,
// don't send the state change notification until we've determined
// what our final state is to avoid notification churn.
StateChangeNotificationBlocker blocker(this);
SetState(NOTHING);
APZC_LOG("%p starting a fling animation if %f >= %f\n", this,
flingVelocity.Length().value, gfxPrefs::APZFlingMinVelocityThreshold());
if (flingVelocity.Length() < gfxPrefs::APZFlingMinVelocityThreshold()) {
// Relieve overscroll now if needed, since we will not transition to a fling
// animation and then an overscroll animation, and relieve it then.
GetCurrentTouchBlock()->GetOverscrollHandoffChain()->SnapBackOverscrolledApzc(this);
return nsEventStatus_eConsumeNoDefault;
// Along with clearing the overscroll, we also want to snap to the nearest
// snap point as appropriate.
ScrollSnap();
}
// Make a local copy of the tree manager pointer and check that it's not
// null before calling DispatchFling(). This is necessary because Destroy(),
// which nulls out mTreeManager, could be called concurrently.
if (APZCTreeManager* treeManagerLocal = GetApzcTreeManager()) {
FlingHandoffState handoffState{flingVelocity,
GetCurrentTouchBlock()->GetOverscrollHandoffChain(),
false /* not handoff */,
GetCurrentTouchBlock()->GetScrolledApzc()};
treeManagerLocal->DispatchFling(this, handoffState);
}
return nsEventStatus_eConsumeNoDefault;
}
@ -2348,12 +2324,12 @@ void AsyncPanZoomController::HandlePanningUpdate(const ScreenPoint& aPanDistance
}
}
nsEventStatus
AsyncPanZoomController::StartPanning(const ParentLayerPoint& aStartPoint) {
nsEventStatus AsyncPanZoomController::StartPanning(const MultiTouchInput& aEvent) {
ReentrantMonitorAutoEnter lock(mMonitor);
float dx = mX.PanDistance(aStartPoint.x);
float dy = mY.PanDistance(aStartPoint.y);
ParentLayerPoint point = GetFirstTouchPoint(aEvent);
float dx = mX.PanDistance(point.x);
float dy = mY.PanDistance(point.y);
double angle = atan2(dy, dx); // range [-pi, pi]
angle = fabs(angle); // range [0, pi]

Просмотреть файл

@ -457,7 +457,6 @@ protected:
nsEventStatus OnPanEnd(const PanGestureInput& aEvent);
nsEventStatus OnPanMomentumStart(const PanGestureInput& aEvent);
nsEventStatus OnPanMomentumEnd(const PanGestureInput& aEvent);
nsEventStatus HandleEndOfPan();
/**
* Helper methods for handling scroll wheel events.
@ -577,7 +576,7 @@ protected:
* Sets up anything needed for panning. This takes us out of the "TOUCHING"
* state and starts actually panning us.
*/
nsEventStatus StartPanning(const ParentLayerPoint& aStartPoint);
nsEventStatus StartPanning(const MultiTouchInput& aStartPoint);
/**
* Wrapper for Axis::UpdateWithTouchAtDevicePoint(). Calls this function for

Просмотреть файл

@ -138,7 +138,7 @@ PinchWithPinchInput(const RefPtr<InputReceiver>& aTarget,
CreatePinchGestureInput(PinchGestureInput::PINCHGESTURE_END,
// note: negative values here tell APZC
// not to turn the pinch into a pan
ScreenIntPoint(-1, -1), 10.0 * aScale, 10.0 * aScale),
aFocus, -1.0, -1.0),
nullptr);
if (aOutEventStatuses) {
(*aOutEventStatuses)[2] = actualStatus;