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:
Josh Matthews 2024-11-24 13:01:35 -05:00 committed by GitHub
parent e956f3124c
commit 3faed9b921
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
94 changed files with 206 additions and 53 deletions

View file

@ -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()))
}