This source file includes following definitions.
- m_deviceMotionData
- initDeviceMotionEvent
- acceleration
- accelerationIncludingGravity
- rotationRate
- interval
- interfaceName
- trace
#include "config.h"
#include "modules/device_orientation/DeviceMotionEvent.h"
#include "modules/device_orientation/DeviceAcceleration.h"
#include "modules/device_orientation/DeviceMotionData.h"
#include "modules/device_orientation/DeviceRotationRate.h"
namespace WebCore {
DeviceMotionEvent::~DeviceMotionEvent()
{
}
DeviceMotionEvent::DeviceMotionEvent()
: m_deviceMotionData(DeviceMotionData::create())
{
ScriptWrappable::init(this);
}
DeviceMotionEvent::DeviceMotionEvent(const AtomicString& eventType, DeviceMotionData* deviceMotionData)
: Event(eventType, false, false)
, m_deviceMotionData(deviceMotionData)
{
ScriptWrappable::init(this);
}
void DeviceMotionEvent::initDeviceMotionEvent(const AtomicString& type, bool bubbles, bool cancelable, DeviceMotionData* deviceMotionData)
{
if (dispatched())
return;
initEvent(type, bubbles, cancelable);
m_deviceMotionData = deviceMotionData;
m_acceleration.clear();
m_accelerationIncludingGravity.clear();
m_rotationRate.clear();
}
DeviceAcceleration* DeviceMotionEvent::acceleration()
{
if (!m_deviceMotionData->acceleration())
return 0;
if (!m_acceleration)
m_acceleration = DeviceAcceleration::create(m_deviceMotionData->acceleration());
return m_acceleration.get();
}
DeviceAcceleration* DeviceMotionEvent::accelerationIncludingGravity()
{
if (!m_deviceMotionData->accelerationIncludingGravity())
return 0;
if (!m_accelerationIncludingGravity)
m_accelerationIncludingGravity = DeviceAcceleration::create(m_deviceMotionData->accelerationIncludingGravity());
return m_accelerationIncludingGravity.get();
}
DeviceRotationRate* DeviceMotionEvent::rotationRate()
{
if (!m_deviceMotionData->rotationRate())
return 0;
if (!m_rotationRate)
m_rotationRate = DeviceRotationRate::create(m_deviceMotionData->rotationRate());
return m_rotationRate.get();
}
double DeviceMotionEvent::interval(bool& isNull) const
{
if (m_deviceMotionData->canProvideInterval())
return m_deviceMotionData->interval();
isNull = true;
return 0;
}
const AtomicString& DeviceMotionEvent::interfaceName() const
{
return EventNames::DeviceMotionEvent;
}
void DeviceMotionEvent::trace(Visitor* visitor)
{
visitor->trace(m_deviceMotionData);
visitor->trace(m_acceleration);
visitor->trace(m_accelerationIncludingGravity);
visitor->trace(m_rotationRate);
Event::trace(visitor);
}
}