aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/webxr/xrinputsource.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2025-05-02 16:10:26 -0400
committerGitHub <noreply@github.com>2025-05-02 20:10:26 +0000
commitb8971e528f6ed9affb7e8aaaea17b8fc0b929af7 (patch)
treedcd0ebf1295223a70b5b9a80b78e4a5f67620ae8 /components/script/dom/webxr/xrinputsource.rs
parent80d3e138a88473826b580423410944ba854e8ca4 (diff)
downloadservo-b8971e528f6ed9affb7e8aaaea17b8fc0b929af7.tar.gz
servo-b8971e528f6ed9affb7e8aaaea17b8fc0b929af7.zip
script: Move Window-only gamepad functionality out of GlobalScope (#36805)
The only code that calls these methods is in the script thread, and the code is simpler when we can assume a Window global. Pulling this thread led to cleaning up a lot of constructors for Window-only WebXR code, too. Testing: Existing WPT coverage. --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Diffstat (limited to 'components/script/dom/webxr/xrinputsource.rs')
-rw-r--r--components/script/dom/webxr/xrinputsource.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/components/script/dom/webxr/xrinputsource.rs b/components/script/dom/webxr/xrinputsource.rs
index 009b210646a..e454e785424 100644
--- a/components/script/dom/webxr/xrinputsource.rs
+++ b/components/script/dom/webxr/xrinputsource.rs
@@ -17,6 +17,7 @@ use crate::dom::bindings::reflector::{DomGlobal, Reflector, reflect_dom_object};
use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom};
use crate::dom::gamepad::Gamepad;
use crate::dom::globalscope::GlobalScope;
+use crate::dom::window::Window;
use crate::dom::xrhand::XRHand;
use crate::dom::xrsession::XRSession;
use crate::dom::xrspace::XRSpace;
@@ -40,14 +41,14 @@ pub(crate) struct XRInputSource {
impl XRInputSource {
pub(crate) fn new_inherited(
- global: &GlobalScope,
+ window: &Window,
session: &XRSession,
info: InputSource,
can_gc: CanGc,
) -> XRInputSource {
// <https://www.w3.org/TR/webxr-gamepads-module-1/#gamepad-differences>
let gamepad = Gamepad::new(
- global,
+ window,
0,
"".into(),
"xr-standard".into(),
@@ -74,18 +75,18 @@ impl XRInputSource {
#[allow(unsafe_code)]
pub(crate) fn new(
- global: &GlobalScope,
+ window: &Window,
session: &XRSession,
info: InputSource,
can_gc: CanGc,
) -> DomRoot<XRInputSource> {
let source = reflect_dom_object(
- Box::new(XRInputSource::new_inherited(global, session, info, can_gc)),
- global,
+ Box::new(XRInputSource::new_inherited(window, session, info, can_gc)),
+ window,
can_gc,
);
- let _ac = enter_realm(global);
+ let _ac = enter_realm(window);
let cx = GlobalScope::get_cx();
unsafe {
rooted!(in(*cx) let mut profiles = UndefinedValue());