diff options
Diffstat (limited to 'Source/WebCore/dom/DeviceOrientationController.cpp')
-rw-r--r-- | Source/WebCore/dom/DeviceOrientationController.cpp | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/Source/WebCore/dom/DeviceOrientationController.cpp b/Source/WebCore/dom/DeviceOrientationController.cpp index 952676652..396bf8cf4 100644 --- a/Source/WebCore/dom/DeviceOrientationController.cpp +++ b/Source/WebCore/dom/DeviceOrientationController.cpp @@ -30,26 +30,27 @@ #include "DeviceOrientationClient.h" #include "DeviceOrientationData.h" #include "DeviceOrientationEvent.h" -#include "InspectorInstrumentation.h" +#include "Page.h" namespace WebCore { -DeviceOrientationController::DeviceOrientationController(Page* page, DeviceOrientationClient* client) +DeviceOrientationController::DeviceOrientationController(DeviceOrientationClient* client) : DeviceController(client) - , m_page(page) { +#if PLATFORM(IOS) + // FIXME: Temporarily avoid asserting while OpenSource is using a different design. + // We should reconcile the differences between OpenSource and iOS so that we can + // remove this code path. + if (m_client) + deviceOrientationClient()->setController(this); +#else ASSERT(m_client); deviceOrientationClient()->setController(this); -} - -PassOwnPtr<DeviceOrientationController> DeviceOrientationController::create(Page* page, DeviceOrientationClient* client) -{ - return adoptPtr(new DeviceOrientationController(page, client)); +#endif } void DeviceOrientationController::didChangeDeviceOrientation(DeviceOrientationData* orientation) { - orientation = InspectorInstrumentation::overrideDeviceOrientation(m_page, orientation); dispatchDeviceEvent(DeviceOrientationEvent::create(eventNames().deviceorientationEvent, orientation)); } @@ -58,15 +59,31 @@ DeviceOrientationClient* DeviceOrientationController::deviceOrientationClient() return static_cast<DeviceOrientationClient*>(m_client); } +#if PLATFORM(IOS) +// FIXME: We should look to reconcile the iOS and OpenSource differences with this class +// so that we can either remove these methods or remove the PLATFORM(IOS)-guard. +void DeviceOrientationController::suspendUpdates() +{ + if (m_client) + m_client->stopUpdating(); +} + +void DeviceOrientationController::resumeUpdates() +{ + if (m_client && !m_listeners.isEmpty()) + m_client->startUpdating(); +} +#else bool DeviceOrientationController::hasLastData() { return deviceOrientationClient()->lastOrientation(); } -PassRefPtr<Event> DeviceOrientationController::getLastEvent() +RefPtr<Event> DeviceOrientationController::getLastEvent() { return DeviceOrientationEvent::create(eventNames().deviceorientationEvent, deviceOrientationClient()->lastOrientation()); } +#endif // PLATFORM(IOS) const char* DeviceOrientationController::supplementName() { @@ -87,7 +104,7 @@ bool DeviceOrientationController::isActiveAt(Page* page) void provideDeviceOrientationTo(Page* page, DeviceOrientationClient* client) { - DeviceOrientationController::provideTo(page, DeviceOrientationController::supplementName(), DeviceOrientationController::create(page, client)); + DeviceOrientationController::provideTo(page, DeviceOrientationController::supplementName(), std::make_unique<DeviceOrientationController>(client)); } } // namespace WebCore |