WebGestureEventBuilder::WebGestureEventBuilder(const Widget* widget, const WebCore::RenderObject* renderObject, const GestureEvent& event)
{
    if (event.type() == eventNames().gesturetapEvent)
        type = GestureTap;
    else if (event.type() == eventNames().gesturetapdownEvent)
        type = GestureTapDown;
    else if (event.type() == eventNames().gesturescrollstartEvent)
        type = GestureScrollBegin;
    else if (event.type() == eventNames().gesturescrollendEvent)
        type = GestureScrollEnd;
    else if (event.type() == eventNames().gesturescrollupdateEvent) {
        type = GestureScrollUpdate;
        data.scrollUpdate.deltaX = event.deltaX();
        data.scrollUpdate.deltaY = event.deltaY();
    }

    timeStampSeconds = event.timeStamp() / millisPerSecond;
    modifiers = getWebInputModifiers(event);

    globalX = event.screenX();
    globalY = event.screenY();
    IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteLocation(), *renderObject);
    x = localPoint.x();
    y = localPoint.y();
}
WebGestureEventBuilder::WebGestureEventBuilder(const LayoutObject* layoutObject, const GestureEvent& event)
{
    if (event.type() == EventTypeNames::gestureshowpress) {
        type = GestureShowPress;
    } else if (event.type() == EventTypeNames::gesturelongpress) {
        type = GestureLongPress;
    } else if (event.type() == EventTypeNames::gesturetapdown) {
        type = GestureTapDown;
    } else if (event.type() == EventTypeNames::gesturescrollstart) {
        type = GestureScrollBegin;
        resendingPluginId = event.resendingPluginId();
        data.scrollBegin.deltaXHint = event.deltaX();
        data.scrollBegin.deltaYHint = event.deltaY();
        data.scrollBegin.deltaHintUnits = toWebGestureScrollUnits(event.deltaUnits());
        data.scrollBegin.inertial = event.inertial();
        data.scrollBegin.synthetic = event.synthetic();
    } else if (event.type() == EventTypeNames::gesturescrollend) {
        type = GestureScrollEnd;
        resendingPluginId = event.resendingPluginId();
        data.scrollEnd.deltaUnits = toWebGestureScrollUnits(event.deltaUnits());
        data.scrollEnd.inertial = event.inertial();
        data.scrollEnd.synthetic = event.synthetic();
    } else if (event.type() == EventTypeNames::gesturescrollupdate) {
        type = GestureScrollUpdate;
        data.scrollUpdate.deltaUnits = toWebGestureScrollUnits(event.deltaUnits());
        data.scrollUpdate.deltaX = event.deltaX();
        data.scrollUpdate.deltaY = event.deltaY();
        data.scrollUpdate.inertial = event.inertial();
        resendingPluginId = event.resendingPluginId();
    } else if (event.type() == EventTypeNames::gestureflingstart) {
        type = GestureFlingStart;
        data.flingStart.velocityX = event.velocityX();
        data.flingStart.velocityY = event.velocityY();
    } else if (event.type() == EventTypeNames::gesturetap) {
        type = GestureTap;
        data.tap.tapCount = 1;
    }

    timeStampSeconds = event.platformTimeStamp();
    modifiers = event.modifiers();

    globalX = event.screenX();
    globalY = event.screenY();
    IntPoint localPoint = convertAbsoluteLocationForLayoutObject(event.absoluteLocation(), *layoutObject);
    x = localPoint.x();
    y = localPoint.y();

    switch (event.source()) {
    case GestureSourceTouchpad:
        sourceDevice = WebGestureDeviceTouchpad;
        break;
    case GestureSourceTouchscreen:
        sourceDevice = WebGestureDeviceTouchscreen;
        break;
    case GestureSourceUninitialized:
        ASSERT_NOT_REACHED();
    }
}
void PointLightInteractionHandler::invokeEvent(Event* event) {
    // if(event->hasBeenUsed())
    //    return;

    if (screenPosEnabled_->get()) setLightPosFromScreenCoords(screenPos_->get());

    if (interactionEventOption_ == 1 || interactionEventOption_ == 3) {
        GestureEvent* gestureEvent = dynamic_cast<GestureEvent*>(event);
        if (gestureEvent) {
            if (gestureEvent->type() == GestureEvent::PAN) {
                setLightPosFromScreenCoords(gestureEvent->screenPosNormalized());
                gestureEvent->markAsUsed();
                return;
            }
        }
        MouseEvent* mouseEvent = dynamic_cast<MouseEvent*>(event);
        if (mouseEvent) {
            int button = mouseEvent->button();
            if (button == MouseEvent::MOUSE_BUTTON_MIDDLE) {
                // setLightPosFromScreenCoords(mouseEvent->posNormalized());
                mouseEvent->markAsUsed();
                screenPos_->set(mouseEvent->posNormalized());
                return;
            }
        }
    }

    if (interactionEventOption_ == 1 || interactionEventOption_ == 2) trackball_.invokeEvent(event);
}
WebGestureEventBuilder::WebGestureEventBuilder(const LayoutObject* layoutObject, const GestureEvent& event)
{
    if (event.type() == EventTypeNames::gestureshowpress)
        type = GestureShowPress;
    else if (event.type() == EventTypeNames::gesturelongpress)
        type = GestureLongPress;
    else if (event.type() == EventTypeNames::gesturetapdown)
        type = GestureTapDown;
    else if (event.type() == EventTypeNames::gesturescrollstart)
        type = GestureScrollBegin;
    else if (event.type() == EventTypeNames::gesturescrollend)
        type = GestureScrollEnd;
    else if (event.type() == EventTypeNames::gesturescrollupdate) {
        type = GestureScrollUpdate;
        data.scrollUpdate.deltaX = event.deltaX();
        data.scrollUpdate.deltaY = event.deltaY();
    } else if (event.type() == EventTypeNames::gesturetap) {
        type = GestureTap;
        data.tap.tapCount = 1;
    }

    timeStampSeconds = event.timeStamp() / millisPerSecond;
    modifiers = getWebInputModifiers(event);

    globalX = event.screenX();
    globalY = event.screenY();
    IntPoint localPoint = convertAbsoluteLocationForLayoutObject(event.absoluteLocation(), *layoutObject);
    x = localPoint.x();
    y = localPoint.y();
}