From 9b7d70905fb781f2efc0bad85230713fbc4d2af2 Mon Sep 17 00:00:00 2001 From: Klaus Weidner Date: Fri, 4 Oct 2019 10:44:01 -0700 Subject: [PATCH] WebXR: experimental DOM Overlay support for immersive-ar mode This opt-in mode keeps DOM content visible as a transparent overlay while in an immersive-ar WebXR session. It is activated by requesting an optional or required feature on session start: navigator.xr.requestSession( 'immersive-ar', {optionalFeatures: ['dom-overlay-for-handheld-ar']}); This functionality is only available if the corresponding feature flag chrome://flags#webxr-ar-dom-overlay is enabled. On session start, this fullscreens the element. The application can use the Fullscreen API to change the visible element. Exiting the session ends fullscreen mode, and calling document.exitFullscreen() exits the immersive-ar session if there are no remaining fullscreened elements. (As of this CL, changing the fullscreen element doesn't fully update layer visibility, so non-fullscreen content can remain visible unexpectedly. That's being addressed in a followup.) Change-Id: I77b767b111436b45e2b584e46a390a68473ab118 Bug: 991747 --- resources/chromium/webxr-test.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/resources/chromium/webxr-test.js b/resources/chromium/webxr-test.js index ccb7a008b8563ee..94031657b4b6d26 100644 --- a/resources/chromium/webxr-test.js +++ b/resources/chromium/webxr-test.js @@ -187,6 +187,15 @@ class MockVRService { // Implements XRFrameDataProvider and XRPresentationProvider. Maintains a mock // for XRPresentationProvider. class MockRuntime { + // Mapping from string feature names to the corresponding mojo types. + // This is exposed as a member for extensibility. + static featureToMojoMap = { + "viewer": device.mojom.XRSessionFeature.REF_SPACE_VIEWER, + "local": device.mojom.XRSessionFeature.REF_SPACE_LOCAL, + "local-floor": device.mojom.XRSessionFeature.REF_SPACE_LOCAL_FLOOR, + "bounded-floor": device.mojom.XRSessionFeature.REF_SPACE_BOUNDED_FLOOR, + "unbounded": device.mojom.XRSessionFeature.REF_SPACE_UNBOUNDED }; + constructor(fakeDeviceInit, service) { this.sessionClient_ = new device.mojom.XRSessionClientPtr(); this.presentation_provider_ = new MockXRPresentationProvider(); @@ -456,19 +465,10 @@ class MockRuntime { setFeatures(supportedFeatures) { function convertFeatureToMojom(feature) { - switch (feature) { - case "viewer": - return device.mojom.XRSessionFeature.REF_SPACE_VIEWER; - case "local": - return device.mojom.XRSessionFeature.REF_SPACE_LOCAL; - case "local-floor": - return device.mojom.XRSessionFeature.REF_SPACE_LOCAL_FLOOR; - case "bounded-floor": - return device.mojom.XRSessionFeature.REF_SPACE_BOUNDED_FLOOR; - case "unbounded": - return device.mojom.XRSessionFeature.REF_SPACE_UNBOUNDED; - default: - return device.mojom.XRSessionFeature.INVALID; + if (feature in MockRuntime.featureToMojoMap) { + return MockRuntime.featureToMojoMap[feature]; + } else { + return device.mojom.XRSessionFeature.INVALID; } }