This source file includes following definitions.
- instance
- addDeviceOrientationController
- removeDeviceOrientationController
- startListening
- stopListening
- didChangeDeviceOrientation
- latestDeviceOrientationData
#include "config.h"
#include "modules/device_orientation/DeviceOrientationDispatcher.h"
#include "modules/device_orientation/DeviceOrientationController.h"
#include "modules/device_orientation/DeviceOrientationData.h"
#include "public/platform/Platform.h"
#include "wtf/TemporaryChange.h"
namespace WebCore {
DeviceOrientationDispatcher& DeviceOrientationDispatcher::instance()
{
DEFINE_STATIC_LOCAL(DeviceOrientationDispatcher, deviceOrientationDispatcher, ());
return deviceOrientationDispatcher;
}
DeviceOrientationDispatcher::DeviceOrientationDispatcher()
{
}
DeviceOrientationDispatcher::~DeviceOrientationDispatcher()
{
}
void DeviceOrientationDispatcher::addDeviceOrientationController(DeviceOrientationController* controller)
{
addController(controller);
}
void DeviceOrientationDispatcher::removeDeviceOrientationController(DeviceOrientationController* controller)
{
removeController(controller);
}
void DeviceOrientationDispatcher::startListening()
{
blink::Platform::current()->setDeviceOrientationListener(this);
}
void DeviceOrientationDispatcher::stopListening()
{
blink::Platform::current()->setDeviceOrientationListener(0);
m_lastDeviceOrientationData.clear();
}
void DeviceOrientationDispatcher::didChangeDeviceOrientation(const blink::WebDeviceOrientationData& motion)
{
m_lastDeviceOrientationData = DeviceOrientationData::create(motion);
{
TemporaryChange<bool> changeIsDispatching(m_isDispatching, true);
size_t size = m_controllers.size();
for (size_t i = 0; i < size; ++i) {
if (m_controllers[i])
static_cast<DeviceOrientationController*>(m_controllers[i])->didChangeDeviceOrientation(m_lastDeviceOrientationData.get());
}
}
if (m_needsPurge)
purgeControllers();
}
DeviceOrientationData* DeviceOrientationDispatcher::latestDeviceOrientationData()
{
return m_lastDeviceOrientationData.get();
}
}