| Index: Source/modules/device_orientation/DeviceOrientationDispatcher.cpp
|
| diff --git a/Source/modules/device_orientation/DeviceOrientationDispatcher.cpp b/Source/modules/device_orientation/DeviceOrientationDispatcher.cpp
|
| index 4c82b25aaa92041c0318862cf2a01268c79d3f62..ed73d039e8a2fe02e57b474002e88edfc65157d1 100644
|
| --- a/Source/modules/device_orientation/DeviceOrientationDispatcher.cpp
|
| +++ b/Source/modules/device_orientation/DeviceOrientationDispatcher.cpp
|
| @@ -34,6 +34,7 @@
|
| #include "modules/device_orientation/DeviceOrientationController.h"
|
| #include "modules/device_orientation/DeviceOrientationData.h"
|
| #include "public/platform/Platform.h"
|
| +#include "wtf/TemporaryChange.h"
|
|
|
| namespace WebCore {
|
|
|
| @@ -51,6 +52,16 @@
|
| {
|
| }
|
|
|
| +void DeviceOrientationDispatcher::addDeviceOrientationController(DeviceOrientationController* controller)
|
| +{
|
| + addController(controller);
|
| +}
|
| +
|
| +void DeviceOrientationDispatcher::removeDeviceOrientationController(DeviceOrientationController* controller)
|
| +{
|
| + removeController(controller);
|
| +}
|
| +
|
| void DeviceOrientationDispatcher::startListening()
|
| {
|
| blink::Platform::current()->setDeviceOrientationListener(this);
|
| @@ -65,7 +76,19 @@
|
| void DeviceOrientationDispatcher::didChangeDeviceOrientation(const blink::WebDeviceOrientationData& motion)
|
| {
|
| m_lastDeviceOrientationData = DeviceOrientationData::create(motion);
|
| - notifyControllers();
|
| +
|
| + {
|
| + TemporaryChange<bool> changeIsDispatching(m_isDispatching, true);
|
| + // Don't fire controllers removed or added during event dispatch.
|
| + 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()
|
|
|