mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Support profiles
This commit is contained in:
parent
9c34a6585b
commit
e0135fe783
10 changed files with 40 additions and 17 deletions
|
@ -205,13 +205,16 @@ impl FakeXRDeviceMethods for FakeXRDevice {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
// XXXManishearth deal with profiles, supportedButtons, selection*
|
let profiles = init.profiles.iter().cloned().map(String::from).collect();
|
||||||
|
|
||||||
|
// XXXManishearth deal with supportedButtons and selection*
|
||||||
|
|
||||||
let source = InputSource {
|
let source = InputSource {
|
||||||
handedness,
|
handedness,
|
||||||
target_ray_mode,
|
target_ray_mode,
|
||||||
id,
|
id,
|
||||||
supports_grip: true,
|
supports_grip: true,
|
||||||
|
profiles,
|
||||||
};
|
};
|
||||||
|
|
||||||
let init = MockInputInit {
|
let init = MockInputInit {
|
||||||
|
|
|
@ -12,6 +12,7 @@ use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding::{
|
||||||
use crate::dom::bindings::error::Fallible;
|
use crate::dom::bindings::error::Fallible;
|
||||||
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
|
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
|
||||||
use crate::dom::bindings::root::DomRoot;
|
use crate::dom::bindings::root::DomRoot;
|
||||||
|
use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::fakexrdevice::get_origin;
|
use crate::dom::fakexrdevice::get_origin;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
@ -128,4 +129,10 @@ impl FakeXRInputControllerMethods for FakeXRInputController {
|
||||||
};
|
};
|
||||||
let _ = self.send_message(MockInputMsg::SetTargetRayMode(t));
|
let _ = self.send_message(MockInputMsg::SetTargetRayMode(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// https://immersive-web.github.io/webxr-test-api/#dom-fakexrinputcontroller-setprofiles
|
||||||
|
fn SetProfiles(&self, profiles: Vec<DOMString>) {
|
||||||
|
let t = profiles.into_iter().map(String::from).collect();
|
||||||
|
let _ = self.send_message(MockInputMsg::SetProfiles(t));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
interface FakeXRInputController {
|
interface FakeXRInputController {
|
||||||
void setHandedness(XRHandedness handedness);
|
void setHandedness(XRHandedness handedness);
|
||||||
void setTargetRayMode(XRTargetRayMode targetRayMode);
|
void setTargetRayMode(XRTargetRayMode targetRayMode);
|
||||||
// void setProfiles(sequence<DOMString> profiles);
|
void setProfiles(sequence<DOMString> profiles);
|
||||||
[Throws] void setGripOrigin(FakeXRRigidTransformInit gripOrigin, optional boolean emulatedPosition = false);
|
[Throws] void setGripOrigin(FakeXRRigidTransformInit gripOrigin, optional boolean emulatedPosition = false);
|
||||||
void clearGripOrigin();
|
void clearGripOrigin();
|
||||||
[Throws] void setPointerOrigin(FakeXRRigidTransformInit pointerOrigin, optional boolean emulatedPosition = false);
|
[Throws] void setPointerOrigin(FakeXRRigidTransformInit pointerOrigin, optional boolean emulatedPosition = false);
|
||||||
|
|
|
@ -23,4 +23,5 @@ interface XRInputSource {
|
||||||
[SameObject] readonly attribute XRSpace targetRaySpace;
|
[SameObject] readonly attribute XRSpace targetRaySpace;
|
||||||
[SameObject] readonly attribute XRSpace? gripSpace;
|
[SameObject] readonly attribute XRSpace? gripSpace;
|
||||||
// [SameObject] readonly attribute Gamepad? gamepad;
|
// [SameObject] readonly attribute Gamepad? gamepad;
|
||||||
|
/* [SameObject] */ readonly attribute /* FrozenArray<DOMString> */ any profiles;
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
use crate::compartments::enter_realm;
|
||||||
use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding;
|
use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding;
|
||||||
use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding::{
|
use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding::{
|
||||||
XRHandedness, XRInputSourceMethods, XRTargetRayMode,
|
XRHandedness, XRInputSourceMethods, XRTargetRayMode,
|
||||||
|
@ -11,7 +12,11 @@ use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom};
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::xrsession::XRSession;
|
use crate::dom::xrsession::XRSession;
|
||||||
use crate::dom::xrspace::XRSpace;
|
use crate::dom::xrspace::XRSpace;
|
||||||
|
use crate::script_runtime::JSContext;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
use js::conversions::ToJSValConvertible;
|
||||||
|
use js::jsapi::Heap;
|
||||||
|
use js::jsval::{JSVal, UndefinedValue};
|
||||||
use webxr_api::{Handedness, InputId, InputSource, TargetRayMode};
|
use webxr_api::{Handedness, InputId, InputSource, TargetRayMode};
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -24,6 +29,8 @@ pub struct XRInputSource {
|
||||||
target_ray_space: MutNullableDom<XRSpace>,
|
target_ray_space: MutNullableDom<XRSpace>,
|
||||||
#[ignore_malloc_size_of = "Defined in rust-webxr"]
|
#[ignore_malloc_size_of = "Defined in rust-webxr"]
|
||||||
grip_space: MutNullableDom<XRSpace>,
|
grip_space: MutNullableDom<XRSpace>,
|
||||||
|
#[ignore_malloc_size_of = "mozjs"]
|
||||||
|
profiles: Heap<JSVal>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl XRInputSource {
|
impl XRInputSource {
|
||||||
|
@ -34,19 +41,30 @@ impl XRInputSource {
|
||||||
info,
|
info,
|
||||||
target_ray_space: Default::default(),
|
target_ray_space: Default::default(),
|
||||||
grip_space: Default::default(),
|
grip_space: Default::default(),
|
||||||
|
profiles: Heap::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unsafe_code)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
session: &XRSession,
|
session: &XRSession,
|
||||||
info: InputSource,
|
info: InputSource,
|
||||||
) -> DomRoot<XRInputSource> {
|
) -> DomRoot<XRInputSource> {
|
||||||
reflect_dom_object(
|
let source = reflect_dom_object(
|
||||||
Box::new(XRInputSource::new_inherited(session, info)),
|
Box::new(XRInputSource::new_inherited(session, info)),
|
||||||
global,
|
global,
|
||||||
XRInputSourceBinding::Wrap,
|
XRInputSourceBinding::Wrap,
|
||||||
)
|
);
|
||||||
|
|
||||||
|
let _ac = enter_realm(&*global);
|
||||||
|
let cx = global.get_cx();
|
||||||
|
unsafe {
|
||||||
|
rooted!(in(*cx) let mut profiles = UndefinedValue());
|
||||||
|
source.info.profiles.to_jsval(*cx, profiles.handle_mut());
|
||||||
|
source.profiles.set(profiles.get());
|
||||||
|
}
|
||||||
|
source
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn id(&self) -> InputId {
|
pub fn id(&self) -> InputId {
|
||||||
|
@ -92,4 +110,8 @@ impl XRInputSourceMethods for XRInputSource {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// https://immersive-web.github.io/webxr/#dom-xrinputsource-profiles
|
||||||
|
fn Profiles(&self, _cx: JSContext) -> JSVal {
|
||||||
|
self.profiles.get()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ impl XRInputSourceArray {
|
||||||
for info in sess.initial_inputs() {
|
for info in sess.initial_inputs() {
|
||||||
// XXXManishearth we should be able to listen for updates
|
// XXXManishearth we should be able to listen for updates
|
||||||
// to the input sources
|
// to the input sources
|
||||||
let input = XRInputSource::new(&global, &session, *info);
|
let input = XRInputSource::new(&global, &session, info.clone());
|
||||||
input_sources.push(Dom::from_ref(&input));
|
input_sources.push(Dom::from_ref(&input));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -54,11 +54,11 @@ impl XRInputSourceArray {
|
||||||
pub fn add_input_source(&self, session: &XRSession, info: InputSource) {
|
pub fn add_input_source(&self, session: &XRSession, info: InputSource) {
|
||||||
let mut input_sources = self.input_sources.borrow_mut();
|
let mut input_sources = self.input_sources.borrow_mut();
|
||||||
let global = self.global();
|
let global = self.global();
|
||||||
let input = XRInputSource::new(&global, &session, info);
|
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
input_sources.iter().find(|i| i.id() == info.id).is_none(),
|
input_sources.iter().find(|i| i.id() == info.id).is_none(),
|
||||||
"Should never add a duplicate input id!"
|
"Should never add a duplicate input id!"
|
||||||
);
|
);
|
||||||
|
let input = XRInputSource::new(&global, &session, info);
|
||||||
input_sources.push(Dom::from_ref(&input));
|
input_sources.push(Dom::from_ref(&input));
|
||||||
|
|
||||||
let added = [input];
|
let added = [input];
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
[events_input_source_recreation.https.html]
|
|
||||||
[Input sources are re-created when handedness or target ray mode changes]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -95,9 +95,6 @@
|
||||||
[XRReferenceSpaceEvent interface: existence and properties of interface prototype object's "constructor" property]
|
[XRReferenceSpaceEvent interface: existence and properties of interface prototype object's "constructor" property]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[XRInputSource interface: attribute profiles]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[XR interface: operation requestSession(XRSessionMode, XRSessionInit)]
|
[XR interface: operation requestSession(XRSessionMode, XRSessionInit)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
[xrInputSource_profiles.https.html]
|
|
||||||
[WebXR InputSource's profiles list can be set]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
[xrSession_input_events_end.https.html]
|
[xrSession_input_events_end.https.html]
|
||||||
|
expected: TIMEOUT
|
||||||
[Calling end during an input callback stops processing at the right time]
|
[Calling end during an input callback stops processing at the right time]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue