コード例 #1
0
MouseEvent* MouseEvent::create(const AtomicString& eventType, AbstractView* view, Event* underlyingEvent, SimulatedClickCreationScope creationScope)
{
    PlatformEvent::Modifiers modifiers = PlatformEvent::NoModifiers;
    if (UIEventWithKeyState* keyStateEvent = findEventWithKeyState(underlyingEvent)) {
        modifiers = keyStateEvent->modifiers();
    }

    PlatformMouseEvent::SyntheticEventType syntheticType = PlatformMouseEvent::Positionless;
    int screenX = 0;
    int screenY = 0;
    if (underlyingEvent && underlyingEvent->isMouseEvent()) {
        syntheticType = PlatformMouseEvent::RealOrIndistinguishable;
        MouseEvent* mouseEvent = toMouseEvent(underlyingEvent);
        screenX = mouseEvent->screenLocation().x();
        screenY = mouseEvent->screenLocation().y();
    }

    double timestamp = underlyingEvent ? underlyingEvent->platformTimeStamp() : monotonicallyIncreasingTime();
    MouseEvent* createdEvent = MouseEvent::create(eventType, true, true, view,
        0, screenX, screenY, 0, 0, 0, 0, modifiers, 0, 0, nullptr,
        timestamp, syntheticType, String());

    createdEvent->setTrusted(creationScope == SimulatedClickCreationScope::FromUserAgent);
    createdEvent->setUnderlyingEvent(underlyingEvent);
    if (syntheticType == PlatformMouseEvent::RealOrIndistinguishable) {
        MouseEvent* mouseEvent = toMouseEvent(createdEvent->underlyingEvent());
        createdEvent->initCoordinates(mouseEvent->clientLocation());
    }

    return createdEvent;
}
コード例 #2
0
ファイル: MouseEvent.cpp プロジェクト: 1833183060/wke
SimulatedMouseEvent::SimulatedMouseEvent(const AtomicString& eventType, PassRefPtr<AbstractView> view, PassRefPtr<Event> underlyingEvent)
    : MouseEvent(eventType, true, true, view, 0, 0, 0, 0, 0, false, false, false, false, 0, 0, 0, true)
{
    if (UIEventWithKeyState* keyStateEvent = findEventWithKeyState(underlyingEvent.get())) {
        m_ctrlKey = keyStateEvent->ctrlKey();
        m_altKey = keyStateEvent->altKey();
        m_shiftKey = keyStateEvent->shiftKey();
        m_metaKey = keyStateEvent->metaKey();
    }
    setUnderlyingEvent(underlyingEvent);

    if (this->underlyingEvent() && this->underlyingEvent()->isMouseEvent()) {
        MouseEvent* mouseEvent = static_cast<MouseEvent*>(this->underlyingEvent());
        m_screenLocation = mouseEvent->screenLocation();
        initCoordinates(mouseEvent->clientLocation());
    }
}
コード例 #3
0
SimulatedMouseEvent::SimulatedMouseEvent(const AtomicString& eventType, PassRefPtrWillBeRawPtr<AbstractView> view, PassRefPtrWillBeRawPtr<Event> underlyingEvent)
    : MouseEvent(eventType, true, true, view, 0, 0, 0, 0, 0, 0, 0, false, false, false, false, 0, 0,
        nullptr, nullptr, true, PlatformMouseEvent::RealOrIndistinguishable)
{
    if (UIEventWithKeyState* keyStateEvent = findEventWithKeyState(underlyingEvent.get())) {
        m_ctrlKey = keyStateEvent->ctrlKey();
        m_altKey = keyStateEvent->altKey();
        m_shiftKey = keyStateEvent->shiftKey();
        m_metaKey = keyStateEvent->metaKey();
    }
    setUnderlyingEvent(underlyingEvent);

    if (this->underlyingEvent() && this->underlyingEvent()->isMouseEvent()) {
        MouseEvent* mouseEvent = toMouseEvent(this->underlyingEvent());
        m_screenLocation = mouseEvent->screenLocation();
        initCoordinates(mouseEvent->clientLocation());
    }
}
コード例 #4
0
ファイル: MouseEvent.cpp プロジェクト: CannedFish/webkitgtk
SimulatedMouseEvent::SimulatedMouseEvent(const AtomicString& eventType, PassRefPtr<AbstractView> view, PassRefPtr<Event> underlyingEvent, Element* target)
    : MouseEvent(eventType, true, true, underlyingEvent ? underlyingEvent->timeStamp() : currentTime(), view, 0, 0, 0, 0, 0,
#if ENABLE(POINTER_LOCK)
                 0, 0,
#endif
                 false, false, false, false, 0, 0, 0, true)
{
    if (UIEventWithKeyState* keyStateEvent = findEventWithKeyState(underlyingEvent.get())) {
        m_ctrlKey = keyStateEvent->ctrlKey();
        m_altKey = keyStateEvent->altKey();
        m_shiftKey = keyStateEvent->shiftKey();
        m_metaKey = keyStateEvent->metaKey();
    }
    setUnderlyingEvent(underlyingEvent);

    if (this->underlyingEvent() && this->underlyingEvent()->isMouseEvent()) {
        MouseEvent* mouseEvent = static_cast<MouseEvent*>(this->underlyingEvent());
        m_screenLocation = mouseEvent->screenLocation();
        initCoordinates(mouseEvent->clientLocation());
    } else if (target) {
        m_screenLocation = target->screenRect().center();
        initCoordinates(LayoutPoint(target->clientRect().center()));
    }
}