mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
frozen array in XRInputSourcesChangeEvent, update to_frozen_array
doc (#34100)
* frozen array in XRInputSourcesChangeEvent, update o_frozen_array doc Signed-off-by: L Ashwin B <lashwinib@gmail.com> * simplified changes Signed-off-by: L Ashwin B <lashwinib@gmail.com> * added tests Signed-off-by: L Ashwin B <lashwinib@gmail.com> --------- Signed-off-by: L Ashwin B <lashwinib@gmail.com>
This commit is contained in:
parent
f47cc927a0
commit
900d13fc2f
4 changed files with 18 additions and 13 deletions
|
@ -116,7 +116,7 @@ impl Clone for DOMJSClass {
|
|||
}
|
||||
unsafe impl Sync for DOMJSClass {}
|
||||
|
||||
/// Returns a JSVal representing a frozen array of ports
|
||||
/// Returns a JSVal representing the frozen JavaScript array
|
||||
pub fn to_frozen_array<T: ToJSValConvertible>(convertibles: &[T], cx: SafeJSContext) -> JSVal {
|
||||
rooted!(in(*cx) let mut ports = UndefinedValue());
|
||||
unsafe { convertibles.to_jsval(*cx, ports.handle_mut()) };
|
||||
|
|
|
@ -3,9 +3,8 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use js::conversions::ToJSValConvertible;
|
||||
use js::jsapi::Heap;
|
||||
use js::jsval::{JSVal, UndefinedValue};
|
||||
use js::jsval::JSVal;
|
||||
use js::rust::HandleObject;
|
||||
use servo_atoms::Atom;
|
||||
|
||||
|
@ -17,6 +16,7 @@ use crate::dom::bindings::inheritance::Castable;
|
|||
use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomObject};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::bindings::utils::to_frozen_array;
|
||||
use crate::dom::event::Event;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::window::Window;
|
||||
|
@ -87,15 +87,8 @@ impl XRInputSourcesChangeEvent {
|
|||
}
|
||||
let _ac = enter_realm(global);
|
||||
let cx = GlobalScope::get_cx();
|
||||
unsafe {
|
||||
rooted!(in(*cx) let mut added_val = UndefinedValue());
|
||||
added.to_jsval(*cx, added_val.handle_mut());
|
||||
changeevent.added.set(added_val.get());
|
||||
rooted!(in(*cx) let mut removed_val = UndefinedValue());
|
||||
removed.to_jsval(*cx, removed_val.handle_mut());
|
||||
changeevent.removed.set(removed_val.get());
|
||||
}
|
||||
|
||||
changeevent.added.set(to_frozen_array(added, cx));
|
||||
changeevent.removed.set(to_frozen_array(removed, cx));
|
||||
changeevent
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue