Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1250)

Unified Diff: Source/modules/device_orientation/DeviceOrientationDispatcher.cpp

Issue 21256002: Fire null Device Motion events only once. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/device_orientation/DeviceOrientationDispatcher.cpp
diff --git a/Source/modules/device_orientation/DeviceOrientationDispatcher.cpp b/Source/modules/device_orientation/DeviceOrientationDispatcher.cpp
index b6989e95340be9c2898e92299d30ee579cfe7a56..b4836ed06f681216fa7a5bc7027bf8eb429b7623 100644
--- a/Source/modules/device_orientation/DeviceOrientationDispatcher.cpp
+++ b/Source/modules/device_orientation/DeviceOrientationDispatcher.cpp
@@ -69,20 +69,23 @@ void DeviceOrientationDispatcher::startListening()
void DeviceOrientationDispatcher::stopListening()
{
WebKit::Platform::current()->setDeviceOrientationListener(0);
+ m_lastDeviceOrientationData.clear();
}
void DeviceOrientationDispatcher::didChangeDeviceOrientation(const WebKit::WebDeviceOrientationData& motion)
{
m_lastDeviceOrientationData = DeviceOrientationData::create(motion);
- bool needsPurge = false;
- for (size_t i = 0; i < m_controllers.size(); ++i) {
+
+ m_isDispatching = true;
+ // Don't fire controllers removed or added during event dispatch.
+ size_t end = m_controllers.size();
+ for (size_t i = 0; i < end; ++i) {
if (m_controllers[i])
static_cast<NewDeviceOrientationController*>(m_controllers[i])->didChangeDeviceOrientation(m_lastDeviceOrientationData.get());
- else
- needsPurge = true;
}
+ m_isDispatching = false;
- if (needsPurge)
+ if (m_needsPurge)
purgeControllers();
}

Powered by Google App Engine
This is Rietveld 408576698