#pragma once
#include "MouseEvent.h"
#include "PlatformWheelEvent.h"
namespace WebCore {
class WheelEvent final : public MouseEvent {
WTF_MAKE_ISO_ALLOCATED(WheelEvent);
public:
enum { TickMultiplier = 120 };
enum {
DOM_DELTA_PIXEL = 0,
DOM_DELTA_LINE,
DOM_DELTA_PAGE
};
static Ref<WheelEvent> create(const PlatformWheelEvent&, RefPtr<WindowProxy>&&);
static Ref<WheelEvent> createForBindings();
struct Init : MouseEventInit {
double deltaX { 0 };
double deltaY { 0 };
double deltaZ { 0 };
unsigned deltaMode { DOM_DELTA_PIXEL };
int wheelDeltaX { 0 }; int wheelDeltaY { 0 }; };
static Ref<WheelEvent> create(const AtomString& type, const Init&);
WEBCORE_EXPORT void initWebKitWheelEvent(int rawDeltaX, int rawDeltaY, RefPtr<WindowProxy>&&, int screenX, int screenY, int pageX, int pageY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey);
const Optional<PlatformWheelEvent>& underlyingPlatformEvent() const { return m_underlyingPlatformEvent; }
double deltaX() const { return m_deltaX; } double deltaY() const { return m_deltaY; } double deltaZ() const { return m_deltaZ; }
int wheelDelta() const { return wheelDeltaY() ? wheelDeltaY() : wheelDeltaX(); } int wheelDeltaX() const { return m_wheelDelta.x(); } int wheelDeltaY() const { return m_wheelDelta.y(); } unsigned deltaMode() const { return m_deltaMode; }
bool webkitDirectionInvertedFromDevice() const { return m_underlyingPlatformEvent && m_underlyingPlatformEvent.value().directionInvertedFromDevice(); }
#if PLATFORM(MAC)
PlatformWheelEventPhase phase() const { return m_underlyingPlatformEvent ? m_underlyingPlatformEvent.value().phase() : PlatformWheelEventPhaseNone; }
PlatformWheelEventPhase momentumPhase() const { return m_underlyingPlatformEvent ? m_underlyingPlatformEvent.value().momentumPhase() : PlatformWheelEventPhaseNone; }
#endif
private:
WheelEvent();
WheelEvent(const AtomString&, const Init&);
WheelEvent(const PlatformWheelEvent&, RefPtr<WindowProxy>&&);
EventInterface eventInterface() const final;
bool isWheelEvent() const final;
IntPoint m_wheelDelta;
double m_deltaX { 0 };
double m_deltaY { 0 };
double m_deltaZ { 0 };
unsigned m_deltaMode { DOM_DELTA_PIXEL };
Optional<PlatformWheelEvent> m_underlyingPlatformEvent;
};
}
SPECIALIZE_TYPE_TRAITS_EVENT(WheelEvent)