Пример #1
0
nsEventStatus AsyncPanZoomController::HandleInputEvent(const InputEvent& event) {
  nsEventStatus rv = nsEventStatus_eIgnore;
  if (!mIsCompositing)
    return rv;

  switch (event.mMessage) {
  case MULTITOUCH_START_POINTER:
  case MULTITOUCH_START: rv = OnTouchStart((const MultiTouchEvent&)event); break;
  case MULTITOUCH_MOVE: rv = OnTouchMove((const MultiTouchEvent&)event); break;
  case MULTITOUCH_END: rv = OnTouchEnd((const MultiTouchEvent&)event); break;
  case MULTITOUCH_CANCEL: rv = OnTouchCancel((const MultiTouchEvent&)event); break;
  case PINCH_START: rv = OnScaleBegin((const PinchEvent&)event); break;
  case PINCH_SCALE: rv = OnScale((const PinchEvent&)event); break;
  case PINCH_END: rv = OnScaleEnd((const PinchEvent&)event); break;
  case TAP_LONG: rv = OnLongPress((const TapEvent&)event); break;
  case TAP_UP: rv = OnSingleTapUp((const TapEvent&)event); break;
  case TAP_CONFIRMED: rv = OnSingleTapConfirmed((const TapEvent&)event); break;
  case TAP_DOUBLE: rv = OnDoubleTap((const TapEvent&)event); break;
  case TAP_CANCEL: rv = OnCancelTap((const TapEvent&)event); break;
  default: break;
  }

  mLastEventTime = event.mTime;
  return rv;
}
nsEventStatus AsyncPanZoomController::HandleInputEvent(const InputData& aEvent) {
  nsEventStatus rv = nsEventStatus_eIgnore;

  if (mGestureEventListener) {
    nsEventStatus rv = mGestureEventListener->HandleInputEvent(aEvent);
    if (rv == nsEventStatus_eConsumeNoDefault)
      return rv;
  }

  switch (aEvent.mInputType) {
  case MULTITOUCH_INPUT: {
    const MultiTouchInput& multiTouchInput = aEvent.AsMultiTouchInput();
    switch (multiTouchInput.mType) {
      case MultiTouchInput::MULTITOUCH_START: rv = OnTouchStart(multiTouchInput); break;
      case MultiTouchInput::MULTITOUCH_MOVE: rv = OnTouchMove(multiTouchInput); break;
      case MultiTouchInput::MULTITOUCH_END: rv = OnTouchEnd(multiTouchInput); break;
      case MultiTouchInput::MULTITOUCH_CANCEL: rv = OnTouchCancel(multiTouchInput); break;
      default: NS_WARNING("Unhandled multitouch"); break;
    }
    break;
  }
  case PINCHGESTURE_INPUT: {
    const PinchGestureInput& pinchGestureInput = aEvent.AsPinchGestureInput();
    switch (pinchGestureInput.mType) {
      case PinchGestureInput::PINCHGESTURE_START: rv = OnScaleBegin(pinchGestureInput); break;
      case PinchGestureInput::PINCHGESTURE_SCALE: rv = OnScale(pinchGestureInput); break;
      case PinchGestureInput::PINCHGESTURE_END: rv = OnScaleEnd(pinchGestureInput); break;
      default: NS_WARNING("Unhandled pinch gesture"); break;
    }
    break;
  }
  case TAPGESTURE_INPUT: {
    const TapGestureInput& tapGestureInput = aEvent.AsTapGestureInput();
    switch (tapGestureInput.mType) {
      case TapGestureInput::TAPGESTURE_LONG: rv = OnLongPress(tapGestureInput); break;
      case TapGestureInput::TAPGESTURE_UP: rv = OnSingleTapUp(tapGestureInput); break;
      case TapGestureInput::TAPGESTURE_CONFIRMED: rv = OnSingleTapConfirmed(tapGestureInput); break;
      case TapGestureInput::TAPGESTURE_DOUBLE: rv = OnDoubleTap(tapGestureInput); break;
      case TapGestureInput::TAPGESTURE_CANCEL: rv = OnCancelTap(tapGestureInput); break;
      default: NS_WARNING("Unhandled tap gesture"); break;
    }
    break;
  }
  default: NS_WARNING("Unhandled input event"); break;
  }

  mLastEventTime = aEvent.mTime;
  return rv;
}