Exemplo n.º 1
0
nsEventStatus GestureEventListener::HandleInputTouchMultiStart()
{
    nsEventStatus rv = nsEventStatus_eIgnore;

    switch (mState) {
    case GESTURE_NONE:
        SetState(GESTURE_MULTI_TOUCH_DOWN);
        break;
    case GESTURE_FIRST_SINGLE_TOUCH_DOWN:
        CancelLongTapTimeoutTask();
        CancelMaxTapTimeoutTask();
        SetState(GESTURE_MULTI_TOUCH_DOWN);
        // Prevent APZC::OnTouchStart() from handling MULTITOUCH_START event
        rv = nsEventStatus_eConsumeNoDefault;
        break;
    case GESTURE_FIRST_SINGLE_TOUCH_MAX_TAP_DOWN:
        CancelLongTapTimeoutTask();
        SetState(GESTURE_MULTI_TOUCH_DOWN);
        // Prevent APZC::OnTouchStart() from handling MULTITOUCH_START event
        rv = nsEventStatus_eConsumeNoDefault;
        break;
    case GESTURE_FIRST_SINGLE_TOUCH_UP:
        // Cancel wait for double tap
        CancelMaxTapTimeoutTask();
        SetState(GESTURE_MULTI_TOUCH_DOWN);
        TriggerSingleTapConfirmedEvent();
        // Prevent APZC::OnTouchStart() from handling MULTITOUCH_START event
        rv = nsEventStatus_eConsumeNoDefault;
        break;
    case GESTURE_SECOND_SINGLE_TOUCH_DOWN:
        // Cancel wait for single tap
        CancelMaxTapTimeoutTask();
        SetState(GESTURE_MULTI_TOUCH_DOWN);
        TriggerSingleTapConfirmedEvent();
        // Prevent APZC::OnTouchStart() from handling MULTITOUCH_START event
        rv = nsEventStatus_eConsumeNoDefault;
        break;
    case GESTURE_LONG_TOUCH_DOWN:
        SetState(GESTURE_MULTI_TOUCH_DOWN);
        break;
    case GESTURE_MULTI_TOUCH_DOWN:
    case GESTURE_PINCH:
        // Prevent APZC::OnTouchStart() from handling MULTITOUCH_START event
        rv = nsEventStatus_eConsumeNoDefault;
        break;
    default:
        NS_WARNING("Unhandled state upon multitouch start");
        SetState(GESTURE_NONE);
        break;
    }

    return rv;
}
Exemplo n.º 2
0
void GestureEventListener::HandleInputTimeoutMaxTap()
{
  mMaxTapTimeoutTask = nullptr;

  if (mState == GESTURE_FIRST_SINGLE_TOUCH_DOWN) {
    SetState(GESTURE_FIRST_SINGLE_TOUCH_MAX_TAP_DOWN);
  } else if (mState == GESTURE_FIRST_SINGLE_TOUCH_UP ||
             mState == GESTURE_SECOND_SINGLE_TOUCH_DOWN) {
    SetState(GESTURE_NONE);
    TriggerSingleTapConfirmedEvent();
  } else {
    NS_WARNING("Unhandled state upon MAX_TAP timeout");
    SetState(GESTURE_NONE);
  }
}
Exemplo n.º 3
0
void GestureEventListener::HandleInputTimeoutMaxTap(bool aDuringFastFling)
{
  GEL_LOG("Running max-tap timeout task in state %d\n", mState);

  mMaxTapTimeoutTask = nullptr;

  if (mState == GESTURE_FIRST_SINGLE_TOUCH_DOWN) {
    SetState(GESTURE_FIRST_SINGLE_TOUCH_MAX_TAP_DOWN);
  } else if (mState == GESTURE_FIRST_SINGLE_TOUCH_UP ||
             mState == GESTURE_SECOND_SINGLE_TOUCH_DOWN) {
    SetState(GESTURE_NONE);
    if (!aDuringFastFling) {
      TriggerSingleTapConfirmedEvent();
    }
  } else {
    NS_WARNING("Unhandled state upon MAX_TAP timeout");
    SetState(GESTURE_NONE);
  }
}
Exemplo n.º 4
0
nsEventStatus GestureEventListener::HandleInputTouchEnd()
{
    // We intentionally do not pass apzc return statuses up since
    // it may cause apzc stay in the touching state even after
    // gestures are completed (please see Bug 1013378 for reference).

    nsEventStatus rv = nsEventStatus_eIgnore;

    switch (mState) {
    case GESTURE_NONE:
        // GEL doesn't have a dedicated state for PANNING handled in APZC thus ignore.
        break;

    case GESTURE_FIRST_SINGLE_TOUCH_DOWN: {
        CancelLongTapTimeoutTask();
        CancelMaxTapTimeoutTask();
        nsEventStatus tapupStatus = mAsyncPanZoomController->HandleGestureEvent(
                                        CreateTapEvent(mLastTouchInput, TapGestureInput::TAPGESTURE_UP));
        if (tapupStatus == nsEventStatus_eIgnore) {
            SetState(GESTURE_FIRST_SINGLE_TOUCH_UP);
            CreateMaxTapTimeoutTask();
        } else {
            // We sent the tapup into content without waiting for a double tap
            SetState(GESTURE_NONE);
        }
        break;
    }

    case GESTURE_SECOND_SINGLE_TOUCH_DOWN: {
        CancelMaxTapTimeoutTask();
        SetState(GESTURE_NONE);
        mAsyncPanZoomController->HandleGestureEvent(
            CreateTapEvent(mLastTouchInput, TapGestureInput::TAPGESTURE_DOUBLE));
        break;
    }

    case GESTURE_FIRST_SINGLE_TOUCH_MAX_TAP_DOWN:
        CancelLongTapTimeoutTask();
        SetState(GESTURE_NONE);
        TriggerSingleTapConfirmedEvent();
        break;

    case GESTURE_LONG_TOUCH_DOWN: {
        SetState(GESTURE_NONE);
        mAsyncPanZoomController->HandleGestureEvent(
            CreateTapEvent(mLastTouchInput, TapGestureInput::TAPGESTURE_LONG_UP));
        break;
    }

    case GESTURE_MULTI_TOUCH_DOWN:
        if (mTouches.Length() < 2) {
            SetState(GESTURE_NONE);
        }
        break;

    case GESTURE_PINCH:
        if (mTouches.Length() < 2) {
            SetState(GESTURE_NONE);
            PinchGestureInput pinchEvent(PinchGestureInput::PINCHGESTURE_END,
                                         mLastTouchInput.mTime,
                                         mLastTouchInput.mTimeStamp,
                                         ScreenPoint(),
                                         1.0f,
                                         1.0f,
                                         mLastTouchInput.modifiers);
            mAsyncPanZoomController->HandleGestureEvent(pinchEvent);
        }

        rv = nsEventStatus_eConsumeNoDefault;

        break;

    default:
        NS_WARNING("Unhandled state upon touch end");
        SetState(GESTURE_NONE);
        break;
    }

    return rv;
}
Exemplo n.º 5
0
nsEventStatus GestureEventListener::HandleInputTouchEnd()
{
  nsEventStatus rv = nsEventStatus_eIgnore;

  switch (mState) {
  case GESTURE_NONE:
    // GEL doesn't have a dedicated state for PANNING handled in APZC thus ignore.
    break;

  case GESTURE_FIRST_SINGLE_TOUCH_DOWN: {
    CancelLongTapTimeoutTask();
    CancelMaxTapTimeoutTask();
    TapGestureInput tapEvent(TapGestureInput::TAPGESTURE_UP,
                             mLastTouchInput.mTime,
                             mLastTouchInput.mTouches[0].mScreenPoint,
                             mLastTouchInput.modifiers);
    nsEventStatus tapupStatus = mAsyncPanZoomController->HandleGestureEvent(tapEvent);
    if (tapupStatus == nsEventStatus_eIgnore) {
      SetState(GESTURE_FIRST_SINGLE_TOUCH_UP);
      CreateMaxTapTimeoutTask();
    } else {
      // We sent the tapup into content without waiting for a double tap
      SetState(GESTURE_NONE);
    }
    break;
  }

  case GESTURE_SECOND_SINGLE_TOUCH_DOWN: {
    CancelMaxTapTimeoutTask();
    SetState(GESTURE_NONE);
    TapGestureInput tapEvent(TapGestureInput::TAPGESTURE_DOUBLE,
                             mLastTouchInput.mTime,
                             mLastTouchInput.mTouches[0].mScreenPoint,
                             mLastTouchInput.modifiers);
    mAsyncPanZoomController->HandleGestureEvent(tapEvent);
    break;
  }

  case GESTURE_FIRST_SINGLE_TOUCH_MAX_TAP_DOWN:
    CancelLongTapTimeoutTask();
    SetState(GESTURE_NONE);
    TriggerSingleTapConfirmedEvent();
    break;

  case GESTURE_LONG_TOUCH_DOWN: {
    SetState(GESTURE_NONE);
    TapGestureInput tapEvent(TapGestureInput::TAPGESTURE_LONG_UP,
                             mLastTouchInput.mTime,
                             mLastTouchInput.mTouches[0].mScreenPoint,
                             mLastTouchInput.modifiers);
    mAsyncPanZoomController->HandleGestureEvent(tapEvent);
    break;
  }

  case GESTURE_MULTI_TOUCH_DOWN:
    if (mTouches.Length() < 2) {
      SetState(GESTURE_NONE);
    }
    break;

  case GESTURE_PINCH:
    if (mTouches.Length() < 2) {
      SetState(GESTURE_NONE);
      PinchGestureInput pinchEvent(PinchGestureInput::PINCHGESTURE_END,
                                   mLastTouchInput.mTime,
                                   ScreenPoint(),
                                   1.0f,
                                   1.0f,
                                   mLastTouchInput.modifiers);
      mAsyncPanZoomController->HandleGestureEvent(pinchEvent);
    }
    rv = nsEventStatus_eConsumeNoDefault;
    break;

  default:
    NS_WARNING("Unhandled state upon touch end");
    SetState(GESTURE_NONE);
    break;
  }

  return rv;
}