mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Auto merge of #27235 - asajeffrey:webxr-sessionavailable, r=jdm
Add a sessionavailable event that allows content to enter an XR session without a user gesture <!-- Please describe your changes on the following line: --> This allows servo to implement immersive web apps. https://immersive-web.github.io/webxr/#application-launch --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes do not require tests because I'm not sure we should have a WPT for something this non-standard. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
commit
a77a1f7bf4
8 changed files with 68 additions and 1 deletions
|
@ -115,6 +115,7 @@ selectend
|
||||||
selectionchange
|
selectionchange
|
||||||
selectstart
|
selectstart
|
||||||
serif
|
serif
|
||||||
|
sessionavailable
|
||||||
signalingstatechange
|
signalingstatechange
|
||||||
squeeze
|
squeeze
|
||||||
squeezeend
|
squeezeend
|
||||||
|
|
|
@ -280,7 +280,8 @@ mod gen {
|
||||||
},
|
},
|
||||||
layers: {
|
layers: {
|
||||||
enabled: bool,
|
enabled: bool,
|
||||||
}
|
},
|
||||||
|
sessionavailable: bool,
|
||||||
},
|
},
|
||||||
worklet: {
|
worklet: {
|
||||||
blockingsleep: {
|
blockingsleep: {
|
||||||
|
|
|
@ -17,6 +17,7 @@ use crate::dom::bindings::codegen::Bindings::EventBinding::EventBinding::EventMe
|
||||||
use crate::dom::bindings::codegen::Bindings::HTMLIFrameElementBinding::HTMLIFrameElementBinding::HTMLIFrameElementMethods;
|
use crate::dom::bindings::codegen::Bindings::HTMLIFrameElementBinding::HTMLIFrameElementBinding::HTMLIFrameElementMethods;
|
||||||
use crate::dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods;
|
use crate::dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods;
|
||||||
use crate::dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTextAreaElementMethods;
|
use crate::dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTextAreaElementMethods;
|
||||||
|
use crate::dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorBinding::NavigatorMethods;
|
||||||
use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||||
use crate::dom::bindings::codegen::Bindings::NodeFilterBinding::NodeFilter;
|
use crate::dom::bindings::codegen::Bindings::NodeFilterBinding::NodeFilter;
|
||||||
use crate::dom::bindings::codegen::Bindings::PerformanceBinding::PerformanceMethods;
|
use crate::dom::bindings::codegen::Bindings::PerformanceBinding::PerformanceMethods;
|
||||||
|
@ -2267,6 +2268,17 @@ impl Document {
|
||||||
// Step 11.
|
// Step 11.
|
||||||
// TODO: ready for post-load tasks.
|
// TODO: ready for post-load tasks.
|
||||||
|
|
||||||
|
// The dom.webxr.sessionavailable pref allows webxr
|
||||||
|
// content to immediately begin a session without waiting for a user gesture.
|
||||||
|
// 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
|
||||||
|
if pref!(dom.webxr.sessionavailable) {
|
||||||
|
if self.window.is_top_level() {
|
||||||
|
self.window.Navigator().Xr().dispatch_sessionavailable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Step 12: completely loaded.
|
// Step 12: completely loaded.
|
||||||
// https://html.spec.whatwg.org/multipage/#completely-loaded
|
// https://html.spec.whatwg.org/multipage/#completely-loaded
|
||||||
// TODO: fully implement "completely loaded".
|
// TODO: fully implement "completely loaded".
|
||||||
|
|
|
@ -7,6 +7,7 @@ use crate::dom::bindings::codegen::Bindings::XRSystemBinding::XRSessionInit;
|
||||||
use crate::dom::bindings::codegen::Bindings::XRSystemBinding::{XRSessionMode, XRSystemMethods};
|
use crate::dom::bindings::codegen::Bindings::XRSystemBinding::{XRSessionMode, XRSystemMethods};
|
||||||
use crate::dom::bindings::conversions::{ConversionResult, FromJSValConvertible};
|
use crate::dom::bindings::conversions::{ConversionResult, FromJSValConvertible};
|
||||||
use crate::dom::bindings::error::Error;
|
use crate::dom::bindings::error::Error;
|
||||||
|
use crate::dom::bindings::inheritance::Castable;
|
||||||
use crate::dom::bindings::refcounted::{Trusted, TrustedPromise};
|
use crate::dom::bindings::refcounted::{Trusted, TrustedPromise};
|
||||||
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject};
|
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject};
|
||||||
use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom};
|
use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom};
|
||||||
|
@ -289,4 +290,26 @@ impl XRSystem {
|
||||||
// This must be called _after_ the promise is resolved
|
// This must be called _after_ the promise is resolved
|
||||||
session.setup_initial_inputs();
|
session.setup_initial_inputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/immersive-web/navigation/issues/10
|
||||||
|
pub fn dispatch_sessionavailable(&self) {
|
||||||
|
let xr = Trusted::new(self);
|
||||||
|
let global = self.global();
|
||||||
|
let window = global.as_window();
|
||||||
|
window
|
||||||
|
.task_manager()
|
||||||
|
.dom_manipulation_task_source()
|
||||||
|
.queue(
|
||||||
|
task!(fire_sessionavailable_event: move || {
|
||||||
|
// The sessionavailable event indicates user intent to enter an XR session
|
||||||
|
let xr = xr.root();
|
||||||
|
let interacting = ScriptThread::is_user_interacting();
|
||||||
|
ScriptThread::set_user_interacting(true);
|
||||||
|
xr.upcast::<EventTarget>().fire_bubbling_event(atom!("sessionavailable"));
|
||||||
|
ScriptThread::set_user_interacting(interacting);
|
||||||
|
}),
|
||||||
|
window.upcast(),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
"dom.webxr.glwindow.spherical": false,
|
"dom.webxr.glwindow.spherical": false,
|
||||||
"dom.webxr.hands.enabled": false,
|
"dom.webxr.hands.enabled": false,
|
||||||
"dom.webxr.layers.enabled": false,
|
"dom.webxr.layers.enabled": false,
|
||||||
|
"dom.webxr.sessionavailable": false,
|
||||||
"dom.webxr.test": false,
|
"dom.webxr.test": false,
|
||||||
"dom.worklet.timeout_ms": 10,
|
"dom.worklet.timeout_ms": 10,
|
||||||
"gfx.subpixel-text-antialiasing.enabled": true,
|
"gfx.subpixel-text-antialiasing.enabled": true,
|
||||||
|
|
|
@ -14731,6 +14731,13 @@
|
||||||
null,
|
null,
|
||||||
{}
|
{}
|
||||||
]
|
]
|
||||||
|
],
|
||||||
|
"sessionavailable.html": [
|
||||||
|
"dd9a071d05c4d696471be87428c12cea573cba60",
|
||||||
|
[
|
||||||
|
null,
|
||||||
|
{}
|
||||||
|
]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
tests/wpt/mozilla/meta/webxr/sessionavailable.html.ini
Normal file
2
tests/wpt/mozilla/meta/webxr/sessionavailable.html.ini
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
prefs: [dom.webxr.sessionavailable:true]
|
||||||
|
|
20
tests/wpt/mozilla/tests/webxr/sessionavailable.html
Normal file
20
tests/wpt/mozilla/tests/webxr/sessionavailable.html
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<body>
|
||||||
|
<script src=/resources/testharness.js></script>
|
||||||
|
<script src=/resources/testharnessreport.js></script>
|
||||||
|
<script src="./resources/webxr-util.js"></script>
|
||||||
|
<script>
|
||||||
|
navigator.xr.test.simulateDeviceConnection({
|
||||||
|
supportedModes: ["immersive-vr"],
|
||||||
|
views: TEST_VIEWS,
|
||||||
|
});
|
||||||
|
async_test((t) => {
|
||||||
|
navigator.xr.addEventListener("sessionavailable", (evt) => {
|
||||||
|
navigator.xr.requestSession("immersive-vr")
|
||||||
|
.then((session) => {
|
||||||
|
t.done();
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}, "Requesting immersive session in a sessionavailable handler should succeed");
|
||||||
|
</script>
|
||||||
|
</body>
|
Loading…
Add table
Add a link
Reference in a new issue