mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Filter out webidl files based on special comments, and feature-gate webxr interfaces. (#34348)
* Filter out webidl files based on skip-if directives. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Don't build XR functionality without webxr feature. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Fix tidy. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Adjust imports for file movement. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Fix clippy. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Formatting. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Clean up webxr module import. Co-authored-by: Samson <16504129+sagudev@users.noreply.github.com> Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net> Co-authored-by: Samson <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
parent
e956f3124c
commit
3faed9b921
94 changed files with 206 additions and 53 deletions
|
@ -20,6 +20,7 @@ tracing = ["dep:tracing"]
|
|||
webgl_backtrace = ["canvas_traits/webgl_backtrace"]
|
||||
js_backtrace = []
|
||||
refcell_backtrace = ["accountable-refcell"]
|
||||
webxr = ["webxr-api"]
|
||||
|
||||
[build-dependencies]
|
||||
phf_codegen = "0.11"
|
||||
|
@ -126,7 +127,7 @@ webdriver = { workspace = true }
|
|||
webgpu = { path = "../webgpu" }
|
||||
webrender_api = { workspace = true }
|
||||
webrender_traits = { workspace = true }
|
||||
webxr-api = { workspace = true, features = ["ipc"] }
|
||||
webxr-api = { workspace = true, features = ["ipc"], optional = true }
|
||||
xml5ever = { workspace = true }
|
||||
|
||||
[target.'cfg(not(target_os = "ios"))'.dependencies]
|
||||
|
|
|
@ -5,10 +5,13 @@
|
|||
import os
|
||||
import sys
|
||||
import json
|
||||
import re
|
||||
|
||||
SCRIPT_PATH = os.path.abspath(os.path.dirname(__file__))
|
||||
SERVO_ROOT = os.path.abspath(os.path.join(SCRIPT_PATH, "..", "..", "..", "..", ".."))
|
||||
|
||||
FILTER_PATTERN = re.compile("// skip-unless ([A-Z_]+)\n")
|
||||
|
||||
|
||||
def main():
|
||||
os.chdir(os.path.join(os.path.dirname(__file__)))
|
||||
|
@ -32,7 +35,14 @@ def main():
|
|||
for webidl in webidls:
|
||||
filename = os.path.join(webidls_dir, webidl)
|
||||
with open(filename, "r", encoding="utf-8") as f:
|
||||
parser.parse(f.read(), filename)
|
||||
contents = f.read()
|
||||
filter_match = FILTER_PATTERN.search(contents)
|
||||
if filter_match:
|
||||
env_var = filter_match.group(1)
|
||||
if not os.environ.get(env_var):
|
||||
continue
|
||||
|
||||
parser.parse(contents, filename)
|
||||
|
||||
add_css_properties_attributes(css_properties_json, parser)
|
||||
parser_results = parser.finish()
|
||||
|
|
|
@ -53,6 +53,7 @@ use style::stylesheet_set::{AuthorStylesheetSet, DocumentStylesheetSet};
|
|||
use tendril::fmt::UTF8;
|
||||
use tendril::stream::LossyDecoder;
|
||||
use tendril::TendrilSink;
|
||||
#[cfg(feature = "webxr")]
|
||||
use webxr_api::{Finger, Hand};
|
||||
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
|
@ -424,6 +425,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "webxr")]
|
||||
unsafe impl<J> CustomTraceable for Hand<J>
|
||||
where
|
||||
J: JSTraceable,
|
||||
|
@ -454,6 +456,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "webxr")]
|
||||
unsafe impl<J> CustomTraceable for Finger<J>
|
||||
where
|
||||
J: JSTraceable,
|
||||
|
|
|
@ -2538,6 +2538,7 @@ impl Document {
|
|||
// TODO: should this only happen on the first document loaded?
|
||||
// https://immersive-web.github.io/webxr/#user-intention
|
||||
// https://github.com/immersive-web/navigation/issues/10
|
||||
#[cfg(feature = "webxr")]
|
||||
if pref!(dom.webxr.sessionavailable) && self.window.is_top_level() {
|
||||
self.window.Navigator().Xr().dispatch_sessionavailable();
|
||||
}
|
||||
|
|
|
@ -308,8 +308,6 @@ pub mod eventsource;
|
|||
pub mod eventtarget;
|
||||
pub mod extendableevent;
|
||||
pub mod extendablemessageevent;
|
||||
pub mod fakexrdevice;
|
||||
pub mod fakexrinputcontroller;
|
||||
pub mod file;
|
||||
pub mod filelist;
|
||||
pub mod filereader;
|
||||
|
@ -614,6 +612,10 @@ pub mod webgluniformlocation;
|
|||
pub mod webglvertexarrayobject;
|
||||
pub mod webglvertexarrayobjectoes;
|
||||
pub mod websocket;
|
||||
#[cfg(feature = "webxr")]
|
||||
mod webxr;
|
||||
#[cfg(feature = "webxr")]
|
||||
pub use self::webxr::*;
|
||||
pub mod wheelevent;
|
||||
pub mod window;
|
||||
pub mod windowproxy;
|
||||
|
@ -628,42 +630,4 @@ pub mod xmlhttprequest;
|
|||
pub mod xmlhttprequesteventtarget;
|
||||
pub mod xmlhttprequestupload;
|
||||
pub mod xmlserializer;
|
||||
pub mod xrboundedreferencespace;
|
||||
pub mod xrcompositionlayer;
|
||||
pub mod xrcubelayer;
|
||||
pub mod xrcylinderlayer;
|
||||
pub mod xrequirectlayer;
|
||||
pub mod xrframe;
|
||||
pub mod xrhand;
|
||||
pub mod xrhittestresult;
|
||||
pub mod xrhittestsource;
|
||||
pub mod xrinputsource;
|
||||
pub mod xrinputsourcearray;
|
||||
pub mod xrinputsourceevent;
|
||||
pub mod xrinputsourceschangeevent;
|
||||
pub mod xrjointpose;
|
||||
pub mod xrjointspace;
|
||||
pub mod xrlayer;
|
||||
pub mod xrlayerevent;
|
||||
pub mod xrmediabinding;
|
||||
pub mod xrpose;
|
||||
pub mod xrprojectionlayer;
|
||||
pub mod xrquadlayer;
|
||||
pub mod xrray;
|
||||
pub mod xrreferencespace;
|
||||
pub mod xrreferencespaceevent;
|
||||
pub mod xrrenderstate;
|
||||
pub mod xrrigidtransform;
|
||||
pub mod xrsession;
|
||||
pub mod xrsessionevent;
|
||||
pub mod xrspace;
|
||||
pub mod xrsubimage;
|
||||
pub mod xrsystem;
|
||||
pub mod xrtest;
|
||||
pub mod xrview;
|
||||
pub mod xrviewerpose;
|
||||
pub mod xrviewport;
|
||||
pub mod xrwebglbinding;
|
||||
pub mod xrwebgllayer;
|
||||
pub mod xrwebglsubimage;
|
||||
pub use self::webgl_extensions::ext::*;
|
||||
|
|
|
@ -28,6 +28,7 @@ use crate::dom::permissions::Permissions;
|
|||
use crate::dom::pluginarray::PluginArray;
|
||||
use crate::dom::serviceworkercontainer::ServiceWorkerContainer;
|
||||
use crate::dom::window::Window;
|
||||
#[cfg(feature = "webxr")]
|
||||
use crate::dom::xrsystem::XRSystem;
|
||||
use crate::script_runtime::{CanGc, JSContext};
|
||||
|
||||
|
@ -44,6 +45,7 @@ pub struct Navigator {
|
|||
plugins: MutNullableDom<PluginArray>,
|
||||
mime_types: MutNullableDom<MimeTypeArray>,
|
||||
service_worker: MutNullableDom<ServiceWorkerContainer>,
|
||||
#[cfg(feature = "webxr")]
|
||||
xr: MutNullableDom<XRSystem>,
|
||||
mediadevices: MutNullableDom<MediaDevices>,
|
||||
/// <https://www.w3.org/TR/gamepad/#dfn-gamepads>
|
||||
|
@ -63,6 +65,7 @@ impl Navigator {
|
|||
plugins: Default::default(),
|
||||
mime_types: Default::default(),
|
||||
service_worker: Default::default(),
|
||||
#[cfg(feature = "webxr")]
|
||||
xr: Default::default(),
|
||||
mediadevices: Default::default(),
|
||||
gamepads: Default::default(),
|
||||
|
@ -77,6 +80,7 @@ impl Navigator {
|
|||
reflect_dom_object(Box::new(Navigator::new_inherited()), window)
|
||||
}
|
||||
|
||||
#[cfg(feature = "webxr")]
|
||||
pub fn xr(&self) -> Option<DomRoot<XRSystem>> {
|
||||
self.xr.get()
|
||||
}
|
||||
|
@ -250,6 +254,7 @@ impl NavigatorMethods<crate::DomTypeHolder> for Navigator {
|
|||
}
|
||||
|
||||
/// <https://immersive-web.github.io/webxr/#dom-navigator-xr>
|
||||
#[cfg(feature = "webxr")]
|
||||
fn Xr(&self) -> DomRoot<XRSystem> {
|
||||
self.xr.or_init(|| XRSystem::new(self.global().as_window()))
|
||||
}
|
||||
|
|
|
@ -4569,6 +4569,7 @@ impl WebGL2RenderingContextMethods<crate::DomTypeHolder> for WebGL2RenderingCont
|
|||
}
|
||||
|
||||
/// <https://immersive-web.github.io/webxr/#dom-webglrenderingcontextbase-makexrcompatible>
|
||||
#[cfg(feature = "webxr")]
|
||||
fn MakeXRCompatible(&self, can_gc: CanGc) -> Rc<Promise> {
|
||||
// XXXManishearth Fill in with compatibility checks when rust-webxr supports this
|
||||
let p = Promise::new(&self.global(), can_gc);
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#![allow(unused_imports)]
|
||||
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl
|
||||
use std::cell::Cell;
|
||||
|
||||
|
@ -11,6 +13,7 @@ use canvas_traits::webgl::{
|
|||
};
|
||||
use dom_struct::dom_struct;
|
||||
use euclid::Size2D;
|
||||
#[cfg(feature = "webxr")]
|
||||
use webxr_api::Viewport;
|
||||
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
|
@ -22,6 +25,7 @@ use crate::dom::webglobject::WebGLObject;
|
|||
use crate::dom::webglrenderbuffer::WebGLRenderbuffer;
|
||||
use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext};
|
||||
use crate::dom::webgltexture::WebGLTexture;
|
||||
#[cfg(feature = "webxr")]
|
||||
use crate::dom::xrsession::XRSession;
|
||||
|
||||
pub enum CompleteForRendering {
|
||||
|
@ -108,6 +112,7 @@ pub struct WebGLFramebuffer {
|
|||
is_initialized: Cell<bool>,
|
||||
// Framebuffers for XR keep a reference to the XR session.
|
||||
// https://github.com/immersive-web/webxr/issues/856
|
||||
#[cfg(feature = "webxr")]
|
||||
xr_session: MutNullableDom<XRSession>,
|
||||
}
|
||||
|
||||
|
@ -128,6 +133,7 @@ impl WebGLFramebuffer {
|
|||
color_read_buffer: DomRefCell::new(constants::COLOR_ATTACHMENT0),
|
||||
color_draw_buffers: DomRefCell::new(vec![constants::COLOR_ATTACHMENT0]),
|
||||
is_initialized: Cell::new(false),
|
||||
#[cfg(feature = "webxr")]
|
||||
xr_session: Default::default(),
|
||||
}
|
||||
}
|
||||
|
@ -142,6 +148,7 @@ impl WebGLFramebuffer {
|
|||
|
||||
// TODO: depth, stencil and alpha
|
||||
// https://github.com/servo/servo/issues/24498
|
||||
#[cfg(feature = "webxr")]
|
||||
pub fn maybe_new_webxr(
|
||||
session: &XRSession,
|
||||
context: &WebGLRenderingContext,
|
||||
|
@ -167,10 +174,16 @@ impl WebGLFramebuffer {
|
|||
self.id
|
||||
}
|
||||
|
||||
#[cfg(feature = "webxr")]
|
||||
fn is_in_xr_session(&self) -> bool {
|
||||
self.xr_session.get().is_some()
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "webxr"))]
|
||||
fn is_in_xr_session(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
pub fn validate_transparent(&self) -> WebGLResult<()> {
|
||||
if self.is_in_xr_session() {
|
||||
Err(WebGLError::InvalidOperation)
|
||||
|
@ -445,15 +458,16 @@ impl WebGLFramebuffer {
|
|||
pub fn check_status(&self) -> u32 {
|
||||
// For opaque framebuffers, check to see if the XR session is currently processing an rAF
|
||||
// https://immersive-web.github.io/webxr/#opaque-framebuffer
|
||||
#[cfg(feature = "webxr")]
|
||||
if let Some(xr_session) = self.xr_session.get() {
|
||||
if xr_session.is_outside_raf() {
|
||||
return if xr_session.is_outside_raf() {
|
||||
constants::FRAMEBUFFER_UNSUPPORTED
|
||||
} else {
|
||||
constants::FRAMEBUFFER_COMPLETE
|
||||
};
|
||||
}
|
||||
} else {
|
||||
|
||||
self.status.get()
|
||||
}
|
||||
// TODO: if a framebuffer has an attachment which is invalid due to
|
||||
// being outside a webxr rAF, should this make the framebuffer incomplete?
|
||||
// https://github.com/immersive-web/layers/issues/196
|
||||
|
@ -467,6 +481,7 @@ impl WebGLFramebuffer {
|
|||
|
||||
// XR framebuffers are complete inside an rAF
|
||||
// https://github.com/immersive-web/webxr/issues/854
|
||||
#[cfg(feature = "webxr")]
|
||||
if self.xr_session.get().is_some() {
|
||||
return CompleteForRendering::Complete;
|
||||
}
|
||||
|
|
|
@ -4796,6 +4796,7 @@ impl WebGLRenderingContextMethods<crate::DomTypeHolder> for WebGLRenderingContex
|
|||
}
|
||||
|
||||
/// <https://immersive-web.github.io/webxr/#dom-webglrenderingcontextbase-makexrcompatible>
|
||||
#[cfg(feature = "webxr")]
|
||||
fn MakeXRCompatible(&self, can_gc: CanGc) -> Rc<Promise> {
|
||||
// XXXManishearth Fill in with compatibility checks when rust-webxr supports this
|
||||
let p = Promise::new(&self.global(), can_gc);
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#![allow(unused_imports)]
|
||||
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl
|
||||
|
||||
use std::cell::Cell;
|
||||
|
@ -23,6 +25,7 @@ use crate::dom::webgl_validations::types::TexImageTarget;
|
|||
use crate::dom::webglframebuffer::WebGLFramebuffer;
|
||||
use crate::dom::webglobject::WebGLObject;
|
||||
use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext};
|
||||
#[cfg(feature = "webxr")]
|
||||
use crate::dom::xrsession::XRSession;
|
||||
|
||||
pub enum TexParameterValue {
|
||||
|
@ -37,6 +40,7 @@ pub enum TexParameterValue {
|
|||
#[derive(JSTraceable, MallocSizeOf)]
|
||||
enum WebGLTextureOwner {
|
||||
WebGL,
|
||||
#[cfg(feature = "webxr")]
|
||||
WebXR(Dom<XRSession>),
|
||||
}
|
||||
|
||||
|
@ -71,16 +75,19 @@ impl WebGLTexture {
|
|||
fn new_inherited(
|
||||
context: &WebGLRenderingContext,
|
||||
id: WebGLTextureId,
|
||||
owner: Option<&XRSession>,
|
||||
#[cfg(feature = "webxr")] owner: Option<&XRSession>,
|
||||
) -> Self {
|
||||
Self {
|
||||
webgl_object: WebGLObject::new_inherited(context),
|
||||
id,
|
||||
target: Cell::new(None),
|
||||
is_deleted: Cell::new(false),
|
||||
#[cfg(feature = "webxr")]
|
||||
owner: owner
|
||||
.map(|session| WebGLTextureOwner::WebXR(Dom::from_ref(session)))
|
||||
.unwrap_or(WebGLTextureOwner::WebGL),
|
||||
#[cfg(not(feature = "webxr"))]
|
||||
owner: WebGLTextureOwner::WebGL,
|
||||
immutable_levels: Cell::new(None),
|
||||
face_count: Cell::new(0),
|
||||
base_mipmap_level: 0,
|
||||
|
@ -102,11 +109,17 @@ impl WebGLTexture {
|
|||
|
||||
pub fn new(context: &WebGLRenderingContext, id: WebGLTextureId) -> DomRoot<Self> {
|
||||
reflect_dom_object(
|
||||
Box::new(WebGLTexture::new_inherited(context, id, None)),
|
||||
Box::new(WebGLTexture::new_inherited(
|
||||
context,
|
||||
id,
|
||||
#[cfg(feature = "webxr")]
|
||||
None,
|
||||
)),
|
||||
&*context.global(),
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(feature = "webxr")]
|
||||
pub fn new_webxr(
|
||||
context: &WebGLRenderingContext,
|
||||
id: WebGLTextureId,
|
||||
|
@ -238,6 +251,7 @@ impl WebGLTexture {
|
|||
}
|
||||
|
||||
// We don't delete textures owned by WebXR
|
||||
#[cfg(feature = "webxr")]
|
||||
if let WebGLTextureOwner::WebXR(_) = self.owner {
|
||||
return;
|
||||
}
|
||||
|
@ -252,6 +266,7 @@ impl WebGLTexture {
|
|||
|
||||
pub fn is_invalid(&self) -> bool {
|
||||
// https://immersive-web.github.io/layers/#xrwebglsubimagetype
|
||||
#[cfg(feature = "webxr")]
|
||||
if let WebGLTextureOwner::WebXR(ref session) = self.owner {
|
||||
if session.is_outside_raf() {
|
||||
return true;
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://github.com/immersive-web/webxr-test-api/
|
||||
|
||||
[Exposed=Window, Pref="dom.webxr.test"]
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/webxr-test-api/#fakexrinputcontroller
|
||||
|
||||
[Exposed=Window, Pref="dom.webxr.test"]
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrboundedreferencespace-interface
|
||||
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// TODO: Implement the layer types
|
||||
// https://github.com/servo/servo/issues/27493
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// TODO: Implement the layer types
|
||||
// https://github.com/servo/servo/issues/27493
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// TODO: Implement the layer types
|
||||
// https://github.com/servo/servo/issues/27493
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// TODO: Implement the layer types
|
||||
// https://github.com/servo/servo/issues/27493
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrframe-interface
|
||||
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://github.com/immersive-web/webxr-hands-input/blob/master/explainer.md
|
||||
|
||||
enum XRHandJoint {
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/hit-test/#xrhittestresult-interface
|
||||
|
||||
[SecureContext, Exposed=Window]
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/hit-test/#xrhittestsource-interface
|
||||
|
||||
enum XRHitTestTrackableType {
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrinputsource-interface
|
||||
|
||||
enum XRHandedness {
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrinputsourcearray-interface
|
||||
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrinputsourceevent-interface
|
||||
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrinputsourceschangedevent-interface
|
||||
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.test"]
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://github.com/immersive-web/webxr-hands-input/blob/master/explainer.md
|
||||
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.hands.enabled"]
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://github.com/immersive-web/webxr-hands-input/blob/master/explainer.md
|
||||
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.hands.enabled"]
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrlayer
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
interface XRLayer : EventTarget {};
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/layers/#xrlayerevent-interface
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.layers.enabled"]
|
||||
interface XRLayerEvent : Event {
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/layers/#xrmediabindingtype
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.layers.enabled"]
|
||||
interface XRMediaBinding {
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrpose-interface
|
||||
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// TODO: Implement the layer types
|
||||
// https://github.com/servo/servo/issues/27493
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// TODO: Implement the layer types
|
||||
// https://github.com/servo/servo/issues/27493
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/hit-test/#xrray-interface
|
||||
|
||||
dictionary XRRayDirectionInit {
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrreferencespace-interface
|
||||
|
||||
enum XRReferenceSpaceType {
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrreferencespaceevent-interface
|
||||
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrrenderstate-interface
|
||||
|
||||
dictionary XRRenderStateInit {
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrrigidtransform-interface
|
||||
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrsession-interface
|
||||
|
||||
enum XREnvironmentBlendMode {
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrsessionevent-interface
|
||||
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrspace-interface
|
||||
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/layers/#xrsubimagetype
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.layers.enabled"]
|
||||
interface XRSubImage {
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrsystem-interface
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
interface XRSystem: EventTarget {
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://github.com/immersive-web/webxr-test-api/
|
||||
|
||||
[Exposed=Window, Pref="dom.webxr.test"]
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrview-interface
|
||||
|
||||
enum XREye {
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrviewerpose-interface
|
||||
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrviewport-interface
|
||||
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/layers/#XRWebGLBindingtype
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.layers.enabled"]
|
||||
interface XRWebGLBinding {
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/webxr/#xrwebgllayer-interface
|
||||
|
||||
typedef (WebGLRenderingContext or
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// skip-unless CARGO_FEATURE_WEBXR
|
||||
|
||||
// https://immersive-web.github.io/layers/#xrwebglsubimagetype
|
||||
[SecureContext, Exposed=Window, Pref="dom.webxr.layers.enabled"]
|
||||
interface XRWebGLSubImage : XRSubImage {
|
||||
|
|
44
components/script/dom/webxr/mod.rs
Normal file
44
components/script/dom/webxr/mod.rs
Normal file
|
@ -0,0 +1,44 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
pub mod fakexrdevice;
|
||||
pub mod fakexrinputcontroller;
|
||||
pub mod xrboundedreferencespace;
|
||||
pub mod xrcompositionlayer;
|
||||
pub mod xrcubelayer;
|
||||
pub mod xrcylinderlayer;
|
||||
pub mod xrequirectlayer;
|
||||
pub mod xrframe;
|
||||
pub mod xrhand;
|
||||
pub mod xrhittestresult;
|
||||
pub mod xrhittestsource;
|
||||
pub mod xrinputsource;
|
||||
pub mod xrinputsourcearray;
|
||||
pub mod xrinputsourceevent;
|
||||
pub mod xrinputsourceschangeevent;
|
||||
pub mod xrjointpose;
|
||||
pub mod xrjointspace;
|
||||
pub mod xrlayer;
|
||||
pub mod xrlayerevent;
|
||||
pub mod xrmediabinding;
|
||||
pub mod xrpose;
|
||||
pub mod xrprojectionlayer;
|
||||
pub mod xrquadlayer;
|
||||
pub mod xrray;
|
||||
pub mod xrreferencespace;
|
||||
pub mod xrreferencespaceevent;
|
||||
pub mod xrrenderstate;
|
||||
pub mod xrrigidtransform;
|
||||
pub mod xrsession;
|
||||
pub mod xrsessionevent;
|
||||
pub mod xrspace;
|
||||
pub mod xrsubimage;
|
||||
pub mod xrsystem;
|
||||
pub mod xrtest;
|
||||
pub mod xrview;
|
||||
pub mod xrviewerpose;
|
||||
pub mod xrviewport;
|
||||
pub mod xrwebglbinding;
|
||||
pub mod xrwebgllayer;
|
||||
pub mod xrwebglsubimage;
|
|
@ -8,7 +8,7 @@ use js::rust::HandleObject;
|
|||
use js::typedarray::{Float32, Float32Array};
|
||||
use webxr_api::{ApiSpace, Ray};
|
||||
|
||||
use super::bindings::buffer_source::HeapBufferSource;
|
||||
use crate::dom::bindings::buffer_source::HeapBufferSource;
|
||||
use crate::dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit;
|
||||
use crate::dom::bindings::codegen::Bindings::XRRayBinding::{XRRayDirectionInit, XRRayMethods};
|
||||
use crate::dom::bindings::error::{Error, Fallible};
|
|
@ -7,7 +7,7 @@ use euclid::{RigidTransform3D, Rotation3D, Vector3D};
|
|||
use js::rust::HandleObject;
|
||||
use js::typedarray::{Float32, Float32Array};
|
||||
|
||||
use super::bindings::buffer_source::HeapBufferSource;
|
||||
use crate::dom::bindings::buffer_source::HeapBufferSource;
|
||||
use crate::dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit;
|
||||
use crate::dom::bindings::codegen::Bindings::XRRigidTransformBinding::XRRigidTransformMethods;
|
||||
use crate::dom::bindings::error::{Error, Fallible};
|
|
@ -24,7 +24,7 @@ use webxr_api::{
|
|||
SelectEvent, SelectKind, Session, SessionId, View, Viewer, Visibility,
|
||||
};
|
||||
|
||||
use super::bindings::trace::HashMapTracedValues;
|
||||
use crate::dom::bindings::trace::HashMapTracedValues;
|
||||
use crate::dom::bindings::buffer_source::create_buffer_source;
|
||||
use crate::dom::bindings::callback::ExceptionHandling;
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
|
@ -9,7 +9,7 @@ use euclid::RigidTransform3D;
|
|||
use js::typedarray::{Float32, Float32Array};
|
||||
use webxr_api::{ApiSpace, View};
|
||||
|
||||
use super::bindings::buffer_source::HeapBufferSource;
|
||||
use crate::dom::bindings::buffer_source::HeapBufferSource;
|
||||
use crate::dom::bindings::codegen::Bindings::XRViewBinding::{XREye, XRViewMethods};
|
||||
use crate::dom::bindings::num::Finite;
|
||||
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
|
|
@ -287,6 +287,7 @@ pub struct Window {
|
|||
|
||||
#[ignore_malloc_size_of = "defined in webxr"]
|
||||
#[no_trace]
|
||||
#[cfg(feature = "webxr")]
|
||||
webxr_registry: Option<webxr_api::Registry>,
|
||||
|
||||
/// All of the elements that have an outstanding image request that was
|
||||
|
@ -495,6 +496,7 @@ impl Window {
|
|||
.map(|chan| WebGLCommandSender::new(chan.clone()))
|
||||
}
|
||||
|
||||
#[cfg(feature = "webxr")]
|
||||
pub fn webxr_registry(&self) -> Option<webxr_api::Registry> {
|
||||
self.webxr_registry.clone()
|
||||
}
|
||||
|
@ -2545,6 +2547,7 @@ impl Window {
|
|||
self.webrender_document
|
||||
}
|
||||
|
||||
#[cfg(feature = "webxr")]
|
||||
pub fn in_immersive_xr_session(&self) -> bool {
|
||||
self.navigator
|
||||
.get()
|
||||
|
@ -2552,6 +2555,11 @@ impl Window {
|
|||
.and_then(|nav| nav.xr())
|
||||
.is_some_and(|xr| xr.pending_or_active_session())
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "webxr"))]
|
||||
pub fn in_immersive_xr_session(&self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
impl Window {
|
||||
|
@ -2579,7 +2587,7 @@ impl Window {
|
|||
creator_url: ServoUrl,
|
||||
navigation_start: CrossProcessInstant,
|
||||
webgl_chan: Option<WebGLChan>,
|
||||
webxr_registry: Option<webxr_api::Registry>,
|
||||
#[cfg(feature = "webxr")] webxr_registry: Option<webxr_api::Registry>,
|
||||
microtask_queue: Rc<MicrotaskQueue>,
|
||||
webrender_document: DocumentId,
|
||||
compositor_api: CrossProcessCompositorApi,
|
||||
|
@ -2661,6 +2669,7 @@ impl Window {
|
|||
media_query_lists: DOMTracker::new(),
|
||||
test_runner: Default::default(),
|
||||
webgl_chan,
|
||||
#[cfg(feature = "webxr")]
|
||||
webxr_registry,
|
||||
pending_layout_images: Default::default(),
|
||||
unminified_css_dir: Default::default(),
|
||||
|
|
|
@ -670,6 +670,7 @@ pub struct ScriptThread {
|
|||
|
||||
/// The WebXR device registry
|
||||
#[no_trace]
|
||||
#[cfg(feature = "webxr")]
|
||||
webxr_registry: Option<webxr_api::Registry>,
|
||||
|
||||
/// The worklet thread pool
|
||||
|
@ -1329,6 +1330,7 @@ impl ScriptThread {
|
|||
system_font_service,
|
||||
|
||||
webgl_chan: state.webgl_chan,
|
||||
#[cfg(feature = "webxr")]
|
||||
webxr_registry: state.webxr_registry,
|
||||
|
||||
worklet_thread_pool: Default::default(),
|
||||
|
@ -3751,6 +3753,7 @@ impl ScriptThread {
|
|||
final_url.clone(),
|
||||
incomplete.navigation_start,
|
||||
self.webgl_chan.as_ref().map(|chan| chan.channel()),
|
||||
#[cfg(feature = "webxr")]
|
||||
self.webxr_registry.clone(),
|
||||
self.microtask_queue.clone(),
|
||||
self.webrender_document,
|
||||
|
|
|
@ -37,6 +37,7 @@ webxr = [
|
|||
"compositing/webxr",
|
||||
"embedder_traits/webxr",
|
||||
"canvas/webxr",
|
||||
"script/webxr",
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue