Chromium Code Reviews| Index: Source/modules/device_orientation/DeviceMotionDispatcher.cpp |
| diff --git a/Source/modules/device_orientation/DeviceMotionDispatcher.cpp b/Source/modules/device_orientation/DeviceMotionDispatcher.cpp |
| index 93008e5ea33749e4a15f150af214e0fd173ed78f..8c1dc0c7a6e02d5cfd92eedce9ec194dac7630c3 100644 |
| --- a/Source/modules/device_orientation/DeviceMotionDispatcher.cpp |
| +++ b/Source/modules/device_orientation/DeviceMotionDispatcher.cpp |
| @@ -69,20 +69,23 @@ void DeviceMotionDispatcher::startListening() |
| void DeviceMotionDispatcher::stopListening() |
| { |
| WebKit::Platform::current()->setDeviceMotionListener(0); |
| + m_lastDeviceMotionData.clear(); |
| } |
| void DeviceMotionDispatcher::didChangeDeviceMotion(const WebKit::WebDeviceMotionData& motion) |
| { |
| m_lastDeviceMotionData = DeviceMotionData::create(motion); |
| - bool needsPurge = false; |
| - for (size_t i = 0; i < m_controllers.size(); ++i) { |
| + |
| + m_isDispatching = true; |
|
abarth-chromium
2013/07/31 00:56:19
Consider using TemporaryChange rather than manuall
timvolodine
2013/07/31 13:59:00
Done.
|
| + // Don't fire controllers removed or added during event dispatch. |
| + size_t end = m_controllers.size(); |
|
abarth-chromium
2013/07/31 00:56:19
end -> length or size
We use the term |end| to re
timvolodine
2013/07/31 13:59:00
changed to size.
Actually I was basing myself on E
|
| + for (size_t i = 0; i < end; ++i) { |
| if (m_controllers[i]) |
| static_cast<DeviceMotionController*>(m_controllers[i])->didChangeDeviceMotion(m_lastDeviceMotionData.get()); |
| - else |
| - needsPurge = true; |
| } |
| + m_isDispatching = false; |
| - if (needsPurge) |
| + if (m_needsPurge) |
| purgeControllers(); |
| } |