Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 64 additions & 52 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,15 @@ The <dfn attribute for="XR">ondevicechange</dfn> attribute is an [=Event handler

<div class="algorithm" data-algorithm="supports-session">

When the <dfn method for="XR">supportsSession(|mode|)</dfn> method is invoked, it MUST return [=a new Promise=] |promise| and run the following steps [=in parallel=]:
When the <dfn method for="XR">supportsSession(|mode|)</dfn> method is invoked, it MUST run the following steps:

1. [=ensures an XR device is selected|Ensure an XR device is selected=].
1. If the [=XR/XR device=] is null, [=reject=] |promise| with a "{{NotSupportedError}}" {{DOMException}} and abort these steps.
1. If the [=XR/XR device=]'s [=list of supported modes=] does not [=list/contain=] |mode|, [=reject=] |promise| with a "{{NotSupportedError}}" {{DOMException}} and abort these steps.
1. [=/Resolve=] |promise|.
1. Let |promise| be [=a new Promise=]
1. Run the following steps [=in parallel=]:
1. [=ensures an XR device is selected|Ensure an XR device is selected=].
1. If the [=XR/XR device=] is null, [=reject=] |promise| with a "{{NotSupportedError}}" {{DOMException}} and abort these steps.
1. If the [=XR/XR device=]'s [=list of supported modes=] does not [=list/contain=] |mode|, [=reject=] |promise| with a "{{NotSupportedError}}" {{DOMException}} and abort these steps.
1. [=/Resolve=] |promise|.
1. Return |promise|.

</div>

Expand All @@ -301,36 +304,39 @@ The {{XR}} object has a <dfn>pending immersive session</dfn> boolean, which MUST

<div class="algorithm" data-algorithm="request-session">

When the <dfn method for="XR">requestSession(|mode|)</dfn> method is invoked, the user agent MUST return [=a new Promise=] |promise| and run the following steps [=in parallel=]:

1. Let |immersive| be <code>true</code> if |mode| is {{XRSessionMode/"immersive-vr"}} or {{XRSessionMode/"immersive-ar"}}, and <code>false</code> otherwise.
1. If |immersive| is <code>true</code>:
1. If the algorithm is not [=triggered by user activation=], [=reject=] |promise| with a "{{SecurityError}}" {{DOMException}} and abort these steps.
1. If [=pending immersive session=] is <code>true</code> or [=active immersive session=] is not <code>null</code>, [=reject=] |promise| with an "{{InvalidStateError}}" {{DOMException}} and abort these steps.
1. Set [=pending immersive session=] to be <code>true</code>.
1. [=ensures an XR device is selected|Ensure an XR device is selected=].
1. Follow the steps for the first matching conditions:
<dl class="switch">
<dt> If the [=XR/XR device=] is <code>null</code>
<dd> [=Reject=] |promise| with <code>null</code>.
<dt> If the [=XR/XR device=]'s [=list of supported modes=] does not [=list/contain=] |mode|
<dd> [=Reject=] |promise| with a "{{NotSupportedError}}" {{DOMException}}.
<dt> Otherwise
<dd> Continue to the next step.
</dl>
1. If |promise| was [=rejected=]:
1. If |immersive| is <code>true</code>, set [=pending immersive session=] to <code>false</code>.
1. Abort these steps.
1. Let |session| be a new {{XRSession}} object.
1. [=Initialize the session=] with |session| and |mode|.
1. Potentially set the [=active immersive session=] based on the following:
<dl class="switch">
<dt> If |immersive| is <code>true</code>
<dd> Set the [=active immersive session=] to |session|, and set [=pending immersive session=] to <code>false</code>.
<dt> Otherwise
<dd> Append |session| to the [=list of inline sessions=].
</dl>
1. [=/Resolve=] |promise| with |session|.
When the <dfn method for="XR">requestSession(|mode|)</dfn> method is invoked, the user agent MUST run the following steps:

1. Let |promise| be [=a new Promise=].
1. Run the following steps [=in parallel=]:
1. Let |immersive| be <code>true</code> if |mode| is {{XRSessionMode/"immersive-vr"}} or {{XRSessionMode/"immersive-ar"}}, and <code>false</code> otherwise.
1. If |immersive| is <code>true</code>:
1. If the algorithm is not [=triggered by user activation=], [=reject=] |promise| with a "{{SecurityError}}" {{DOMException}} and abort these steps.
1. If [=pending immersive session=] is <code>true</code> or [=active immersive session=] is not <code>null</code>, [=reject=] |promise| with an "{{InvalidStateError}}" {{DOMException}} and abort these steps.
1. Set [=pending immersive session=] to be <code>true</code>.
1. [=ensures an XR device is selected|Ensure an XR device is selected=].
1. Follow the steps for the first matching conditions:
<dl class="switch">
<dt> If the [=XR/XR device=] is <code>null</code>
<dd> [=Reject=] |promise| with <code>null</code>.
<dt> If the [=XR/XR device=]'s [=list of supported modes=] does not [=list/contain=] |mode|
<dd> [=Reject=] |promise| with a "{{NotSupportedError}}" {{DOMException}}.
<dt> Otherwise
<dd> Continue to the next step.
</dl>
1. If |promise| was [=rejected=]:
1. If |immersive| is <code>true</code>, set [=pending immersive session=] to <code>false</code>.
1. Abort these steps.
1. Let |session| be a new {{XRSession}} object.
1. [=Initialize the session=] with |session| and |mode|.
1. Potentially set the [=active immersive session=] based on the following:
<dl class="switch">
<dt> If |immersive| is <code>true</code>
<dd> Set the [=active immersive session=] to |session|, and set [=pending immersive session=] to <code>false</code>.
<dt> Otherwise
<dd> Append |session| to the [=list of inline sessions=].
</dl>
1. [=/Resolve=] |promise| with |session|.
1. Return |promise|.

</div>

Expand Down Expand Up @@ -503,11 +509,14 @@ When requested, the {{XRSession}} MUST <dfn>apply pending render states</dfn> by

<div class="algorithm" data-algorithm="request-reference-space">

When the <dfn method for="XRSession">requestReferenceSpace(|type|)</dfn> method is invoked, the user agent MUST return [=a new Promise=] |promise| and run the following steps [=in parallel=]:
When the <dfn method for="XRSession">requestReferenceSpace(|type|)</dfn> method is invoked, the user agent MUST run the following steps:

1. [=Create a reference space=], |referenceSpace|, with the {{XRReferenceSpaceType}} |type|.
1. If |referenceSpace| is <code>null</code>, [=reject=] |promise| with a {{NotSupportedError}} and abort these steps.
1. [=/Resolve=] |promise| with |referenceSpace|.
1. Let |promise| be [=a new Promise=].
1. Run the following steps [=in parallel=]:
1. [=Create a reference space=], |referenceSpace|, with the {{XRReferenceSpaceType}} |type|.
1. If |referenceSpace| is <code>null</code>, [=reject=] |promise| with a {{NotSupportedError}} and abort these steps.
1. [=/Resolve=] |promise| with |referenceSpace|.
1. Return |promise|.

</div>

Expand Down Expand Up @@ -1754,20 +1763,23 @@ To set the [=XR compatible=] boolean after the context has been created, the {{m

<div class="algorithm" data-algorithm="make-xr-compatible">

When the <dfn method for="WebGLRenderingContextBase">makeXRCompatible()</dfn> method is invoked, the user agent MUST return [=a new Promise=] |promise| and run the following steps [=in parallel=]:
When the <dfn method for="WebGLRenderingContextBase">makeXRCompatible()</dfn> method is invoked, the user agent MUST run the following steps:

1. Let |context| be the target {{WebGLRenderingContextBase}} object.
1. If |context|'s [=WebGL context lost flag=] is set, [=reject=] |promise| with an {{InvalidStateError}} and abort these abort these steps.
1. If |context|'s [=XR compatible=] boolean is <code>true</code>, [=/resolve=] |promise| and abort these steps.
1. If |context| was created on a [=compatible graphics adapter=] for the [=XR/XR device=]:
1. Set |context|'s [=XR compatible=] boolean to <code>true</code>.
1. [=/Resolve=] |promise| and abort these steps.
1. [=Queue a task=] to perform the following steps:
1. Force |context| to be lost and [=handle the context loss=] as described by the WebGL specification.
1. If the [=canceled flag=] of the "webglcontextlost" event fired in the previous step was not set, [=reject=] |promise| with an {{AbortError}} and abort these steps.
1. [=Restore the context=] on a [=compatible graphics adapter=] for the [=XR/XR device=].
1. Set |context|'s [=XR compatible=] boolean to <code>true</code>.
1. [=/Resolve=] |promise|.
1. Let |promise| be [=a new Promise=].
1. Run the following steps [=in parallel=]:
1. Let |context| be the target {{WebGLRenderingContextBase}} object.
1. If |context|'s [=WebGL context lost flag=] is set, [=reject=] |promise| with an {{InvalidStateError}} and abort these abort these steps.
1. If |context|'s [=XR compatible=] boolean is <code>true</code>, [=/resolve=] |promise| and abort these steps.
1. If |context| was created on a [=compatible graphics adapter=] for the [=XR/XR device=]:
1. Set |context|'s [=XR compatible=] boolean to <code>true</code>.
1. [=/Resolve=] |promise| and abort these steps.
1. [=Queue a task=] to perform the following steps:
1. Force |context| to be lost and [=handle the context loss=] as described by the WebGL specification.
1. If the [=canceled flag=] of the "webglcontextlost" event fired in the previous step was not set, [=reject=] |promise| with an {{AbortError}} and abort these steps.
1. [=Restore the context=] on a [=compatible graphics adapter=] for the [=XR/XR device=].
1. Set |context|'s [=XR compatible=] boolean to <code>true</code>.
1. [=/Resolve=] |promise|.
1. Return |promise|.

</div>

Expand Down