mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
script: introduce safe wrappers for js val conversions (#38004)
Introduce a safe wrapper trait for the unsafe `ToJSValConvertible`, and use it in `script/dom` where the default `T` implementation works. Part of https://github.com/servo/servo/issues/37951 --------- Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
This commit is contained in:
parent
9e2ee0029a
commit
027954dbad
16 changed files with 149 additions and 187 deletions
|
@ -4,10 +4,10 @@
|
|||
|
||||
use dom_struct::dom_struct;
|
||||
use embedder_traits::GamepadSupportedHapticEffects;
|
||||
use js::conversions::ToJSValConvertible;
|
||||
use js::jsapi::Heap;
|
||||
use js::jsval::{JSVal, UndefinedValue};
|
||||
use js::rust::MutableHandleValue;
|
||||
use script_bindings::conversions::SafeToJSValConvertible;
|
||||
use webxr_api::{Handedness, InputFrame, InputId, InputSource, TargetRayMode};
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding::{
|
||||
|
@ -73,7 +73,6 @@ impl XRInputSource {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub(crate) fn new(
|
||||
window: &Window,
|
||||
session: &XRSession,
|
||||
|
@ -88,11 +87,12 @@ impl XRInputSource {
|
|||
|
||||
let _ac = enter_realm(window);
|
||||
let cx = GlobalScope::get_cx();
|
||||
unsafe {
|
||||
rooted!(in(*cx) let mut profiles = UndefinedValue());
|
||||
source.info.profiles.to_jsval(*cx, profiles.handle_mut());
|
||||
source.profiles.set(profiles.get());
|
||||
}
|
||||
rooted!(in(*cx) let mut profiles = UndefinedValue());
|
||||
source
|
||||
.info
|
||||
.profiles
|
||||
.safe_to_jsval(cx, profiles.handle_mut());
|
||||
source.profiles.set(profiles.get());
|
||||
source
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue