#include "config.h"
#include "MouseEvent.h"
#include "EventNames.h"
namespace WebCore {
using namespace EventNames;
MouseEvent::MouseEvent()
: m_button(0)
{
}
MouseEvent::MouseEvent(const AtomicString& eventType, bool canBubble, bool cancelable, AbstractView* view,
int detail, int screenX, int screenY, int pageX, int pageY,
bool ctrlKey, bool altKey, bool shiftKey, bool metaKey,
unsigned short button, EventTargetNode* relatedTarget,
Clipboard* clipboard, bool isSimulated)
: MouseRelatedEvent(eventType, canBubble, cancelable, view, detail, screenX, screenY,
pageX, pageY, ctrlKey, altKey, shiftKey, metaKey, isSimulated)
, m_button(button)
, m_relatedTarget(relatedTarget)
, m_clipboard(clipboard)
{
}
MouseEvent::~MouseEvent()
{
}
void MouseEvent::initMouseEvent(const AtomicString& type, bool canBubble, bool cancelable, AbstractView* view,
int detail, int screenX, int screenY, int clientX, int clientY,
bool ctrlKey, bool altKey, bool shiftKey, bool metaKey,
unsigned short button, EventTargetNode* relatedTarget)
{
if (dispatched())
return;
initUIEvent(type, canBubble, cancelable, view, detail);
m_screenX = screenX;
m_screenY = screenY;
m_ctrlKey = ctrlKey;
m_altKey = altKey;
m_shiftKey = shiftKey;
m_metaKey = metaKey;
m_button = button;
m_relatedTarget = relatedTarget;
initCoordinates(clientX, clientY);
}
bool MouseEvent::isMouseEvent() const
{
return true;
}
bool MouseEvent::isDragEvent() const
{
const AtomicString& t = type();
return t == dragenterEvent || t == dragoverEvent || t == dragleaveEvent || t == dropEvent
|| t == dragstartEvent|| t == dragEvent || t == dragendEvent;
}
int MouseEvent::which() const
{
return m_button + 1;
}
Node* MouseEvent::toElement() const
{
return (type() == mouseoutEvent) ? relatedTarget() : target();
}
Node* MouseEvent::fromElement() const
{
return (type() == mouseoutEvent) ? target() : relatedTarget();
}
}