diff --git a/components/plugins/lints/ban.rs b/components/plugins/lints/ban.rs index bd152dfe313..4a4e71c08cc 100644 --- a/components/plugins/lints/ban.rs +++ b/components/plugins/lints/ban.rs @@ -43,5 +43,11 @@ impl EarlyLintPass for BanPass { .is_some() { cx.span_lint(BANNED_TYPE, ty.span, "Banned type DOMRefCell> detected. Use MutJS> instead") } + if match_ty_unwrap(ty, &["dom", "bindings", "cell", "DOMRefCell"]) + .and_then(|t| t.get(0)) + .and_then(|t| match_ty_unwrap(&**t, &["js", "jsapi", "Heap"])) + .is_some() { + cx.span_lint(BANNED_TYPE, ty.span, "Banned type DOMRefCell> detected. Use Heap directly instead") + } } } diff --git a/components/script/dom/vrpose.rs b/components/script/dom/vrpose.rs index c292de9758b..96fa0597a3a 100644 --- a/components/script/dom/vrpose.rs +++ b/components/script/dom/vrpose.rs @@ -3,7 +3,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use core::nonzero::NonZero; -use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::VRPoseBinding; use dom::bindings::codegen::Bindings::VRPoseBinding::VRPoseMethods; use dom::bindings::js::Root; @@ -17,19 +16,18 @@ use webvr_traits::webvr; #[dom_struct] pub struct VRPose { reflector_: Reflector, - position: DOMRefCell>, - orientation: DOMRefCell>, - linear_vel: DOMRefCell>, - angular_vel: DOMRefCell>, - linear_acc: DOMRefCell>, - angular_acc: DOMRefCell> + position: Heap<*mut JSObject>, + orientation: Heap<*mut JSObject>, + linear_vel: Heap<*mut JSObject>, + angular_vel: Heap<*mut JSObject>, + linear_acc: Heap<*mut JSObject>, + angular_acc: Heap<*mut JSObject>, } #[allow(unsafe_code)] unsafe fn update_or_create_typed_array(cx: *mut JSContext, src: Option<&[f32]>, - dst: &DOMRefCell>) { - let dst = dst.borrow(); + dst: &Heap<*mut JSObject>) { match src { Some(data) => { if dst.get().is_null() { @@ -51,8 +49,8 @@ unsafe fn update_or_create_typed_array(cx: *mut JSContext, #[inline] #[allow(unsafe_code)] -fn heap_to_option(heap: &DOMRefCell>) -> Option> { - let js_object = heap.borrow_mut().get(); +fn heap_to_option(heap: &Heap<*mut JSObject>) -> Option> { + let js_object = heap.get(); if js_object.is_null() { None } else { @@ -66,12 +64,12 @@ impl VRPose { fn new_inherited() -> VRPose { VRPose { reflector_: Reflector::new(), - position: DOMRefCell::new(Heap::default()), - orientation: DOMRefCell::new(Heap::default()), - linear_vel: DOMRefCell::new(Heap::default()), - angular_vel: DOMRefCell::new(Heap::default()), - linear_acc: DOMRefCell::new(Heap::default()), - angular_acc: DOMRefCell::new(Heap::default()) + position: Heap::default(), + orientation: Heap::default(), + linear_vel: Heap::default(), + angular_vel: Heap::default(), + linear_acc: Heap::default(), + angular_acc: Heap::default(), } }