PointerCaptureController.h [plain text]
#pragma once
#if ENABLE(POINTER_EVENTS)
#include "ExceptionOr.h"
#include "PointerID.h"
#include <wtf/HashMap.h>
namespace WebCore {
class Document;
class Element;
class EventTarget;
class IntPoint;
class MouseEvent;
class Page;
class PlatformTouchEvent;
class PointerEvent;
class WindowProxy;
class PointerCaptureController {
WTF_MAKE_NONCOPYABLE(PointerCaptureController);
WTF_MAKE_FAST_ALLOCATED;
public:
explicit PointerCaptureController(Page&);
Element* pointerCaptureElement(Document*, PointerID);
ExceptionOr<void> setPointerCapture(Element*, PointerID);
ExceptionOr<void> releasePointerCapture(Element*, PointerID);
bool hasPointerCapture(Element*, PointerID);
void reset();
void pointerLockWasApplied();
void elementWasRemoved(Element&);
RefPtr<PointerEvent> pointerEventForMouseEvent(const MouseEvent&);
#if ENABLE(TOUCH_EVENTS) && PLATFORM(IOS_FAMILY)
void dispatchEventForTouchAtIndex(EventTarget&, const PlatformTouchEvent&, unsigned, bool isPrimary, WindowProxy&);
#endif
WEBCORE_EXPORT void touchWithIdentifierWasRemoved(PointerID);
bool hasCancelledPointerEventForIdentifier(PointerID);
bool preventsCompatibilityMouseEventsForIdentifier(PointerID);
void dispatchEvent(PointerEvent&, EventTarget*);
WEBCORE_EXPORT void cancelPointer(PointerID, const IntPoint&);
void processPendingPointerCapture(PointerID);
private:
struct CapturingData {
RefPtr<Element> pendingTargetOverride;
RefPtr<Element> targetOverride;
#if ENABLE(TOUCH_EVENTS) && PLATFORM(IOS_FAMILY)
RefPtr<Element> previousTarget;
#endif
String pointerType;
bool cancelled { false };
bool isPrimary { false };
bool preventsCompatibilityMouseEvents { false };
bool pointerIsPressed { false };
short previousMouseButton { -1 };
};
CapturingData& ensureCapturingDataForPointerEvent(const PointerEvent&);
void pointerEventWillBeDispatched(const PointerEvent&, EventTarget*);
void pointerEventWasDispatched(const PointerEvent&);
Page& m_page;
using PointerIdToCapturingDataMap = HashMap<int64_t, CapturingData, WTF::IntHash<int64_t>, WTF::SignedWithZeroKeyHashTraits<int64_t>>;
PointerIdToCapturingDataMap m_activePointerIdsToCapturingData;
bool m_processingPendingPointerCapture { false };
};
}
#endif // ENABLE(POINTER_EVENTS)