Bug 1835529 [wpt PR 40276] - Update wpt metadata, a=testonly
[gecko.git] / dom / webidl / WebXR.webidl
blob302c82156a0bc92df6eb6cd93fdb8dc1042055ae
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4  * You can obtain one at http://mozilla.org/MPL/2.0/.
5  *
6  * The origin of this IDL file is
7  * https://immersive-web.github.io/webxr/
8  */
11 [Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
12 interface XRSystem : EventTarget {
13   // Methods
14   [NewObject]
15   Promise<boolean> isSessionSupported(XRSessionMode mode);
16   [NewObject, NeedsCallerType]
17   Promise<XRSession> requestSession(XRSessionMode mode, optional XRSessionInit options = {});
19   // Events
20   attribute EventHandler ondevicechange;
23 enum XRSessionMode {
24   "inline",
25   "immersive-vr",
26   "immersive-ar",
29 dictionary XRSessionInit {
30   sequence<any> requiredFeatures;
31   sequence<any> optionalFeatures;
34 enum XRVisibilityState {
35   "visible",
36   "visible-blurred",
37   "hidden",
40 [Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
41 interface XRSession : EventTarget {
42   // Attributes
43   readonly attribute XRVisibilityState visibilityState;
44   [SameObject] readonly attribute XRRenderState renderState;
45   [SameObject] readonly attribute XRInputSourceArray inputSources;
46   readonly attribute float? frameRate;
47   readonly attribute Float32Array? supportedFrameRates;
49   // Methods
50   [Throws]
51   undefined updateRenderState(optional XRRenderStateInit state = {});
52   [NewObject]
53   Promise<XRReferenceSpace> requestReferenceSpace(XRReferenceSpaceType type);
54   [NewObject]
55   Promise<undefined> updateTargetFrameRate(float rate);
57   [Throws]
58   long requestAnimationFrame(XRFrameRequestCallback callback);
59   [Throws]
60   undefined cancelAnimationFrame(long handle);
62   [NewObject]
63   Promise<undefined> end();
65   // Events
66   attribute EventHandler onend;
67   attribute EventHandler oninputsourceschange;
68   attribute EventHandler onselect;
69   attribute EventHandler onselectstart;
70   attribute EventHandler onselectend;
71   attribute EventHandler onsqueeze;
72   attribute EventHandler onsqueezestart;
73   attribute EventHandler onsqueezeend;
74   attribute EventHandler onvisibilitychange;
77 dictionary XRRenderStateInit {
78   double depthNear;
79   double depthFar;
80   double inlineVerticalFieldOfView;
81   XRWebGLLayer? baseLayer;
84 [Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
85 interface XRRenderState {
86   readonly attribute double depthNear;
87   readonly attribute double depthFar;
88   readonly attribute double? inlineVerticalFieldOfView;
89   readonly attribute XRWebGLLayer? baseLayer;
92 callback XRFrameRequestCallback = undefined (DOMHighResTimeStamp time, XRFrame frame);
94 [ProbablyShortLivingWrapper, Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
95 interface XRFrame {
96   [SameObject] readonly attribute XRSession session;
98   [Throws] XRViewerPose? getViewerPose(XRReferenceSpace referenceSpace);
99   [Throws] XRPose? getPose(XRSpace space, XRSpace baseSpace);
102 [Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
103 interface XRSpace : EventTarget {
107 enum XRReferenceSpaceType {
108   "viewer",
109   "local",
110   "local-floor",
111   "bounded-floor",
112   "unbounded"
115 [Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
116 interface XRReferenceSpace : XRSpace {
117   [NewObject]
118   XRReferenceSpace getOffsetReferenceSpace(XRRigidTransform originOffset);
120   attribute EventHandler onreset;
123 [Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
124 interface XRBoundedReferenceSpace : XRReferenceSpace {
125   // TODO: Use FrozenArray once available. (Bug 1236777)
126   [Frozen, Cached, Pure]
127   readonly attribute sequence<DOMPointReadOnly> boundsGeometry;
130 enum XREye {
131   "none",
132   "left",
133   "right"
136 [ProbablyShortLivingWrapper, Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
137 interface XRView {
138   readonly attribute XREye eye;
139   [Throws]
140   readonly attribute Float32Array projectionMatrix;
141   [Throws, SameObject]
142   readonly attribute XRRigidTransform transform;
145 [ProbablyShortLivingWrapper, Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
146 interface XRViewport {
147   readonly attribute long x;
148   readonly attribute long y;
149   readonly attribute long width;
150   readonly attribute long height;
153 [ProbablyShortLivingWrapper, Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
154 interface XRRigidTransform {
155   [Throws]
156   constructor(optional DOMPointInit position = {}, optional DOMPointInit orientation = {});
157   [SameObject] readonly attribute DOMPointReadOnly position;
158   [SameObject] readonly attribute DOMPointReadOnly orientation;
159   [Throws]
160   readonly attribute Float32Array matrix;
161   [SameObject] readonly attribute XRRigidTransform inverse;
164 [ProbablyShortLivingWrapper, Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
165 interface XRPose {
166   [SameObject] readonly attribute XRRigidTransform transform;
167   readonly attribute boolean emulatedPosition;
170 [ProbablyShortLivingWrapper, Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
171 interface XRViewerPose : XRPose {
172   // TODO: Use FrozenArray once available. (Bug 1236777)
173   [Constant, Cached, Frozen]
174   readonly attribute sequence<XRView> views;
177 enum XRHandedness {
178   "none",
179   "left",
180   "right"
183 enum XRTargetRayMode {
184   "gaze",
185   "tracked-pointer",
186   "screen"
189 [Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
190 interface XRInputSource {
191   readonly attribute XRHandedness handedness;
192   readonly attribute XRTargetRayMode targetRayMode;
193   [SameObject] readonly attribute XRSpace targetRaySpace;
194   [SameObject] readonly attribute XRSpace? gripSpace;
195   // TODO: Use FrozenArray once available. (Bug 1236777)
196   [Constant, Cached, Frozen]
197   readonly attribute sequence<DOMString> profiles;
198   // https://immersive-web.github.io/webxr-gamepads-module/
199   [SameObject] readonly attribute Gamepad? gamepad;
203 [Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
204 interface XRInputSourceArray {
205   iterable<XRInputSource>;
206   readonly attribute unsigned long length;
207   getter XRInputSource(unsigned long index);
210 typedef (WebGLRenderingContext or
211          WebGL2RenderingContext) XRWebGLRenderingContext;
213 dictionary XRWebGLLayerInit {
214   boolean antialias = true;
215   boolean depth = true;
216   boolean stencil = false;
217   boolean alpha = true;
218   boolean ignoreDepthValues = false;
219   double framebufferScaleFactor = 1.0;
222 [Pref="dom.vr.webxr.enabled", SecureContext, Exposed=Window]
223 interface XRWebGLLayer {
224   [Throws]
225   constructor(XRSession session,
226               XRWebGLRenderingContext context,
227               optional XRWebGLLayerInit layerInit = {});
228   // Attributes
229   readonly attribute boolean antialias;
230   readonly attribute boolean ignoreDepthValues;
232   [SameObject] readonly attribute WebGLFramebuffer? framebuffer;
233   readonly attribute unsigned long framebufferWidth;
234   readonly attribute unsigned long framebufferHeight;
236   // Methods
237   XRViewport? getViewport(XRView view);
239   // Static Methods
240   static double getNativeFramebufferScaleFactor(XRSession session);