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..7eaf6971c8e46a62f43f8dd70553e8aac14b23f2 100644 |
--- a/Source/modules/device_orientation/DeviceOrientationController.cpp |
+++ b/Source/modules/device_orientation/DeviceOrientationController.cpp |
@@ -40,6 +40,7 @@ namespace WebCore { |
DeviceOrientationController::DeviceOrientationController(Document& document) |
: DeviceSensorEventController(document) |
, DOMWindowLifecycleObserver(document.domWindow()) |
+ , m_override(nullptr) |
timvolodine
2014/03/26 13:20:55
no need for this, it's initialized to 0 anyway by
dgozman
2014/03/26 13:51:58
Done.
|
{ |
} |
@@ -50,6 +51,8 @@ DeviceOrientationController::~DeviceOrientationController() |
void DeviceOrientationController::didChangeDeviceOrientation(DeviceOrientationData* deviceOrientationData) |
{ |
+ if (m_override) |
+ return; |
dispatchDeviceEvent(DeviceOrientationEvent::create(EventTypeNames::deviceorientation, deviceOrientationData)); |
} |
@@ -68,15 +71,19 @@ DeviceOrientationController& DeviceOrientationController::from(Document& documen |
return *controller; |
} |
+WebCore::DeviceOrientationData* DeviceOrientationController::lastData() |
timvolodine
2014/03/26 13:20:55
no need for WebCore:: prefix
also everywhere in th
dgozman
2014/03/26 13:51:58
Done.
|
+{ |
+ 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 +125,19 @@ void DeviceOrientationController::didRemoveAllEventListeners(DOMWindow* window) |
m_hasEventListener = false; |
} |
+void DeviceOrientationController::setOverride(WebCore::DeviceOrientationData* deviceOrientationData) |
+{ |
+ m_override = nullptr; |
aandrey
2014/03/25 19:59:44
FYI, maybe we should add:
if (m_override == device
timvolodine
2014/03/26 13:20:55
hmm not sure about this. you would be comparing po
timvolodine
2014/03/26 13:20:55
a more direct way would be: m_override.clear(), al
dgozman
2014/03/26 13:51:58
Done.
|
+ didChangeDeviceOrientation(deviceOrientationData); |
+ m_override = deviceOrientationData; |
+} |
+ |
+void DeviceOrientationController::clearOverride() |
+{ |
+ m_override = nullptr; |
aandrey
2014/03/25 19:59:44
FYI, maybe we should add:
if (!m_override)
ret
timvolodine
2014/03/26 13:20:55
+1
that way clearOverride would not interfere with
dgozman
2014/03/26 13:51:58
I agree. Done.
|
+ WebCore::DeviceOrientationData* orientation = lastData(); |
+ if (orientation) |
+ didChangeDeviceOrientation(orientation); |
+} |
+ |
} // namespace WebCore |