| Index: Source/modules/device_orientation/DeviceSensorEventController.cpp
|
| diff --git a/Source/modules/device_orientation/DeviceSensorEventController.cpp b/Source/modules/device_orientation/DeviceSensorEventController.cpp
|
| index fc5ae617122dcea135e2b236f3ea363db7443713..4b2efb308ed402c00ab611d592cc1795aa155f1a 100644
|
| --- a/Source/modules/device_orientation/DeviceSensorEventController.cpp
|
| +++ b/Source/modules/device_orientation/DeviceSensorEventController.cpp
|
| @@ -35,6 +35,7 @@ namespace WebCore {
|
| DeviceSensorEventController::DeviceSensorEventController(Document* document)
|
| : m_document(document)
|
| , m_isActive(false)
|
| + , m_needsCheckingNullEvents(true)
|
| , m_timer(this, &DeviceSensorEventController::fireDeviceEvent)
|
| {
|
| }
|
| @@ -60,6 +61,13 @@ void DeviceSensorEventController::dispatchDeviceEvent(PassRefPtr<Event> prpEvent
|
| && !m_document->activeDOMObjectsAreSuspended()
|
| && !m_document->activeDOMObjectsAreStopped())
|
| m_document->domWindow()->dispatchEvent(event);
|
| +
|
| + if (m_needsCheckingNullEvents) {
|
| + if (isNullEvent(event.get()))
|
| + stopUpdating();
|
| + else
|
| + m_needsCheckingNullEvents = false;
|
| + }
|
| }
|
|
|
| void DeviceSensorEventController::startUpdating()
|
| @@ -67,13 +75,13 @@ void DeviceSensorEventController::startUpdating()
|
| if (m_isActive)
|
| return;
|
|
|
| - registerWithDispatcher();
|
| - m_isActive = true;
|
| -
|
| if (hasLastData() && !m_timer.isActive()) {
|
| // Make sure to fire the device motion data as soon as possible.
|
| m_timer.startOneShot(0);
|
| }
|
| +
|
| + registerWithDispatcher();
|
| + m_isActive = true;
|
| }
|
|
|
| void DeviceSensorEventController::stopUpdating()
|
| @@ -81,6 +89,9 @@ void DeviceSensorEventController::stopUpdating()
|
| if (!m_isActive)
|
| return;
|
|
|
| + if (m_timer.isActive())
|
| + m_timer.stop();
|
| +
|
| unregisterWithDispatcher();
|
| m_isActive = false;
|
| }
|
|
|