diff options
author | Konstantin Tokarev <annulen@yandex.ru> | 2016-08-25 19:20:41 +0300 |
---|---|---|
committer | Konstantin Tokarev <annulen@yandex.ru> | 2017-02-02 12:30:55 +0000 |
commit | 6882a04fb36642862b11efe514251d32070c3d65 (patch) | |
tree | b7959826000b061fd5ccc7512035c7478742f7b0 /Source/WebCore/dom/DeviceOrientationController.cpp | |
parent | ab6df191029eeeb0b0f16f127d553265659f739e (diff) | |
download | qtwebkit-6882a04fb36642862b11efe514251d32070c3d65.tar.gz |
Imported QtWebKit TP3 (git b57bc6801f1876c3220d5a4bfea33d620d477443)
Change-Id: I3b1d8a2808782c9f34d50240000e20cb38d3680f
Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
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 |