Diff
Modified: trunk/Source/WebCore/ChangeLog (253356 => 253357)
--- trunk/Source/WebCore/ChangeLog 2019-12-11 01:25:27 UTC (rev 253356)
+++ trunk/Source/WebCore/ChangeLog 2019-12-11 01:35:14 UTC (rev 253357)
@@ -1,5 +1,49 @@
2019-12-10 Per Arne Vollan <[email protected]>
+ [iOS] Calls to the device motion API should be done in the UI process
+ https://bugs.webkit.org/show_bug.cgi?id=204770
+
+ Reviewed by Brent Fulgham.
+
+ The device motion API on iOS is communicating with iohideventsystem. Since mach lookup to this daemon
+ will be closed, the calls to this API should be moved from the WebContent process to the UI process.
+ This patch implements forwarding of the device orientation requests to the UI process through the
+ class, DeviceOrientationUpdateProvider, which is subclassed by WebDeviceOrientationUpdateProvider in
+ modern WebKit. This class implements forwarding of the requests to the UI process, and receives
+ device orientation updates from the UI process. An instance of this class will be shared by all
+ device orientation clients on a page, and passed as part of the page configuration parameters. On
+ the UI process side, the class WebDeviceOrientationUpdateProviderProxy attached to the Web page
+ proxy is taking care of calling the device orientation API through the existing WebCoreMotionManager
+ Objective-C class, and send device orientation updates back to the Web process. Also, use a weak
+ hash set of clients in WebDeviceOrientationUpdateProvider.
+
+ No new tests, covered by existing tests.
+
+ * dom/Document.cpp:
+ * platform/ios/DeviceMotionClientIOS.h:
+ * platform/ios/DeviceMotionClientIOS.mm:
+ (WebCore::DeviceMotionClientIOS::DeviceMotionClientIOS):
+ (WebCore::DeviceMotionClientIOS::startUpdating):
+ (WebCore::DeviceMotionClientIOS::stopUpdating):
+ (WebCore::DeviceMotionClientIOS::deviceMotionControllerDestroyed):
+ * platform/ios/DeviceOrientationClientIOS.mm:
+ (WebCore::DeviceOrientationClientIOS::startUpdating):
+ (WebCore::DeviceOrientationClientIOS::stopUpdating):
+ (WebCore::DeviceOrientationClientIOS::deviceOrientationControllerDestroyed):
+ * platform/ios/DeviceOrientationUpdateProvider.h:
+ * platform/ios/MotionManagerClient.h:
+ (WebCore::MotionManagerClient::orientationChanged):
+ (WebCore::MotionManagerClient::motionChanged):
+ * platform/ios/WebCoreMotionManager.h:
+ * platform/ios/WebCoreMotionManager.mm:
+ (-[WebCoreMotionManager addMotionClient:]):
+ (-[WebCoreMotionManager removeMotionClient:]):
+ (-[WebCoreMotionManager checkClientStatus]):
+ (-[WebCoreMotionManager sendAccelerometerData:]):
+ (-[WebCoreMotionManager sendMotionData:withHeading:]):
+
+2019-12-10 Per Arne Vollan <[email protected]>
+
Make it possible to add regression tests for blocked XPC services
https://bugs.webkit.org/show_bug.cgi?id=204967
Modified: trunk/Source/WebCore/dom/Document.cpp (253356 => 253357)
--- trunk/Source/WebCore/dom/Document.cpp 2019-12-11 01:25:27 UTC (rev 253356)
+++ trunk/Source/WebCore/dom/Document.cpp 2019-12-11 01:35:14 UTC (rev 253357)
@@ -563,7 +563,7 @@
#endif
, m_loadEventDelayTimer(*this, &Document::loadEventDelayTimerFired)
#if PLATFORM(IOS_FAMILY) && ENABLE(DEVICE_ORIENTATION)
- , m_deviceMotionClient(makeUnique<DeviceMotionClientIOS>())
+ , m_deviceMotionClient(makeUnique<DeviceMotionClientIOS>(page() ? page()->deviceOrientationUpdateProvider() : nullptr))
, m_deviceMotionController(makeUnique<DeviceMotionController>(*m_deviceMotionClient))
, m_deviceOrientationClient(makeUnique<DeviceOrientationClientIOS>(page() ? page()->deviceOrientationUpdateProvider() : nullptr))
, m_deviceOrientationController(makeUnique<DeviceOrientationController>(*m_deviceOrientationClient))
Modified: trunk/Source/WebCore/platform/ios/DeviceMotionClientIOS.h (253356 => 253357)
--- trunk/Source/WebCore/platform/ios/DeviceMotionClientIOS.h 2019-12-11 01:25:27 UTC (rev 253356)
+++ trunk/Source/WebCore/platform/ios/DeviceMotionClientIOS.h 2019-12-11 01:35:14 UTC (rev 253357)
@@ -30,6 +30,8 @@
#include "DeviceMotionClient.h"
#include "DeviceMotionController.h"
#include "DeviceMotionData.h"
+#include "DeviceOrientationUpdateProvider.h"
+#include "MotionManagerClient.h"
#include <wtf/RefPtr.h>
OBJC_CLASS WebCoreMotionManager;
@@ -36,9 +38,9 @@
namespace WebCore {
-class DeviceMotionClientIOS : public DeviceMotionClient {
+class DeviceMotionClientIOS : public DeviceMotionClient, public MotionManagerClient {
public:
- DeviceMotionClientIOS();
+ DeviceMotionClientIOS(RefPtr<DeviceOrientationUpdateProvider>&&);
~DeviceMotionClientIOS() override;
void setController(DeviceMotionController*) override;
void startUpdating() override;
@@ -46,13 +48,14 @@
DeviceMotionData* lastMotion() const override;
void deviceMotionControllerDestroyed() override;
- void motionChanged(double, double, double, double, double, double, double, double, double);
+ void motionChanged(double, double, double, double, double, double, double, double, double) override;
private:
- WebCoreMotionManager* m_motionManager;
- DeviceMotionController* m_controller;
+ WebCoreMotionManager* m_motionManager { nullptr };
+ DeviceMotionController* m_controller { nullptr };
RefPtr<DeviceMotionData> m_currentDeviceMotionData;
- bool m_updating;
+ RefPtr<DeviceOrientationUpdateProvider> m_deviceOrientationUpdateProvider;
+ bool m_updating { false };
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/ios/DeviceMotionClientIOS.mm (253356 => 253357)
--- trunk/Source/WebCore/platform/ios/DeviceMotionClientIOS.mm 2019-12-11 01:25:27 UTC (rev 253356)
+++ trunk/Source/WebCore/platform/ios/DeviceMotionClientIOS.mm 2019-12-11 01:35:14 UTC (rev 253357)
@@ -33,10 +33,9 @@
namespace WebCore {
-DeviceMotionClientIOS::DeviceMotionClientIOS()
+DeviceMotionClientIOS::DeviceMotionClientIOS(RefPtr<DeviceOrientationUpdateProvider>&& deviceOrientationUpdateProvider)
: DeviceMotionClient()
- , m_motionManager(nullptr)
- , m_updating(0)
+ , m_deviceOrientationUpdateProvider(WTFMove(deviceOrientationUpdateProvider))
{
}
@@ -53,6 +52,11 @@
{
m_updating = true;
+ if (m_deviceOrientationUpdateProvider) {
+ m_deviceOrientationUpdateProvider->startUpdatingDeviceMotion(*this);
+ return;
+ }
+
if (!m_motionManager)
m_motionManager = [WebCoreMotionManager sharedManager];
@@ -63,6 +67,11 @@
{
m_updating = false;
+ if (m_deviceOrientationUpdateProvider) {
+ m_deviceOrientationUpdateProvider->stopUpdatingDeviceMotion(*this);
+ return;
+ }
+
// Remove ourselves as the motion client so we won't get updates.
[m_motionManager removeMotionClient:this];
}
@@ -74,6 +83,11 @@
void DeviceMotionClientIOS::deviceMotionControllerDestroyed()
{
+ if (m_deviceOrientationUpdateProvider) {
+ m_deviceOrientationUpdateProvider->stopUpdatingDeviceMotion(*this);
+ return;
+ }
+
[m_motionManager removeMotionClient:this];
}
Modified: trunk/Source/WebCore/platform/ios/DeviceOrientationClientIOS.mm (253356 => 253357)
--- trunk/Source/WebCore/platform/ios/DeviceOrientationClientIOS.mm 2019-12-11 01:25:27 UTC (rev 253356)
+++ trunk/Source/WebCore/platform/ios/DeviceOrientationClientIOS.mm 2019-12-11 01:35:14 UTC (rev 253357)
@@ -53,7 +53,7 @@
m_updating = true;
if (m_deviceOrientationUpdateProvider) {
- m_deviceOrientationUpdateProvider->startUpdating(*this);
+ m_deviceOrientationUpdateProvider->startUpdatingDeviceOrientation(*this);
return;
}
@@ -68,7 +68,7 @@
m_updating = false;
if (m_deviceOrientationUpdateProvider) {
- m_deviceOrientationUpdateProvider->stopUpdating(*this);
+ m_deviceOrientationUpdateProvider->stopUpdatingDeviceOrientation(*this);
return;
}
@@ -84,7 +84,7 @@
void DeviceOrientationClientIOS::deviceOrientationControllerDestroyed()
{
if (m_deviceOrientationUpdateProvider) {
- m_deviceOrientationUpdateProvider->stopUpdating(*this);
+ m_deviceOrientationUpdateProvider->stopUpdatingDeviceOrientation(*this);
return;
}
Modified: trunk/Source/WebCore/platform/ios/DeviceOrientationUpdateProvider.h (253356 => 253357)
--- trunk/Source/WebCore/platform/ios/DeviceOrientationUpdateProvider.h 2019-12-11 01:25:27 UTC (rev 253356)
+++ trunk/Source/WebCore/platform/ios/DeviceOrientationUpdateProvider.h 2019-12-11 01:35:14 UTC (rev 253357)
@@ -37,10 +37,14 @@
public:
virtual ~DeviceOrientationUpdateProvider() { }
- virtual void startUpdating(MotionManagerClient&) = 0;
- virtual void stopUpdating(MotionManagerClient&) = 0;
+ virtual void startUpdatingDeviceOrientation(MotionManagerClient&) = 0;
+ virtual void stopUpdatingDeviceOrientation(MotionManagerClient&) = 0;
+ virtual void startUpdatingDeviceMotion(MotionManagerClient&) = 0;
+ virtual void stopUpdatingDeviceMotion(MotionManagerClient&) = 0;
+
virtual void deviceOrientationChanged(double, double, double, double, double) = 0;
+ virtual void deviceMotionChanged(double, double, double, double, double, double, double, double, double) = 0;
protected:
DeviceOrientationUpdateProvider() = default;
Modified: trunk/Source/WebCore/platform/ios/MotionManagerClient.h (253356 => 253357)
--- trunk/Source/WebCore/platform/ios/MotionManagerClient.h 2019-12-11 01:25:27 UTC (rev 253356)
+++ trunk/Source/WebCore/platform/ios/MotionManagerClient.h 2019-12-11 01:35:14 UTC (rev 253357)
@@ -35,7 +35,8 @@
public:
virtual ~MotionManagerClient() { };
- virtual void orientationChanged(double, double, double, double, double) = 0;
+ virtual void orientationChanged(double, double, double, double, double) { }
+ virtual void motionChanged(double, double, double, double, double, double, double, double, double) { }
};
};
Modified: trunk/Source/WebCore/platform/ios/WebCoreMotionManager.h (253356 => 253357)
--- trunk/Source/WebCore/platform/ios/WebCoreMotionManager.h 2019-12-11 01:25:27 UTC (rev 253356)
+++ trunk/Source/WebCore/platform/ios/WebCoreMotionManager.h 2019-12-11 01:35:14 UTC (rev 253357)
@@ -43,7 +43,7 @@
WEBCORE_EXPORT @interface WebCoreMotionManager : NSObject {
CMMotionManager* m_motionManager;
CLLocationManager* m_locationManager;
- HashSet<WebCore::DeviceMotionClientIOS*> m_deviceMotionClients;
+ WeakHashSet<WebCore::MotionManagerClient> m_deviceMotionClients;
WeakHashSet<WebCore::MotionManagerClient> m_deviceOrientationClients;
NSTimer* m_updateTimer;
BOOL m_gyroAvailable;
@@ -52,8 +52,8 @@
}
+ (WebCoreMotionManager *)sharedManager;
-- (void)addMotionClient:(WebCore::DeviceMotionClientIOS *)client;
-- (void)removeMotionClient:(WebCore::DeviceMotionClientIOS *)client;
+- (void)addMotionClient:(WebCore::MotionManagerClient *)client;
+- (void)removeMotionClient:(WebCore::MotionManagerClient *)client;
- (void)addOrientationClient:(WebCore::MotionManagerClient *)client;
- (void)removeOrientationClient:(WebCore::MotionManagerClient *)client;
- (BOOL)gyroAvailable;
Modified: trunk/Source/WebCore/platform/ios/WebCoreMotionManager.mm (253356 => 253357)
--- trunk/Source/WebCore/platform/ios/WebCoreMotionManager.mm 2019-12-11 01:25:27 UTC (rev 253356)
+++ trunk/Source/WebCore/platform/ios/WebCoreMotionManager.mm 2019-12-11 01:35:14 UTC (rev 253357)
@@ -100,16 +100,16 @@
[super dealloc];
}
-- (void)addMotionClient:(WebCore::DeviceMotionClientIOS *)client
+- (void)addMotionClient:(WebCore::MotionManagerClient *)client
{
- m_deviceMotionClients.add(client);
+ m_deviceMotionClients.add(*client);
if (m_initialized)
[self checkClientStatus];
}
-- (void)removeMotionClient:(WebCore::DeviceMotionClientIOS *)client
+- (void)removeMotionClient:(WebCore::MotionManagerClient *)client
{
- m_deviceMotionClients.remove(client);
+ m_deviceMotionClients.remove(*client);
if (m_initialized)
[self checkClientStatus];
}
@@ -171,7 +171,7 @@
// be no chance that m_motionManager has not been created.
ASSERT(m_motionManager);
- if (m_deviceMotionClients.size() || m_deviceOrientationClients.computeSize()) {
+ if (m_deviceMotionClients.computeSize() || m_deviceOrientationClients.computeSize()) {
if (m_gyroAvailable)
[m_motionManager startDeviceMotionUpdates];
else
@@ -225,8 +225,15 @@
WebThreadRun(^{
CMAcceleration accel = newAcceleration.acceleration;
- for (auto& client : copyToVector(m_deviceMotionClients))
- client->motionChanged(0, 0, 0, accel.x * kGravity, accel.y * kGravity, accel.z * kGravity, 0, 0, 0);
+ Vector<WeakPtr<WebCore::MotionManagerClient>> motionClients;
+ motionClients.reserveInitialCapacity(m_deviceMotionClients.computeSize());
+ for (auto& client : m_deviceMotionClients)
+ motionClients.uncheckedAppend(makeWeakPtr(&client));
+
+ for (auto& client : motionClients) {
+ if (client)
+ client->motionChanged(0, 0, 0, accel.x * kGravity, accel.y * kGravity, accel.z * kGravity, 0, 0, 0);
+ }
});
}
@@ -243,8 +250,15 @@
CMRotationRate rotationRate = newMotion.rotationRate;
- for (auto& client : copyToVector(m_deviceMotionClients))
- client->motionChanged(userAccel.x * kGravity, userAccel.y * kGravity, userAccel.z * kGravity, totalAccel.x * kGravity, totalAccel.y * kGravity, totalAccel.z * kGravity, rad2deg(rotationRate.x), rad2deg(rotationRate.y), rad2deg(rotationRate.z));
+ Vector<WeakPtr<WebCore::MotionManagerClient>> motionClients;
+ motionClients.reserveInitialCapacity(m_deviceMotionClients.computeSize());
+ for (auto& client : m_deviceMotionClients)
+ motionClients.uncheckedAppend(makeWeakPtr(&client));
+
+ for (auto& client : motionClients) {
+ if (client)
+ client->motionChanged(userAccel.x * kGravity, userAccel.y * kGravity, userAccel.z * kGravity, totalAccel.x * kGravity, totalAccel.y * kGravity, totalAccel.z * kGravity, rad2deg(rotationRate.x), rad2deg(rotationRate.y), rad2deg(rotationRate.z));
+ }
CMAttitude* attitude = newMotion.attitude;
Modified: trunk/Source/WebKit/ChangeLog (253356 => 253357)
--- trunk/Source/WebKit/ChangeLog 2019-12-11 01:25:27 UTC (rev 253356)
+++ trunk/Source/WebKit/ChangeLog 2019-12-11 01:35:14 UTC (rev 253357)
@@ -1,3 +1,33 @@
+2019-12-10 Per Arne Vollan <[email protected]>
+
+ [iOS] Calls to the device motion API should be done in the UI process
+ https://bugs.webkit.org/show_bug.cgi?id=204770
+
+ Reviewed by Brent Fulgham.
+
+ The class WebDeviceOrientationUpdateProviderProxy will handle messages to start and stop updating device motion
+ in the UI process. Also, add a message to update the device motion in the WebContent process. In the UI process,
+ the device motion API is called through the already existing WebCoreMotionManager class.
+
+ * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
+ * UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.h:
+ * UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.messages.in:
+ * UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.mm:
+ (WebKit::WebDeviceOrientationUpdateProviderProxy::startUpdatingDeviceMotion):
+ (WebKit::WebDeviceOrientationUpdateProviderProxy::stopUpdatingDeviceMotion):
+ (WebKit::WebDeviceOrientationUpdateProviderProxy::motionChanged):
+ * WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.cpp:
+ (WebKit::WebDeviceOrientationUpdateProvider::startUpdatingDeviceOrientation):
+ (WebKit::WebDeviceOrientationUpdateProvider::stopUpdatingDeviceOrientation):
+ (WebKit::WebDeviceOrientationUpdateProvider::startUpdatingDeviceMotion):
+ (WebKit::WebDeviceOrientationUpdateProvider::stopUpdatingDeviceMotion):
+ (WebKit::WebDeviceOrientationUpdateProvider::deviceOrientationChanged):
+ (WebKit::WebDeviceOrientationUpdateProvider::deviceMotionChanged):
+ (WebKit::WebDeviceOrientationUpdateProvider::startUpdating): Deleted.
+ (WebKit::WebDeviceOrientationUpdateProvider::stopUpdating): Deleted.
+ * WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.h:
+ * WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.messages.in:
+
2019-12-10 Chris Dumez <[email protected]>
Unreviewed, drop debug assertion in InspectorTargetProxy::didCommitProvisionalTarget() that is hitting after r253337
Modified: trunk/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb (253356 => 253357)
--- trunk/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb 2019-12-11 01:25:27 UTC (rev 253356)
+++ trunk/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb 2019-12-11 01:35:14 UTC (rev 253357)
@@ -112,7 +112,7 @@
(iokit-user-client-class "AppleKeyStoreUserClient")))
(define-once (location-services)
- (allow mach-lookup
+ (allow mach-lookup (with report) (with telemetry)
(global-name "com.apple.locationd.registration"))
(allow-carrier-bundle) ;; <rdar://problem/21192365>
(mobile-preferences-read
Modified: trunk/Source/WebKit/UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.h (253356 => 253357)
--- trunk/Source/WebKit/UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.h 2019-12-11 01:25:27 UTC (rev 253356)
+++ trunk/Source/WebKit/UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.h 2019-12-11 01:35:14 UTC (rev 253357)
@@ -42,11 +42,15 @@
void startUpdatingDeviceOrientation();
void stopUpdatingDeviceOrientation();
-
+
+ void startUpdatingDeviceMotion();
+ void stopUpdatingDeviceMotion();
+
private:
// WebCore::WebCoreMotionManagerClient
void orientationChanged(double, double, double, double, double) final;
-
+ void motionChanged(double, double, double, double, double, double, double, double, double) final;
+
// IPC::MessageReceiver
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
Modified: trunk/Source/WebKit/UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.messages.in (253356 => 253357)
--- trunk/Source/WebKit/UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.messages.in 2019-12-11 01:25:27 UTC (rev 253356)
+++ trunk/Source/WebKit/UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.messages.in 2019-12-11 01:35:14 UTC (rev 253357)
@@ -24,5 +24,7 @@
messages -> WebDeviceOrientationUpdateProviderProxy NotRefCounted {
StartUpdatingDeviceOrientation();
StopUpdatingDeviceOrientation();
+ StartUpdatingDeviceMotion();
+ StopUpdatingDeviceMotion();
}
#endif
Modified: trunk/Source/WebKit/UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.mm (253356 => 253357)
--- trunk/Source/WebKit/UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.mm 2019-12-11 01:25:27 UTC (rev 253356)
+++ trunk/Source/WebKit/UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.mm 2019-12-11 01:35:14 UTC (rev 253357)
@@ -57,11 +57,26 @@
[[WebCoreMotionManager sharedManager] removeOrientationClient:this];
}
+void WebDeviceOrientationUpdateProviderProxy::startUpdatingDeviceMotion()
+{
+ [[WebCoreMotionManager sharedManager] addMotionClient:this];
+}
+
+void WebDeviceOrientationUpdateProviderProxy::stopUpdatingDeviceMotion()
+{
+ [[WebCoreMotionManager sharedManager] removeMotionClient:this];
+}
+
void WebDeviceOrientationUpdateProviderProxy::orientationChanged(double alpha, double beta, double gamma, double compassHeading, double compassAccuracy)
{
m_page.send(Messages::WebDeviceOrientationUpdateProvider::DeviceOrientationChanged(alpha, beta, gamma, compassHeading, compassAccuracy));
}
+void WebDeviceOrientationUpdateProviderProxy::motionChanged(double xAcceleration, double yAcceleration, double zAcceleration, double xAccelerationIncludingGravity, double yAccelerationIncludingGravity, double zAccelerationIncludingGravity, double xRotationRate, double yRotationRate, double zRotationRate)
+{
+ m_page.send(Messages::WebDeviceOrientationUpdateProvider::DeviceMotionChanged(xAcceleration, yAcceleration, zAcceleration, xAccelerationIncludingGravity, yAccelerationIncludingGravity, zAccelerationIncludingGravity, xRotationRate, yRotationRate, zRotationRate));
+}
+
} // namespace WebKit
#endif // PLATFORM(IOS_FAMILY)
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.cpp (253356 => 253357)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.cpp 2019-12-11 01:25:27 UTC (rev 253356)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.cpp 2019-12-11 01:35:14 UTC (rev 253357)
@@ -49,28 +49,62 @@
WebProcess::singleton().removeMessageReceiver(Messages::WebDeviceOrientationUpdateProvider::messageReceiverName(), m_pageIdentifier);
}
-void WebDeviceOrientationUpdateProvider::startUpdating(WebCore::MotionManagerClient& client)
+void WebDeviceOrientationUpdateProvider::startUpdatingDeviceOrientation(WebCore::MotionManagerClient& client)
{
- if (m_clients.isEmpty() && m_page)
+ if (m_deviceOrientationClients.computesEmpty() && m_page)
m_page->send(Messages::WebDeviceOrientationUpdateProviderProxy::StartUpdatingDeviceOrientation());
- m_clients.add(&client);
+ m_deviceOrientationClients.add(client);
}
-void WebDeviceOrientationUpdateProvider::stopUpdating(WebCore::MotionManagerClient& client)
+void WebDeviceOrientationUpdateProvider::stopUpdatingDeviceOrientation(WebCore::MotionManagerClient& client)
{
- if (m_clients.isEmpty())
+ if (m_deviceOrientationClients.computesEmpty())
return;
- m_clients.remove(&client);
- if (m_clients.isEmpty() && m_page)
+ m_deviceOrientationClients.remove(client);
+ if (m_deviceOrientationClients.computesEmpty() && m_page)
m_page->send(Messages::WebDeviceOrientationUpdateProviderProxy::StopUpdatingDeviceOrientation());
}
+void WebDeviceOrientationUpdateProvider::startUpdatingDeviceMotion(WebCore::MotionManagerClient& client)
+{
+ if (m_deviceMotionClients.computesEmpty() && m_page)
+ m_page->send(Messages::WebDeviceOrientationUpdateProviderProxy::StartUpdatingDeviceMotion());
+ m_deviceMotionClients.add(client);
+}
+
+void WebDeviceOrientationUpdateProvider::stopUpdatingDeviceMotion(WebCore::MotionManagerClient& client)
+{
+ if (m_deviceMotionClients.computesEmpty())
+ return;
+ m_deviceMotionClients.remove(client);
+ if (m_deviceMotionClients.computesEmpty() && m_page)
+ m_page->send(Messages::WebDeviceOrientationUpdateProviderProxy::StopUpdatingDeviceMotion());
+}
+
void WebDeviceOrientationUpdateProvider::deviceOrientationChanged(double alpha, double beta, double gamma, double compassHeading, double compassAccuracy)
{
- for (auto* client : copyToVector(m_clients))
- client->orientationChanged(alpha, beta, gamma, compassHeading, compassAccuracy);
+ Vector<WeakPtr<WebCore::MotionManagerClient>> clients;
+ for (auto& client : m_deviceOrientationClients)
+ clients.append(makeWeakPtr(&client));
+
+ for (auto& client : clients) {
+ if (client)
+ client->orientationChanged(alpha, beta, gamma, compassHeading, compassAccuracy);
+ }
}
+void WebDeviceOrientationUpdateProvider::deviceMotionChanged(double xAcceleration, double yAcceleration, double zAcceleration, double xAccelerationIncludingGravity, double yAccelerationIncludingGravity, double zAccelerationIncludingGravity, double xRotationRate, double yRotationRate, double zRotationRate)
+{
+ Vector<WeakPtr<WebCore::MotionManagerClient>> clients;
+ for (auto& client : m_deviceMotionClients)
+ clients.append(makeWeakPtr(&client));
+
+ for (auto& client : clients) {
+ if (client)
+ client->motionChanged(xAcceleration, yAcceleration, zAcceleration, xAccelerationIncludingGravity, yAccelerationIncludingGravity, zAccelerationIncludingGravity, xRotationRate, yRotationRate, zRotationRate);
+ }
}
+}
+
#endif // PLATFORM(IOS_FAMILY) && ENABLE(DEVICE_ORIENTATION)
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.h (253356 => 253357)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.h 2019-12-11 01:25:27 UTC (rev 253356)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.h 2019-12-11 01:35:14 UTC (rev 253357)
@@ -30,7 +30,7 @@
#include <WebCore/DeviceOrientationUpdateProvider.h>
-#include <wtf/HashSet.h>
+#include <wtf/WeakHashSet.h>
#include <wtf/WeakPtr.h>
#if PLATFORM(IOS_FAMILY) && ENABLE(DEVICE_ORIENTATION)
@@ -46,9 +46,12 @@
~WebDeviceOrientationUpdateProvider();
// WebCore::DeviceOrientationUpdateProvider
- void startUpdating(WebCore::MotionManagerClient&) final;
- void stopUpdating(WebCore::MotionManagerClient&) final;
+ void startUpdatingDeviceOrientation(WebCore::MotionManagerClient&) final;
+ void stopUpdatingDeviceOrientation(WebCore::MotionManagerClient&) final;
+ void startUpdatingDeviceMotion(WebCore::MotionManagerClient&) final;
+ void stopUpdatingDeviceMotion(WebCore::MotionManagerClient&) final;
void deviceOrientationChanged(double, double, double, double, double) final;
+ void deviceMotionChanged(double, double, double, double, double, double, double, double, double) final;
// IPC::MessageReceiver.
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
@@ -55,7 +58,8 @@
WeakPtr<WebPage> m_page;
WebCore::PageIdentifier m_pageIdentifier;
- HashSet<WebCore::MotionManagerClient*> m_clients;
+ WeakHashSet<WebCore::MotionManagerClient> m_deviceOrientationClients;
+ WeakHashSet<WebCore::MotionManagerClient> m_deviceMotionClients;
};
}
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.messages.in (253356 => 253357)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.messages.in 2019-12-11 01:25:27 UTC (rev 253356)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.messages.in 2019-12-11 01:35:14 UTC (rev 253357)
@@ -23,5 +23,6 @@
#if PLATFORM(IOS_FAMILY) && ENABLE(DEVICE_ORIENTATION)
messages -> WebDeviceOrientationUpdateProvider {
DeviceOrientationChanged(double alpha, double beta, double gamma, double compassHeading, double compassAccuracy)
+ DeviceMotionChanged(double xAcceleration, double yAcceleration, double zAcceleration, double xAccelerationIncludingGravity, double yAccelerationIncludingGravity, double zAccelerationIncludingGravity, double xRotationRate, double yRotationRate, double zRotationRate)
}
#endif