PointerLockController.h [plain text]
#pragma once
#if ENABLE(POINTER_LOCK)
#include <wtf/RefPtr.h>
#include <wtf/WeakPtr.h>
#include <wtf/text/AtomString.h>
namespace WebCore {
class Element;
class Document;
class Page;
class PlatformMouseEvent;
class PlatformWheelEvent;
class VoidCallback;
class PointerLockController {
WTF_MAKE_NONCOPYABLE(PointerLockController);
WTF_MAKE_FAST_ALLOCATED;
public:
explicit PointerLockController(Page&);
void requestPointerLock(Element* target);
void requestPointerUnlock();
void requestPointerUnlockAndForceCursorVisible();
void elementRemoved(Element&);
void documentDetached(Document&);
bool isLocked() const;
WEBCORE_EXPORT bool lockPending() const;
WEBCORE_EXPORT Element* element() const;
WEBCORE_EXPORT void didAcquirePointerLock();
WEBCORE_EXPORT void didNotAcquirePointerLock();
WEBCORE_EXPORT void didLosePointerLock();
void dispatchLockedMouseEvent(const PlatformMouseEvent&, const AtomString& eventType);
void dispatchLockedWheelEvent(const PlatformWheelEvent&);
private:
void clearElement();
void enqueueEvent(const AtomString& type, Element*);
void enqueueEvent(const AtomString& type, Document*);
Page& m_page;
bool m_lockPending { false };
bool m_unlockPending { false };
bool m_forceCursorVisibleUponUnlock { false };
RefPtr<Element> m_element;
WeakPtr<Document> m_documentOfRemovedElementWhileWaitingForUnlock;
WeakPtr<Document> m_documentAllowedToRelockWithoutUserGesture;
};
}
#endif // ENABLE(POINTER_LOCK)