Пример #1
0
IDOMEvent* DOMEvent::createInstance(PassRefPtr<WebCore::Event> e)
{
    if (!e)
        return nullptr;

    HRESULT hr;
    IDOMEvent* domEvent = nullptr;

    switch (e->eventInterface()) {
    case WebCore::KeyboardEventInterfaceType: {
        DOMKeyboardEvent* newEvent = new DOMKeyboardEvent(e);
        hr = newEvent->QueryInterface(IID_IDOMKeyboardEvent, (void**)&domEvent);
        break;
    }
    case WebCore::MouseEventInterfaceType: {
        DOMMouseEvent* newEvent = new DOMMouseEvent(e);
        hr = newEvent->QueryInterface(IID_IDOMMouseEvent, (void**)&domEvent);
        break;
    }
    case WebCore::MutationEventInterfaceType: {
        DOMMutationEvent* newEvent = new DOMMutationEvent(e);
        hr = newEvent->QueryInterface(IID_IDOMMutationEvent, (void**)&domEvent);
        break;
    }
    case WebCore::OverflowEventInterfaceType: {
        DOMOverflowEvent* newEvent = new DOMOverflowEvent(e);
        hr = newEvent->QueryInterface(IID_IDOMOverflowEvent, (void**)&domEvent);
        break;
    }
    case WebCore::WheelEventInterfaceType: {
        DOMWheelEvent* newEvent = new DOMWheelEvent(e);
        hr = newEvent->QueryInterface(IID_IDOMWheelEvent, (void**)&domEvent);
        break;
    }
    default:
        if (e->isUIEvent()) {
            DOMUIEvent* newEvent = new DOMUIEvent(e);
            hr = newEvent->QueryInterface(IID_IDOMUIEvent, (void**)&domEvent);
        } else {
            DOMEvent* newEvent = new DOMEvent(e);
            hr = newEvent->QueryInterface(IID_IDOMEvent, (void**)&domEvent);
        }
    }

    if (FAILED(hr))
        return nullptr;

    return domEvent;
}
Пример #2
0
IDOMEvent* DOMEvent::createInstance(PassRefPtr<WebCore::Event> e)
{
    if (!e)
        return 0;

    HRESULT hr;
    IDOMEvent* domEvent = 0;

    if (e->isKeyboardEvent()) {
        DOMKeyboardEvent* newEvent = new DOMKeyboardEvent(e);
        hr = newEvent->QueryInterface(IID_IDOMKeyboardEvent, (void**)&domEvent);
    } else if (e->isMouseEvent()) {
        DOMMouseEvent* newEvent = new DOMMouseEvent(e);
        hr = newEvent->QueryInterface(IID_IDOMMouseEvent, (void**)&domEvent);
    } else if (e->isMutationEvent()) {
        DOMMutationEvent* newEvent = new DOMMutationEvent(e);
        hr = newEvent->QueryInterface(IID_IDOMMutationEvent, (void**)&domEvent);
    } else if (e->isOverflowEvent()) {
        DOMOverflowEvent* newEvent = new DOMOverflowEvent(e);
        hr = newEvent->QueryInterface(IID_IDOMOverflowEvent, (void**)&domEvent);
    } else if (e->isWheelEvent()) {
        DOMWheelEvent* newEvent = new DOMWheelEvent(e);
        hr = newEvent->QueryInterface(IID_IDOMWheelEvent, (void**)&domEvent);
    } else if (e->isUIEvent()) {
        DOMUIEvent* newEvent = new DOMUIEvent(e);
        hr = newEvent->QueryInterface(IID_IDOMUIEvent, (void**)&domEvent);
    } else {
        DOMEvent* newEvent = new DOMEvent(e);
        hr = newEvent->QueryInterface(IID_IDOMEvent, (void**)&domEvent);
    }

    if (FAILED(hr))
        return 0;

    return domEvent;
}