mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
webxr: Add some missing internal checks/validation (#33318)
* Ensure depthFar is non-negative Signed-off-by: Daniel Adams <msub2official@gmail.com> * Properly append default features in requestSession Signed-off-by: Daniel Adams <msub2official@gmail.com> * Ensure XRRigidTransform init members have finite values Signed-off-by: Daniel Adams <msub2official@gmail.com> --------- Signed-off-by: Daniel Adams <msub2official@gmail.com>
This commit is contained in:
parent
aadc212b95
commit
75c7712905
9 changed files with 35 additions and 40 deletions
|
@ -83,6 +83,26 @@ impl XRRigidTransform {
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !position.x.is_finite() ||
|
||||||
|
!position.y.is_finite() ||
|
||||||
|
!position.z.is_finite() ||
|
||||||
|
!position.w.is_finite()
|
||||||
|
{
|
||||||
|
return Err(Error::Type(
|
||||||
|
"Position must not contain non-finite values".into(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
if !orientation.x.is_finite() ||
|
||||||
|
!orientation.y.is_finite() ||
|
||||||
|
!orientation.z.is_finite() ||
|
||||||
|
!orientation.w.is_finite()
|
||||||
|
{
|
||||||
|
return Err(Error::Type(
|
||||||
|
"Orientation must not contain non-finite values".into(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
let translate = Vector3D::new(position.x as f32, position.y as f32, position.z as f32);
|
let translate = Vector3D::new(position.x as f32, position.y as f32, position.z as f32);
|
||||||
let rotate = Rotation3D::unit_quaternion(
|
let rotate = Rotation3D::unit_quaternion(
|
||||||
orientation.x as f32,
|
orientation.x as f32,
|
||||||
|
|
|
@ -709,11 +709,16 @@ impl XRSessionMethods for XRSession {
|
||||||
pending.set_depth_near(near);
|
pending.set_depth_near(near);
|
||||||
}
|
}
|
||||||
if let Some(far) = init.depthFar {
|
if let Some(far) = init.depthFar {
|
||||||
|
let mut far = *far;
|
||||||
// Step 9 from #apply-the-pending-render-state
|
// Step 9 from #apply-the-pending-render-state
|
||||||
// this may need to be changed if backends wish to impose
|
// this may need to be changed if backends wish to impose
|
||||||
// further constraints
|
// further constraints
|
||||||
// currently the maximum is infinity, so we do nothing
|
// currently the maximum is infinity, so just check that
|
||||||
pending.set_depth_far(*far);
|
// the value is non-negative
|
||||||
|
if far < 0. {
|
||||||
|
far = 0.;
|
||||||
|
}
|
||||||
|
pending.set_depth_far(far);
|
||||||
}
|
}
|
||||||
if let Some(fov) = init.inlineVerticalFieldOfView {
|
if let Some(fov) = init.inlineVerticalFieldOfView {
|
||||||
let mut fov = *fov;
|
let mut fov = *fov;
|
||||||
|
|
|
@ -187,8 +187,6 @@ impl XRSystemMethods for XRSystem {
|
||||||
let mut optional_features = vec![];
|
let mut optional_features = vec![];
|
||||||
let cx = GlobalScope::get_cx();
|
let cx = GlobalScope::get_cx();
|
||||||
|
|
||||||
// We are supposed to include "viewer" and on immersive devices "local"
|
|
||||||
// by default here, but this is handled directly in requestReferenceSpace()
|
|
||||||
if let Some(ref r) = init.requiredFeatures {
|
if let Some(ref r) = init.requiredFeatures {
|
||||||
for feature in r {
|
for feature in r {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -222,6 +220,14 @@ impl XRSystemMethods for XRSystem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !required_features.contains(&"viewer".to_string()) {
|
||||||
|
required_features.push("viewer".to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
if !required_features.contains(&"local".to_string()) && mode != XRSessionMode::Inline {
|
||||||
|
required_features.push("local".to_string());
|
||||||
|
}
|
||||||
|
|
||||||
let init = SessionInit {
|
let init = SessionInit {
|
||||||
required_features,
|
required_features,
|
||||||
optional_features,
|
optional_features,
|
||||||
|
|
|
@ -1,7 +1,2 @@
|
||||||
[render_state_update.https.html]
|
[render_state_update.https.html]
|
||||||
expected: ERROR
|
expected: ERROR
|
||||||
[updateRenderState clamps appropriately near/far clipping planes - webgl]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[updateRenderState clamps appropriately near/far clipping planes - webgl2]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
[xrRigidTransform_constructor.https.html]
|
|
||||||
[XRRigidTransform constructor works - webgl2]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[XRRigidTransform constructor works - webgl]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
[xrSession_enabledFeatures.https.html]
|
|
||||||
[Validate enabledFeatures on XRSession - webgl]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Validate enabledFeatures on XRSession - webgl2]
|
|
||||||
expected: FAIL
|
|
|
@ -1,7 +1,2 @@
|
||||||
[render_state_update.https.html]
|
[render_state_update.https.html]
|
||||||
expected: ERROR
|
expected: ERROR
|
||||||
[updateRenderState clamps appropriately near/far clipping planes - webgl]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[updateRenderState clamps appropriately near/far clipping planes - webgl2]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
[xrRigidTransform_constructor.https.html]
|
|
||||||
[XRRigidTransform constructor works - webgl2]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[XRRigidTransform constructor works - webgl]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
[xrSession_enabledFeatures.https.html]
|
|
||||||
[Validate enabledFeatures on XRSession - webgl]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Validate enabledFeatures on XRSession - webgl2]
|
|
||||||
expected: FAIL
|
|
Loading…
Add table
Add a link
Reference in a new issue