#include "config.h"
#include "WebEvent.h"
#include "Arguments.h"
#include "WebCoreArgumentCoders.h"
using namespace WebCore;
namespace WebKit {
WebWheelEvent::WebWheelEvent(Type type, const IntPoint& position, const IntPoint& globalPosition, const FloatSize& delta, const FloatSize& wheelTicks, Granularity granularity, Modifiers modifiers, double timestamp)
: WebEvent(type, modifiers, timestamp)
, m_position(position)
, m_globalPosition(globalPosition)
, m_delta(delta)
, m_wheelTicks(wheelTicks)
, m_granularity(granularity)
, m_directionInvertedFromDevice(false)
#if PLATFORM(MAC)
, m_phase(PhaseNone)
, m_hasPreciseScrollingDeltas(false)
, m_scrollCount(0)
#endif
{
ASSERT(isWheelEventType(type));
}
#if PLATFORM(MAC)
WebWheelEvent::WebWheelEvent(Type type, const IntPoint& position, const IntPoint& globalPosition, const FloatSize& delta, const FloatSize& wheelTicks, Granularity granularity, bool directionInvertedFromDevice, Phase phase, Phase momentumPhase, bool hasPreciseScrollingDeltas, uint32_t scrollCount, const WebCore::FloatSize& unacceleratedScrollingDelta, Modifiers modifiers, double timestamp)
: WebEvent(type, modifiers, timestamp)
, m_position(position)
, m_globalPosition(globalPosition)
, m_delta(delta)
, m_wheelTicks(wheelTicks)
, m_granularity(granularity)
, m_directionInvertedFromDevice(directionInvertedFromDevice)
, m_phase(phase)
, m_momentumPhase(momentumPhase)
, m_hasPreciseScrollingDeltas(hasPreciseScrollingDeltas)
, m_scrollCount(scrollCount)
, m_unacceleratedScrollingDelta(unacceleratedScrollingDelta)
{
ASSERT(isWheelEventType(type));
}
#endif
void WebWheelEvent::encode(CoreIPC::ArgumentEncoder* encoder) const
{
WebEvent::encode(encoder);
encoder->encode(m_position);
encoder->encode(m_globalPosition);
encoder->encode(m_delta);
encoder->encode(m_wheelTicks);
encoder->encode(m_granularity);
encoder->encode(m_directionInvertedFromDevice);
#if PLATFORM(MAC)
encoder->encode(m_phase);
encoder->encode(m_momentumPhase);
encoder->encode(m_hasPreciseScrollingDeltas);
encoder->encode(m_scrollCount);
encoder->encode(m_unacceleratedScrollingDelta);
#endif
}
bool WebWheelEvent::decode(CoreIPC::ArgumentDecoder* decoder, WebWheelEvent& t)
{
if (!WebEvent::decode(decoder, t))
return false;
if (!decoder->decode(t.m_position))
return false;
if (!decoder->decode(t.m_globalPosition))
return false;
if (!decoder->decode(t.m_delta))
return false;
if (!decoder->decode(t.m_wheelTicks))
return false;
if (!decoder->decode(t.m_granularity))
return false;
if (!decoder->decode(t.m_directionInvertedFromDevice))
return false;
#if PLATFORM(MAC)
if (!decoder->decode(t.m_phase))
return false;
if (!decoder->decode(t.m_momentumPhase))
return false;
if (!decoder->decode(t.m_hasPreciseScrollingDeltas))
return false;
if (!decoder->decode(t.m_scrollCount))
return false;
if (!decoder->decode(t.m_unacceleratedScrollingDelta))
return false;
#endif
return true;
}
bool WebWheelEvent::isWheelEventType(Type type)
{
return type == Wheel;
}
}