Title: [274821] trunk/Source/WebCore
- Revision
- 274821
- Author
- [email protected]
- Date
- 2021-03-22 17:05:29 -0700 (Mon, 22 Mar 2021)
Log Message
[WebXR] Enumerate XR devices via ChromeClient in WebXRSystem
https://bugs.webkit.org/show_bug.cgi?id=223520
Patch by Ada Chan <[email protected]> on 2021-03-22
Reviewed by Sam Weinig.
We want to avoid using singletons in the WebProcess and be able
to proxy the devices from the UI process.
* Modules/webxr/WebXRSystem.cpp:
(WebCore::WebXRSystem::ensureImmersiveXRDeviceIsSelected):
Instead of getting the devices from the singleton PlatformXR::Instance,
get them from the ChromeClient.
* WebCore.xcodeproj/project.pbxproj:
Mark PlatformXR.h private so it's visible to WebKit.
* page/ChromeClient.h:
(WebCore::ChromeClient::enumerateImmersiveXRDevices):
The default implementation will call PlatformXR::Instance::enumerateImmersiveXRDevices()
to keep current functionality.
* platform/xr/PlatformXR.h:
Export methods that are now called in ChromeClient.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (274820 => 274821)
--- trunk/Source/WebCore/ChangeLog 2021-03-23 00:02:52 UTC (rev 274820)
+++ trunk/Source/WebCore/ChangeLog 2021-03-23 00:05:29 UTC (rev 274821)
@@ -1,3 +1,26 @@
+2021-03-22 Ada Chan <[email protected]>
+
+ [WebXR] Enumerate XR devices via ChromeClient in WebXRSystem
+ https://bugs.webkit.org/show_bug.cgi?id=223520
+
+ Reviewed by Sam Weinig.
+
+ We want to avoid using singletons in the WebProcess and be able
+ to proxy the devices from the UI process.
+
+ * Modules/webxr/WebXRSystem.cpp:
+ (WebCore::WebXRSystem::ensureImmersiveXRDeviceIsSelected):
+ Instead of getting the devices from the singleton PlatformXR::Instance,
+ get them from the ChromeClient.
+ * WebCore.xcodeproj/project.pbxproj:
+ Mark PlatformXR.h private so it's visible to WebKit.
+ * page/ChromeClient.h:
+ (WebCore::ChromeClient::enumerateImmersiveXRDevices):
+ The default implementation will call PlatformXR::Instance::enumerateImmersiveXRDevices()
+ to keep current functionality.
+ * platform/xr/PlatformXR.h:
+ Export methods that are now called in ChromeClient.
+
2021-03-22 Eric Carlson <[email protected]>
AVAudioSessionCaptureDeviceManager should use crossThreadCopy
Modified: trunk/Source/WebCore/Headers.cmake (274820 => 274821)
--- trunk/Source/WebCore/Headers.cmake 2021-03-23 00:02:52 UTC (rev 274820)
+++ trunk/Source/WebCore/Headers.cmake 2021-03-23 00:05:29 UTC (rev 274821)
@@ -1476,6 +1476,8 @@
platform/text/UnicodeBidi.h
platform/text/WritingMode.h
+ platform/xr/PlatformXR.h
+
plugins/PluginData.h
plugins/PluginInfoProvider.h
plugins/PluginViewBase.h
Modified: trunk/Source/WebCore/Modules/webxr/WebXRSystem.cpp (274820 => 274821)
--- trunk/Source/WebCore/Modules/webxr/WebXRSystem.cpp 2021-03-23 00:02:52 UTC (rev 274820)
+++ trunk/Source/WebCore/Modules/webxr/WebXRSystem.cpp 2021-03-23 00:05:29 UTC (rev 274821)
@@ -28,6 +28,8 @@
#if ENABLE(WEBXR)
+#include "Chrome.h"
+#include "ChromeClient.h"
#include "DOMWindow.h"
#include "Document.h"
#include "FeaturePolicy.h"
@@ -34,6 +36,7 @@
#include "IDLTypes.h"
#include "JSWebXRSession.h"
#include "JSXRReferenceSpaceType.h"
+#include "Page.h"
#include "PlatformXR.h"
#include "RequestAnimationFrameCallback.h"
#include "RuntimeEnabledFeatures.h"
@@ -80,9 +83,14 @@
}
// https://immersive-web.github.io/webxr/#enumerate-immersive-xr-devices
- auto& platformXR = PlatformXR::Instance::singleton();
+ auto document = downcast<Document>(scriptExecutionContext());
+ if (!document || !document->page()) {
+ callback();
+ return;
+ }
+
bool isFirstXRDevicesEnumeration = !m_immersiveXRDevicesHaveBeenEnumerated;
- platformXR.enumerateImmersiveXRDevices([this, protectedThis = makeRef(*this), isFirstXRDevicesEnumeration, callback = WTFMove(callback)](auto& immersiveXRDevices) mutable {
+ document->page()->chrome().client().enumerateImmersiveXRDevices([this, protectedThis = makeRef(*this), isFirstXRDevicesEnumeration, callback = WTFMove(callback)](auto& immersiveXRDevices) mutable {
m_immersiveXRDevicesHaveBeenEnumerated = true;
auto callbackOnExit = makeScopeExit([&]() {
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (274820 => 274821)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-03-23 00:02:52 UTC (rev 274820)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-03-23 00:05:29 UTC (rev 274821)
@@ -5020,7 +5020,7 @@
E1E6EEA80B628DB3005F2F70 /* JSHTMLSelectElement.h in Headers */ = {isa = PBXBuildFile; fileRef = E1E6EEA70B628DB3005F2F70 /* JSHTMLSelectElement.h */; };
E1EC29A00BB04C6B00EA187B /* XPathNodeSet.h in Headers */ = {isa = PBXBuildFile; fileRef = E1EC299E0BB04C6B00EA187B /* XPathNodeSet.h */; settings = {ATTRIBUTES = (Private, ); }; };
E1ED8AC30CC49BE000BFC557 /* CSSPrimitiveValueMappings.h in Headers */ = {isa = PBXBuildFile; fileRef = E1ED8AC20CC49BE000BFC557 /* CSSPrimitiveValueMappings.h */; settings = {ATTRIBUTES = (Private, ); }; };
- E1EE8B722412B2A800E794D6 /* PlatformXR.h in Headers */ = {isa = PBXBuildFile; fileRef = E1EE8B6F2412B2A700E794D6 /* PlatformXR.h */; };
+ E1EE8B722412B2A800E794D6 /* PlatformXR.h in Headers */ = {isa = PBXBuildFile; fileRef = E1EE8B6F2412B2A700E794D6 /* PlatformXR.h */; settings = {ATTRIBUTES = (Private, ); }; };
E1EE8B762413191F00E794D6 /* WebXRViewerPose.h in Headers */ = {isa = PBXBuildFile; fileRef = E1EE8AC72412B16F00E794D6 /* WebXRViewerPose.h */; };
E1EE8B772413191F00E794D6 /* XRReferenceSpaceType.h in Headers */ = {isa = PBXBuildFile; fileRef = E1EE8AC92412B17000E794D6 /* XRReferenceSpaceType.h */; };
E1EE8B782413191F00E794D6 /* NavigatorWebXR.h in Headers */ = {isa = PBXBuildFile; fileRef = E1EE8ACA2412B17000E794D6 /* NavigatorWebXR.h */; };
Modified: trunk/Source/WebCore/page/ChromeClient.h (274820 => 274821)
--- trunk/Source/WebCore/page/ChromeClient.h 2021-03-23 00:02:52 UTC (rev 274820)
+++ trunk/Source/WebCore/page/ChromeClient.h 2021-03-23 00:05:29 UTC (rev 274821)
@@ -77,6 +77,10 @@
#include "MediaUsageInfo.h"
#endif
+#if ENABLE(WEBXR)
+#include "PlatformXR.h"
+#endif
+
OBJC_CLASS NSResponder;
namespace WebCore {
@@ -563,6 +567,10 @@
virtual void showMediaControlsContextMenu(FloatRect&&, Vector<MediaControlsContextMenuItem>&&, CompletionHandler<void(MediaControlsContextMenuItem::ID)>&& completionHandler) { completionHandler(MediaControlsContextMenuItem::invalidID); }
#endif // ENABLE(MEDIA_CONTROLS_CONTEXT_MENUS) && USE(UICONTEXTMENU)
+#if ENABLE(WEBXR)
+ virtual void enumerateImmersiveXRDevices(CompletionHandler<void(const PlatformXR::Instance::DeviceList&)>&& completionHandler) { PlatformXR::Instance::singleton().enumerateImmersiveXRDevices(WTFMove(completionHandler)); }
+#endif
+
protected:
virtual ~ChromeClient() = default;
};
Modified: trunk/Source/WebCore/platform/xr/PlatformXR.h (274820 => 274821)
--- trunk/Source/WebCore/platform/xr/PlatformXR.h 2021-03-23 00:02:52 UTC (rev 274820)
+++ trunk/Source/WebCore/platform/xr/PlatformXR.h 2021-03-23 00:05:29 UTC (rev 274821)
@@ -191,10 +191,10 @@
class Instance {
public:
- static Instance& singleton();
+ WEBCORE_EXPORT static Instance& singleton();
using DeviceList = Vector<Ref<Device>>;
- void enumerateImmersiveXRDevices(CompletionHandler<void(const DeviceList&)>&&);
+ WEBCORE_EXPORT void enumerateImmersiveXRDevices(CompletionHandler<void(const DeviceList&)>&&);
private:
friend LazyNeverDestroyed<Instance>;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes