Chromium Code Reviews| Index: Source/modules/device_orientation/DeviceOrientationController.cpp |
| diff --git a/Source/modules/device_orientation/DeviceOrientationController.cpp b/Source/modules/device_orientation/DeviceOrientationController.cpp |
| index 9f51237b891e64c4c9941accd72c3e085529ccf7..bfc65e61925e43b139c361b9d84cbc52dac98bb2 100644 |
| --- a/Source/modules/device_orientation/DeviceOrientationController.cpp |
| +++ b/Source/modules/device_orientation/DeviceOrientationController.cpp |
| @@ -40,6 +40,8 @@ namespace WebCore { |
| DeviceOrientationController::DeviceOrientationController(Document& document) |
| : DeviceSensorEventController(document) |
| , DOMWindowLifecycleObserver(document.domWindow()) |
| + , m_lastOrientation(nullptr) |
| + , m_override(nullptr) |
| { |
| } |
| @@ -50,6 +52,10 @@ DeviceOrientationController::~DeviceOrientationController() |
| void DeviceOrientationController::didChangeDeviceOrientation(DeviceOrientationData* deviceOrientationData) |
| { |
| + if (m_override) { |
| + m_lastOrientation = deviceOrientationData; |
| + return; |
|
timvolodine
2014/03/25 15:06:33
hmm so I guess we don't fire overrides at regular
dgozman
2014/03/25 17:50:30
Done.
|
| + } |
| dispatchDeviceEvent(DeviceOrientationEvent::create(EventTypeNames::deviceorientation, deviceOrientationData)); |
| } |
| @@ -68,15 +74,19 @@ DeviceOrientationController& DeviceOrientationController::from(Document& documen |
| return *controller; |
| } |
| +WebCore::DeviceOrientationData* DeviceOrientationController::lastData() |
| +{ |
| + return m_override ? m_override.get() : DeviceOrientationDispatcher::instance().latestDeviceOrientationData(); |
| +} |
| + |
| bool DeviceOrientationController::hasLastData() |
| { |
| - return DeviceOrientationDispatcher::instance().latestDeviceOrientationData(); |
| + return lastData(); |
| } |
| PassRefPtr<Event> DeviceOrientationController::getLastEvent() |
| { |
| - return DeviceOrientationEvent::create(EventTypeNames::deviceorientation, |
| - DeviceOrientationDispatcher::instance().latestDeviceOrientationData()); |
| + return DeviceOrientationEvent::create(EventTypeNames::deviceorientation, lastData()); |
| } |
| void DeviceOrientationController::registerWithDispatcher() |
| @@ -118,4 +128,21 @@ void DeviceOrientationController::didRemoveAllEventListeners(DOMWindow* window) |
| m_hasEventListener = false; |
| } |
| +void DeviceOrientationController::setOverride(WebCore::DeviceOrientationData* deviceOrientationData) |
| +{ |
| + if (!m_override) |
| + m_lastOrientation = DeviceOrientationDispatcher::instance().latestDeviceOrientationData(); |
| + m_override = nullptr; |
| + didChangeDeviceOrientation(deviceOrientationData); |
| + m_override = deviceOrientationData; |
| +} |
| + |
| +void DeviceOrientationController::clearOverride() |
| +{ |
| + m_override = nullptr; |
| + if (m_lastOrientation) |
|
timvolodine
2014/03/25 15:06:33
could you use lastData() here instead of m_lastOri
dgozman
2014/03/25 17:50:30
Done.
|
| + didChangeDeviceOrientation(m_lastOrientation.get()); |
| + m_lastOrientation = nullptr; |
| +} |
| + |
| } // namespace WebCore |