Bug 1011389 - Don't fire a long-tap-up if the user moves after long-tap. r=dmitry.rojkov

This commit is contained in:
Kartikaya Gupta 2014-05-16 11:26:00 -04:00
parent 3ee3478056
commit 355c624b5a
4 changed files with 22 additions and 6 deletions

View File

@ -66,7 +66,9 @@ public:
/**
* Requests handling of releasing a long tap. |aPoint| is in CSS pixels,
* relative to the current scroll offset. HandleLongTapUp will always be
* preceeded by HandleLongTap
* preceeded by HandleLongTap. However not all calls to HandleLongTap will
* be followed by a HandleLongTapUp (for example, if the user drags
* around between the long-tap and lifting their finger).
*/
virtual void HandleLongTapUp(const CSSPoint& aPoint,
int32_t aModifiers,

View File

@ -180,22 +180,34 @@ nsEventStatus GestureEventListener::HandleInputTouchMultiStart()
return rv;
}
bool GestureEventListener::MoveDistanceIsLarge()
{
ScreenIntPoint delta = mLastTouchInput.mTouches[0].mScreenPoint - mTouchStartPosition;
return (NS_hypot(delta.x, delta.y) > AsyncPanZoomController::GetTouchStartTolerance());
}
nsEventStatus GestureEventListener::HandleInputTouchMove()
{
nsEventStatus rv = nsEventStatus_eIgnore;
switch (mState) {
case GESTURE_NONE:
case GESTURE_LONG_TOUCH_DOWN:
// Ignore this input signal as the corresponding events get handled by APZC
break;
case GESTURE_LONG_TOUCH_DOWN:
if (MoveDistanceIsLarge()) {
// So that we don't fire a long-tap-up if the user moves around after a
// long-tap
SetState(GESTURE_NONE);
}
break;
case GESTURE_FIRST_SINGLE_TOUCH_DOWN:
case GESTURE_FIRST_SINGLE_TOUCH_MAX_TAP_DOWN:
case GESTURE_SECOND_SINGLE_TOUCH_DOWN: {
// If we move too much, bail out of the tap.
ScreenIntPoint delta = mLastTouchInput.mTouches[0].mScreenPoint - mTouchStartPosition;
if (NS_hypot(delta.x, delta.y) > AsyncPanZoomController::GetTouchStartTolerance()) {
if (MoveDistanceIsLarge()) {
CancelLongTapTimeoutTask();
CancelMaxTapTimeoutTask();
SetState(GESTURE_NONE);

View File

@ -126,6 +126,8 @@ private:
void TriggerSingleTapConfirmedEvent();
bool MoveDistanceIsLarge();
/**
* Do actual state transition and reset substates.
*/

View File

@ -950,7 +950,7 @@ DoLongPressPreventDefaultTest(bool aShouldUseTouchAction, uint32_t aBehavior) {
apzc->NotifyLayersUpdated(TestFrameMetrics(), true);
apzc->UpdateZoomConstraints(ZoomConstraints(false, false, CSSToScreenScale(1.0), CSSToScreenScale(1.0)));
apzc->SetTouchActionEnabled(aShouldUseTouchAction);
apzc->SetTouchActionEnabled(aShouldUseTouchAction);
EXPECT_CALL(*mcc, SendAsyncScrollDOMEvent(_,_,_)).Times(0);
EXPECT_CALL(*mcc, RequestContentRepaint(_)).Times(0);
@ -999,7 +999,7 @@ DoLongPressPreventDefaultTest(bool aShouldUseTouchAction, uint32_t aBehavior) {
status = apzc->ReceiveInputEvent(mti);
EXPECT_EQ(nsEventStatus_eIgnore, status);
EXPECT_CALL(*mcc, HandleLongTapUp(CSSPoint(touchX, touchEndY), 0, apzc->GetGuid())).Times(1);
EXPECT_CALL(*mcc, HandleLongTapUp(CSSPoint(touchX, touchEndY), 0, apzc->GetGuid())).Times(0);
status = ApzcUp(apzc, touchX, touchEndY, time);
EXPECT_EQ(nsEventStatus_eIgnore, status);