aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/utils.rs
diff options
context:
space:
mode:
authorAlan Jeffrey <ajeffrey@mozilla.com>2020-04-07 16:05:36 -0500
committerAlan Jeffrey <ajeffrey@mozilla.com>2020-04-08 20:23:41 -0500
commitc611e46381c9b813aa134ac34b631145ef0c8672 (patch)
tree7b01b33a340a2b9be21ca208d40b508dff9610f0 /components/script/dom/bindings/utils.rs
parentd8781c1054ec268f19f3e716f2b5d6b56aab52cf (diff)
downloadservo-c611e46381c9b813aa134ac34b631145ef0c8672.tar.gz
servo-c611e46381c9b813aa134ac34b631145ef0c8672.zip
Remove WebVR
Diffstat (limited to 'components/script/dom/bindings/utils.rs')
-rw-r--r--components/script/dom/bindings/utils.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs
index 21f82be9cee..80217fea8fb 100644
--- a/components/script/dom/bindings/utils.rs
+++ b/components/script/dom/bindings/utils.rs
@@ -44,6 +44,7 @@ use js::rust::wrappers::JS_HasPropertyById;
use js::rust::wrappers::JS_SetProperty;
use js::rust::{get_object_class, is_dom_class, GCMethods, ToString, ToWindowProxyIfWindow};
use js::rust::{Handle, HandleId, HandleObject, HandleValue, MutableHandleValue};
+use js::typedarray::{CreateWith, Float32Array};
use js::JS_CALLEE;
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
use std::ffi::CString;
@@ -134,6 +135,15 @@ pub fn to_frozen_array<T: ToJSValConvertible>(convertibles: &[T], cx: SafeJSCont
*ports
}
+/// Creates a Float32 array
+pub fn create_typed_array(cx: SafeJSContext, src: &[f32], dst: &Heap<*mut JSObject>) {
+ rooted!(in (*cx) let mut array = ptr::null_mut::<JSObject>());
+ unsafe {
+ let _ = Float32Array::create(*cx, CreateWith::Slice(src), array.handle_mut());
+ }
+ (*dst).set(array.get());
+}
+
/// Returns the ProtoOrIfaceArray for the given global object.
/// Fails if `global` is not a DOM global object.
pub fn get_proto_or_iface_array(global: *mut JSObject) -> *mut ProtoOrIfaceArray {