#include "config.h"
#include "WheelEvent.h"
#include "EventNames.h"
#include <wtf/MathExtras.h>
namespace WebCore {
WheelEvent::WheelEvent()
: m_wheelDeltaX(0)
, m_wheelDeltaY(0)
, m_rawDeltaX(0)
, m_rawDeltaY(0)
, m_granularity(Pixel)
{
}
WheelEvent::WheelEvent(float wheelTicksX, float wheelTicksY, float rawDeltaX, float rawDeltaY,
Granularity granularity, PassRefPtr<AbstractView> view,
int screenX, int screenY, int pageX, int pageY,
bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
: MouseRelatedEvent(eventNames().mousewheelEvent,
true, true, view, 0, screenX, screenY, pageX, pageY,
ctrlKey, altKey, shiftKey, metaKey)
, m_wheelDeltaX(lroundf(wheelTicksX * 120))
, m_wheelDeltaY(lroundf(wheelTicksY * 120)) , m_rawDeltaX(rawDeltaX)
, m_rawDeltaY(rawDeltaY)
, m_granularity(granularity)
{
}
void WheelEvent::initWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<AbstractView> view,
int screenX, int screenY, int pageX, int pageY,
bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
{
if (dispatched())
return;
initUIEvent(eventNames().mousewheelEvent, true, true, view, 0);
m_screenX = screenX;
m_screenY = screenY;
m_ctrlKey = ctrlKey;
m_altKey = altKey;
m_shiftKey = shiftKey;
m_metaKey = metaKey;
m_wheelDeltaX = rawDeltaX * 120;
m_wheelDeltaY = rawDeltaY * 120;
m_rawDeltaX = rawDeltaX;
m_rawDeltaY = rawDeltaY;
m_granularity = Pixel;
initCoordinates(pageX, pageY);
}
void WheelEvent::initWebKitWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<AbstractView> view,
int screenX, int screenY, int pageX, int pageY,
bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
{
initWheelEvent(rawDeltaX, rawDeltaY, view, screenX, screenY, pageX, pageY,
ctrlKey, altKey, shiftKey, metaKey);
}
bool WheelEvent::isWheelEvent() const
{
return true;
}
}