#include "config.h"
#if ENABLE(TOUCH_EVENTS)
#include "TouchEvent.h"
#include "EventDispatcher.h"
#include <wtf/IsoMallocInlines.h>
namespace WebCore {
WTF_MAKE_ISO_ALLOCATED_IMPL(TouchEvent);
TouchEvent::TouchEvent() = default;
TouchEvent::TouchEvent(TouchList* touches, TouchList* targetTouches, TouchList* changedTouches, const AtomString& type,
RefPtr<WindowProxy>&& view, const IntPoint& globalLocation, OptionSet<Modifier> modifiers)
: MouseRelatedEvent(type, IsCancelable::Yes, MonotonicTime::now(), WTFMove(view), globalLocation, modifiers)
, m_touches(touches)
, m_targetTouches(targetTouches)
, m_changedTouches(changedTouches)
{
}
TouchEvent::TouchEvent(const AtomString& type, const Init& initializer, IsTrusted isTrusted)
: MouseRelatedEvent(type, initializer, isTrusted)
, m_touches(initializer.touches ? initializer.touches : TouchList::create())
, m_targetTouches(initializer.targetTouches ? initializer.targetTouches : TouchList::create())
, m_changedTouches(initializer.changedTouches ? initializer.changedTouches : TouchList::create())
{
}
TouchEvent::~TouchEvent() = default;
void TouchEvent::initTouchEvent(TouchList* touches, TouchList* targetTouches,
TouchList* changedTouches, const AtomString& type,
RefPtr<WindowProxy>&& view, int screenX, int screenY, int clientX, int clientY,
bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
{
if (isBeingDispatched())
return;
initUIEvent(type, true, true, WTFMove(view), 0);
m_touches = touches;
m_targetTouches = targetTouches;
m_changedTouches = changedTouches;
m_screenLocation = IntPoint(screenX, screenY);
setModifierKeys(ctrlKey, altKey, shiftKey, metaKey);
initCoordinates(IntPoint(clientX, clientY));
}
EventInterface TouchEvent::eventInterface() const
{
return TouchEventInterfaceType;
}
bool TouchEvent::isTouchEvent() const
{
return true;
}
}
#endif // ENABLE(TOUCH_EVENTS)