Skip to content

Commit

Permalink
WebXR: experimental DOM Overlay support for immersive-ar mode
Browse files Browse the repository at this point in the history
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 <body> 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
  • Loading branch information
klausw authored and chromium-wpt-export-bot committed Oct 4, 2019
1 parent f4483de commit 9b7d709
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions resources/chromium/webxr-test.js
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 9b7d709

Please sign in to comment.