#ifndef EventPath_h
#define EventPath_h
#include "EventContext.h"
#include "PseudoElement.h"
#include "SVGElement.h"
#include "SVGUseElement.h"
#include <wtf/Forward.h>
#include <wtf/Vector.h>
namespace WebCore {
class EventPath {
public:
EventPath(Node& origin, Event&);
bool isEmpty() const { return m_path.isEmpty(); }
size_t size() const { return m_path.size(); }
const EventContext& contextAt(size_t i) const { return *m_path[i]; }
EventContext& contextAt(size_t i) { return *m_path[i]; }
#if ENABLE(TOUCH_EVENTS)
void retargetTouchLists(const TouchEvent&);
#endif
void setRelatedTarget(Node& origin, EventTarget&);
bool hasEventListeners(const AtomicString& eventType) const;
EventContext* lastContextIfExists() { return m_path.isEmpty() ? nullptr : m_path.last().get(); }
Vector<EventTarget*> computePathUnclosedToTarget(const EventTarget&) const;
static Node* eventTargetRespectingTargetRules(Node& referenceNode)
{
if (is<PseudoElement>(referenceNode))
return downcast<PseudoElement>(referenceNode).hostElement();
if (is<SVGElement>(referenceNode)) {
if (auto* useElement = downcast<SVGElement>(referenceNode).correspondingUseElement())
return useElement;
}
return &referenceNode;
}
private:
#if ENABLE(TOUCH_EVENTS)
void retargetTouch(TouchEventContext::TouchListType, const Touch&);
#endif
Vector<std::unique_ptr<EventContext>, 32> m_path;
};
}
#endif