JSValue* JSMouseEventPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
{
    if (!thisObj->inherits(&JSMouseEvent::info))
      return throwError(exec, TypeError);

    MouseEvent* imp = static_cast<MouseEvent*>(static_cast<JSMouseEvent*>(thisObj)->impl());

    switch (id) {
    case JSMouseEvent::InitMouseEventFuncNum: {
        AtomicString type = args[0]->toString(exec);
        bool canBubble = args[1]->toBoolean(exec);
        bool cancelable = args[2]->toBoolean(exec);
        DOMWindow* view = toDOMWindow(args[3]);
        bool detailOk;
        int detail = args[4]->toInt32(exec, detailOk);
        if (!detailOk) {
            setDOMException(exec, TYPE_MISMATCH_ERR);
            return jsUndefined();
        }
        bool screenXOk;
        int screenX = args[5]->toInt32(exec, screenXOk);
        if (!screenXOk) {
            setDOMException(exec, TYPE_MISMATCH_ERR);
            return jsUndefined();
        }
        bool screenYOk;
        int screenY = args[6]->toInt32(exec, screenYOk);
        if (!screenYOk) {
            setDOMException(exec, TYPE_MISMATCH_ERR);
            return jsUndefined();
        }
        bool clientXOk;
        int clientX = args[7]->toInt32(exec, clientXOk);
        if (!clientXOk) {
            setDOMException(exec, TYPE_MISMATCH_ERR);
            return jsUndefined();
        }
        bool clientYOk;
        int clientY = args[8]->toInt32(exec, clientYOk);
        if (!clientYOk) {
            setDOMException(exec, TYPE_MISMATCH_ERR);
            return jsUndefined();
        }
        bool ctrlKey = args[9]->toBoolean(exec);
        bool altKey = args[10]->toBoolean(exec);
        bool shiftKey = args[11]->toBoolean(exec);
        bool metaKey = args[12]->toBoolean(exec);
        unsigned short button = args[13]->toInt32(exec);
        EventTargetNode* relatedTarget = toEventTargetNode(args[14]);

        imp->initMouseEvent(type, canBubble, cancelable, view, detail, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget);
        return jsUndefined();
    }
    }
    return 0;
}
Пример #2
0
void SVGVisual::OnLeftMouseButtonDown(Gui::MouseButtonEventArgs* args)
{
	Gui::Point mousepos = args->GetPosition(this);

	PSVGElement* pElement;
	pElement = m_psvgelement->HitTestElement(gm::Matrix3d::GetIdentity(), gm::PointD(mousepos.X, mousepos.Y));

	if (pElement)
	{
		EventTarget* target = dynamic_cast<EventTarget*>(pElement->m_pNode);
		EventTarget* relatedTarget = dynamic_cast<EventTarget*>(m_psvgelement->m_pNode);

		gm::PointF screenpt;
		gm::PointF clientpt = mousepos;
		UINT nFlags = 0;
		bool m_bAlt = false;
		int iButton = 0;

		//IDocumentEvent* documentEvent = dynamic_cast<IDocumentEvent*>(m_document);

		MouseEvent* mouseevt = static_cast<MouseEvent*>(m_document->createEvent(WSTR("MouseEvents")));
		mouseevt->initMouseEvent(L"mousedown",
			true,	// bubbles
			true,	// cancelable
			m_window,	// viewArg
			0,		// detail
			screenpt.X, screenpt.Y,	// screen
			clientpt.X, clientpt.Y, // client,
			(nFlags & MK_CONTROL)? true: false,
			(nFlags & MK_SHIFT)? true: false,
			(m_bAlt)? true: false,
			0,	// meta
			iButton,
			relatedTarget
			);

		bool doDefault = target->dispatchEvent(mouseevt);
		if (doDefault)
		{
		}
	}
}
Пример #3
0
static v8::Handle<v8::Value> initMouseEventCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.MouseEvent.initMouseEvent");
    MouseEvent* imp = V8MouseEvent::toNative(args.Holder());
    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, type, MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined));
    EXCEPTION_BLOCK(bool, canBubble, MAYBE_MISSING_PARAMETER(args, 1, MissingIsUndefined)->BooleanValue());
    EXCEPTION_BLOCK(bool, cancelable, MAYBE_MISSING_PARAMETER(args, 2, MissingIsUndefined)->BooleanValue());
    EXCEPTION_BLOCK(DOMWindow*, view, V8DOMWindow::HasInstance(MAYBE_MISSING_PARAMETER(args, 3, MissingIsUndefined)) ? V8DOMWindow::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 3, MissingIsUndefined))) : 0);
    EXCEPTION_BLOCK(int, detail, toInt32(MAYBE_MISSING_PARAMETER(args, 4, MissingIsUndefined)));
    EXCEPTION_BLOCK(int, screenX, toInt32(MAYBE_MISSING_PARAMETER(args, 5, MissingIsUndefined)));
    EXCEPTION_BLOCK(int, screenY, toInt32(MAYBE_MISSING_PARAMETER(args, 6, MissingIsUndefined)));
    EXCEPTION_BLOCK(int, clientX, toInt32(MAYBE_MISSING_PARAMETER(args, 7, MissingIsUndefined)));
    EXCEPTION_BLOCK(int, clientY, toInt32(MAYBE_MISSING_PARAMETER(args, 8, MissingIsUndefined)));
    EXCEPTION_BLOCK(bool, ctrlKey, MAYBE_MISSING_PARAMETER(args, 9, MissingIsUndefined)->BooleanValue());
    EXCEPTION_BLOCK(bool, altKey, MAYBE_MISSING_PARAMETER(args, 10, MissingIsUndefined)->BooleanValue());
    EXCEPTION_BLOCK(bool, shiftKey, MAYBE_MISSING_PARAMETER(args, 11, MissingIsUndefined)->BooleanValue());
    EXCEPTION_BLOCK(bool, metaKey, MAYBE_MISSING_PARAMETER(args, 12, MissingIsUndefined)->BooleanValue());
    EXCEPTION_BLOCK(int, button, toUInt32(MAYBE_MISSING_PARAMETER(args, 13, MissingIsUndefined)));
    EXCEPTION_BLOCK(Node*, relatedTarget, V8Node::HasInstance(MAYBE_MISSING_PARAMETER(args, 14, MissingIsUndefined)) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 14, MissingIsUndefined))) : 0);
    imp->initMouseEvent(type, canBubble, cancelable, view, detail, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget);
    return v8::Handle<v8::Value>();
}