From 62fb2074e1ad55293d6f058793e77012235f5631 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Thu, 8 Dec 2016 15:05:26 -1000 Subject: [PATCH 1/4] Clean up ROOTED_TRACEABLES --- components/script/dom/bindings/trace.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index 4c650719bff..58583077e62 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -82,7 +82,7 @@ use serde::{Deserialize, Serialize}; use servo_atoms::Atom; use servo_url::ServoUrl; use smallvec::SmallVec; -use std::cell::{Cell, UnsafeCell}; +use std::cell::{Cell, RefCell, UnsafeCell}; use std::collections::{BTreeMap, HashMap, HashSet, VecDeque}; use std::hash::{BuildHasher, Hash}; use std::ops::{Deref, DerefMut}; @@ -579,16 +579,11 @@ pub struct RootedTraceableSet { set: Vec, } -#[allow(missing_docs)] // FIXME -mod dummy { // Attributes don’t apply through the macro. - use std::cell::RefCell; - use std::rc::Rc; - use super::RootedTraceableSet; +thread_local!( /// TLV Holds a set of JSTraceables that need to be rooted - thread_local!(pub static ROOTED_TRACEABLES: Rc> = - Rc::new(RefCell::new(RootedTraceableSet::new()))); -} -pub use self::dummy::ROOTED_TRACEABLES; + static ROOTED_TRACEABLES: Rc> = + Rc::new(RefCell::new(RootedTraceableSet::new())); +); impl RootedTraceableSet { fn new() -> RootedTraceableSet { From f7d53b7bc18f10bac98b038c94f46f09fc02e002 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Fri, 9 Dec 2016 08:37:39 -1000 Subject: [PATCH 2/4] Use trait objects in RootedTraceableSet --- components/script/dom/bindings/trace.rs | 43 ++++++++----------------- 1 file changed, 13 insertions(+), 30 deletions(-) diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index 58583077e62..9c61daaaabb 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -59,7 +59,6 @@ use js::glue::{CallObjectTracer, CallUnbarrieredObjectTracer, CallValueTracer}; use js::jsapi::{GCTraceKindToAscii, Heap, JSObject, JSTracer, TraceKind}; use js::jsval::JSVal; use js::rust::Runtime; -use libc; use msg::constellation_msg::{FrameId, FrameType, PipelineId}; use net_traits::{Metadata, NetworkError, ReferrerPolicy, ResourceThreads}; use net_traits::filemanager_thread::RelativePos; @@ -568,15 +567,9 @@ unsafe impl JSTraceable for RwLock { } } -/// Homemade trait object for JSTraceable things -struct TraceableInfo { - pub ptr: *const libc::c_void, - pub trace: unsafe fn(obj: *const libc::c_void, tracer: *mut JSTracer), -} - /// Holds a set of JSTraceables that need to be rooted pub struct RootedTraceableSet { - set: Vec, + set: Vec<*const JSTraceable>, } thread_local!( @@ -592,12 +585,12 @@ impl RootedTraceableSet { } } - unsafe fn remove(traceable: &T) { + unsafe fn remove(traceable: *const JSTraceable) { ROOTED_TRACEABLES.with(|ref traceables| { let mut traceables = traceables.borrow_mut(); let idx = match traceables.set.iter() - .rposition(|x| x.ptr == traceable as *const T as *const _) { + .rposition(|x| *x == traceable) { Some(idx) => idx, None => unreachable!(), }; @@ -605,25 +598,15 @@ impl RootedTraceableSet { }); } - unsafe fn add(traceable: &T) { + unsafe fn add(traceable: *const JSTraceable) { ROOTED_TRACEABLES.with(|ref traceables| { - unsafe fn trace(obj: *const libc::c_void, tracer: *mut JSTracer) { - let obj: &T = &*(obj as *const T); - obj.trace(tracer); - } - - let mut traceables = traceables.borrow_mut(); - let info = TraceableInfo { - ptr: traceable as *const T as *const libc::c_void, - trace: trace::, - }; - traceables.set.push(info); + traceables.borrow_mut().set.push(traceable); }) } unsafe fn trace(&self, tracer: *mut JSTracer) { - for info in &self.set { - (info.trace)(info.ptr, tracer); + for traceable in &self.set { + (**traceable).trace(tracer); } } } @@ -635,11 +618,11 @@ impl RootedTraceableSet { /// If you have an arbitrary number of DomObjects to root, use rooted_vec!. /// If you know what you're doing, use this. #[derive(JSTraceable)] -pub struct RootedTraceable<'a, T: 'a + JSTraceable> { +pub struct RootedTraceable<'a, T: 'static + JSTraceable> { ptr: &'a T, } -impl<'a, T: JSTraceable> RootedTraceable<'a, T> { +impl<'a, T: JSTraceable + 'static> RootedTraceable<'a, T> { /// Root a JSTraceable thing for the life of this RootedTraceable pub fn new(traceable: &'a T) -> RootedTraceable<'a, T> { unsafe { @@ -651,7 +634,7 @@ impl<'a, T: JSTraceable> RootedTraceable<'a, T> { } } -impl<'a, T: JSTraceable> Drop for RootedTraceable<'a, T> { +impl<'a, T: JSTraceable + 'static> Drop for RootedTraceable<'a, T> { fn drop(&mut self) { unsafe { RootedTraceableSet::remove(self.ptr); @@ -681,11 +664,11 @@ impl RootableVec { /// A vector of items that are rooted for the lifetime 'a. #[allow_unrooted_interior] -pub struct RootedVec<'a, T: 'a + JSTraceable> { +pub struct RootedVec<'a, T: 'static + JSTraceable> { root: &'a mut RootableVec, } -impl<'a, T: JSTraceable + DomObject> RootedVec<'a, JS> { +impl<'a, T: 'static + JSTraceable + DomObject> RootedVec<'a, JS> { /// Create a vector of items of type T that is rooted for /// the lifetime of this struct pub fn new>>(root: &'a mut RootableVec>, iter: I) @@ -700,7 +683,7 @@ impl<'a, T: JSTraceable + DomObject> RootedVec<'a, JS> { } } -impl<'a, T: JSTraceable> Drop for RootedVec<'a, T> { +impl<'a, T: JSTraceable + 'static> Drop for RootedVec<'a, T> { fn drop(&mut self) { self.clear(); unsafe { From 1327ebd52f53f5f6637a12fab6cf0cad0aa0be6f Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Sun, 11 Dec 2016 01:19:04 -1000 Subject: [PATCH 3/4] Remove HeapGCValue It could be used to have mutable JSVal fields without GC barriers. With the removal of that trait, MutHeap and MutNullableHeap can respectively be replaced by MutJS and MutNullableJS. --- components/plugins/lints/ban.rs | 6 +- components/script/dom/attr.rs | 7 +-- components/script/dom/bindings/js.rs | 62 +++++++------------ components/script/dom/bluetooth.rs | 6 +- components/script/dom/bluetoothdevice.rs | 24 +++---- .../dom/bluetoothremotegattcharacteristic.rs | 10 +-- .../dom/bluetoothremotegattdescriptor.rs | 6 +- .../script/dom/bluetoothremotegattserver.rs | 6 +- .../script/dom/bluetoothremotegattservice.rs | 6 +- components/script/dom/browsingcontext.rs | 4 +- components/script/dom/client.rs | 4 +- components/script/dom/cssgroupingrule.rs | 6 +- components/script/dom/csskeyframesrule.rs | 6 +- components/script/dom/cssmediarule.rs | 6 +- components/script/dom/cssrulelist.rs | 12 ++-- components/script/dom/cssstylesheet.rs | 6 +- components/script/dom/document.rs | 48 +++++++------- components/script/dom/element.rs | 6 +- components/script/dom/event.rs | 6 +- components/script/dom/filereader.rs | 6 +- components/script/dom/focusevent.rs | 4 +- components/script/dom/globalscope.rs | 4 +- components/script/dom/htmlanchorelement.rs | 4 +- components/script/dom/htmlareaelement.rs | 4 +- components/script/dom/htmlcanvaselement.rs | 4 +- components/script/dom/htmlcollection.rs | 6 +- components/script/dom/htmlelement.rs | 6 +- components/script/dom/htmlformelement.rs | 4 +- components/script/dom/htmliframeelement.rs | 4 +- components/script/dom/htmlinputelement.rs | 6 +- components/script/dom/htmllinkelement.rs | 8 +-- components/script/dom/htmlmediaelement.rs | 4 +- components/script/dom/htmlmetaelement.rs | 6 +- components/script/dom/htmlselectelement.rs | 4 +- components/script/dom/htmlstyleelement.rs | 6 +- components/script/dom/htmltableelement.rs | 4 +- components/script/dom/htmltablerowelement.rs | 4 +- components/script/dom/htmltemplateelement.rs | 6 +- components/script/dom/mod.rs | 4 +- components/script/dom/mouseevent.rs | 4 +- components/script/dom/navigator.rs | 10 +-- components/script/dom/node.rs | 18 +++--- components/script/dom/nodeiterator.rs | 6 +- components/script/dom/nodelist.rs | 6 +- components/script/dom/range.rs | 6 +- components/script/dom/request.rs | 4 +- components/script/dom/response.rs | 4 +- .../script/dom/serviceworkercontainer.rs | 4 +- components/script/dom/servoparser/xml.rs | 4 +- components/script/dom/storageevent.rs | 6 +- components/script/dom/touch.rs | 6 +- components/script/dom/touchevent.rs | 14 ++--- components/script/dom/treewalker.rs | 6 +- components/script/dom/uievent.rs | 5 +- components/script/dom/url.rs | 4 +- components/script/dom/webglframebuffer.rs | 4 +- components/script/dom/webglprogram.rs | 6 +- .../script/dom/webglrenderingcontext.rs | 30 ++++----- components/script/dom/window.rs | 18 +++--- components/script/dom/workerglobalscope.rs | 6 +- components/script/dom/xmlhttprequest.rs | 6 +- components/script/script_thread.rs | 6 +- .../plugin/compile-fail/ban-domrefcell.rs | 2 +- tests/compiletest/plugin/compile-fail/ban.rs | 2 +- 64 files changed, 251 insertions(+), 271 deletions(-) diff --git a/components/plugins/lints/ban.rs b/components/plugins/lints/ban.rs index 0e1ebc94721..bd152dfe313 100644 --- a/components/plugins/lints/ban.rs +++ b/components/plugins/lints/ban.rs @@ -29,19 +29,19 @@ impl EarlyLintPass for BanPass { .and_then(|t| t.get(0)) .and_then(|t| match_ty_unwrap(&**t, &["dom", "bindings", "js", "JS"])) .is_some() { - cx.span_lint(BANNED_TYPE, ty.span, "Banned type Cell> detected. Use MutHeap> instead") + cx.span_lint(BANNED_TYPE, ty.span, "Banned type Cell> detected. Use MutJS> instead") } if match_ty_unwrap(ty, &["std", "cell", "Cell"]) .and_then(|t| t.get(0)) .and_then(|t| match_ty_unwrap(&**t, &["js", "jsval", "JSVal"])) .is_some() { - cx.span_lint(BANNED_TYPE, ty.span, "Banned type Cell detected. Use MutHeap instead") + cx.span_lint(BANNED_TYPE, ty.span, "Banned type Cell 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, &["dom", "bindings", "js", "JS"])) .is_some() { - cx.span_lint(BANNED_TYPE, ty.span, "Banned type DOMRefCell> detected. Use MutHeap> instead") + cx.span_lint(BANNED_TYPE, ty.span, "Banned type DOMRefCell> detected. Use MutJS> instead") } } } diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs index 8b9587c9151..c44cfd4367d 100644 --- a/components/script/dom/attr.rs +++ b/components/script/dom/attr.rs @@ -6,8 +6,7 @@ use devtools_traits::AttrInfo; use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::AttrBinding::{self, AttrMethods}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableHeap}; -use dom::bindings::js::{LayoutJS, Root, RootedReference}; +use dom::bindings::js::{LayoutJS, MutNullableJS, Root, RootedReference}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; use dom::bindings::str::DOMString; use dom::element::{AttributeMutation, Element}; @@ -28,7 +27,7 @@ pub struct Attr { value: DOMRefCell, /// the element that owns this attribute. - owner: MutNullableHeap>, + owner: MutNullableJS, } impl Attr { @@ -48,7 +47,7 @@ impl Attr { prefix: prefix, }, value: DOMRefCell::new(value), - owner: MutNullableHeap::new(owner), + owner: MutNullableJS::new(owner), } } diff --git a/components/script/dom/bindings/js.rs b/components/script/dom/bindings/js.rs index fa7999ebcb1..bdd2b81ce37 100644 --- a/components/script/dom/bindings/js.rs +++ b/components/script/dom/bindings/js.rs @@ -229,20 +229,6 @@ impl LayoutJS { } } - -/// A trait to be implemented for JS-managed types that can be stored in -/// mutable member fields. -/// -/// Do not implement this trait yourself. -pub trait HeapGCValue: JSTraceable { -} - -impl HeapGCValue for Heap { -} - -impl HeapGCValue for JS { -} - /// A holder that provides interior mutability for GC-managed JSVals. /// /// Must be used in place of traditional interior mutability to ensure proper @@ -293,20 +279,20 @@ impl MutHeapJSVal { /// on `JS`. #[must_root] #[derive(JSTraceable)] -pub struct MutHeap { - val: UnsafeCell, +pub struct MutJS { + val: UnsafeCell>, } -impl MutHeap> { - /// Create a new `MutHeap`. - pub fn new(initial: &T) -> MutHeap> { +impl MutJS { + /// Create a new `MutJS`. + pub fn new(initial: &T) -> MutJS { debug_assert!(thread_state::get().is_script()); - MutHeap { + MutJS { val: UnsafeCell::new(JS::from_ref(initial)), } } - /// Set this `MutHeap` to the given value. + /// Set this `MutJS` to the given value. pub fn set(&self, val: &T) { debug_assert!(thread_state::get().is_script()); unsafe { @@ -314,7 +300,7 @@ impl MutHeap> { } } - /// Get the value in this `MutHeap`. + /// Get the value in this `MutJS`. pub fn get(&self) -> Root { debug_assert!(thread_state::get().is_script()); unsafe { @@ -323,14 +309,14 @@ impl MutHeap> { } } -impl HeapSizeOf for MutHeap { +impl HeapSizeOf for MutJS { fn heap_size_of_children(&self) -> usize { // See comment on HeapSizeOf for JS. 0 } } -impl PartialEq for MutHeap> { +impl PartialEq for MutJS { fn eq(&self, other: &Self) -> bool { unsafe { *self.val.get() == *other.val.get() @@ -338,7 +324,7 @@ impl PartialEq for MutHeap> { } } -impl PartialEq for MutHeap> { +impl PartialEq for MutJS { fn eq(&self, other: &T) -> bool { unsafe { **self.val.get() == *other @@ -354,15 +340,15 @@ impl PartialEq for MutHeap> { /// on `JS`. #[must_root] #[derive(JSTraceable)] -pub struct MutNullableHeap { - ptr: UnsafeCell>, +pub struct MutNullableJS { + ptr: UnsafeCell>>, } -impl MutNullableHeap> { - /// Create a new `MutNullableHeap`. - pub fn new(initial: Option<&T>) -> MutNullableHeap> { +impl MutNullableJS { + /// Create a new `MutNullableJS`. + pub fn new(initial: Option<&T>) -> MutNullableJS { debug_assert!(thread_state::get().is_script()); - MutNullableHeap { + MutNullableJS { ptr: UnsafeCell::new(initial.map(JS::from_ref)), } } @@ -400,7 +386,7 @@ impl MutNullableHeap> { } } - /// Set this `MutNullableHeap` to the given value. + /// Set this `MutNullableJS` to the given value. pub fn set(&self, val: Option<&T>) { debug_assert!(thread_state::get().is_script()); unsafe { @@ -416,7 +402,7 @@ impl MutNullableHeap> { } } -impl PartialEq for MutNullableHeap> { +impl PartialEq for MutNullableJS { fn eq(&self, other: &Self) -> bool { unsafe { *self.ptr.get() == *other.ptr.get() @@ -424,7 +410,7 @@ impl PartialEq for MutNullableHeap> { } } -impl<'a, T: DomObject> PartialEq> for MutNullableHeap> { +impl<'a, T: DomObject> PartialEq> for MutNullableJS { fn eq(&self, other: &Option<&T>) -> bool { unsafe { *self.ptr.get() == other.map(JS::from_ref) @@ -432,17 +418,17 @@ impl<'a, T: DomObject> PartialEq> for MutNullableHeap> { } } -impl Default for MutNullableHeap { +impl Default for MutNullableJS { #[allow(unrooted_must_root)] - fn default() -> MutNullableHeap { + fn default() -> MutNullableJS { debug_assert!(thread_state::get().is_script()); - MutNullableHeap { + MutNullableJS { ptr: UnsafeCell::new(None), } } } -impl HeapSizeOf for MutNullableHeap { +impl HeapSizeOf for MutNullableJS { fn heap_size_of_children(&self) -> usize { // See comment on HeapSizeOf for JS. 0 diff --git a/components/script/dom/bluetooth.rs b/components/script/dom/bluetooth.rs index 5a657eb6459..6d35009f869 100644 --- a/components/script/dom/bluetooth.rs +++ b/components/script/dom/bluetooth.rs @@ -15,7 +15,7 @@ use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; use dom::bindings::codegen::UnionTypes::StringOrUnsignedLong; use dom::bindings::error::Error::{self, NotFound, Security, Type}; use dom::bindings::error::Fallible; -use dom::bindings::js::{JS, MutHeap, Root}; +use dom::bindings::js::{MutJS, Root}; use dom::bindings::refcounted::{Trusted, TrustedPromise}; use dom::bindings::reflector::{DomObject, reflect_dom_object}; use dom::bindings::str::DOMString; @@ -86,7 +86,7 @@ impl BluetoothResponseListener for #[dom_struct] pub struct Bluetooth { eventtarget: EventTarget, - device_instance_map: DOMRefCell>>>, + device_instance_map: DOMRefCell>>, } impl Bluetooth { @@ -409,7 +409,7 @@ impl AsyncBluetoothListener for Bluetooth { device.name.map(DOMString::from), &ad_data, &self); - device_instance_map.insert(device.id, MutHeap::new(&bt_device)); + device_instance_map.insert(device.id, MutJS::new(&bt_device)); // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-requestdevice // Step 5. promise.resolve_native(promise_cx, &bt_device); diff --git a/components/script/dom/bluetoothdevice.rs b/components/script/dom/bluetoothdevice.rs index b257b82f343..9b39cfbcd5f 100644 --- a/components/script/dom/bluetoothdevice.rs +++ b/components/script/dom/bluetoothdevice.rs @@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::BluetoothDeviceBinding; use dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods; use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods; use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; -use dom::bindings::js::{JS, Root, MutHeap, MutNullableHeap}; +use dom::bindings::js::{MutJS, MutNullableJS, Root}; use dom::bindings::reflector::{DomObject, reflect_dom_object}; use dom::bindings::str::DOMString; use dom::bluetooth::Bluetooth; @@ -29,12 +29,12 @@ pub struct BluetoothDevice { eventtarget: EventTarget, id: DOMString, name: Option, - ad_data: MutHeap>, - gatt: MutNullableHeap>, - context: MutHeap>, - attribute_instance_map: (DOMRefCell>>>, - DOMRefCell>>>, - DOMRefCell>>>), + ad_data: MutJS, + gatt: MutNullableJS, + context: MutJS, + attribute_instance_map: (DOMRefCell>>, + DOMRefCell>>, + DOMRefCell>>), } impl BluetoothDevice { @@ -47,9 +47,9 @@ impl BluetoothDevice { eventtarget: EventTarget::new_inherited(), id: id, name: name, - ad_data: MutHeap::new(ad_data), + ad_data: MutJS::new(ad_data), gatt: Default::default(), - context: MutHeap::new(context), + context: MutJS::new(context), attribute_instance_map: (DOMRefCell::new(HashMap::new()), DOMRefCell::new(HashMap::new()), DOMRefCell::new(HashMap::new())), @@ -84,7 +84,7 @@ impl BluetoothDevice { DOMString::from(service.uuid.clone()), service.is_primary, service.instance_id.clone()); - service_map.insert(service.instance_id.clone(), MutHeap::new(&bt_service)); + service_map.insert(service.instance_id.clone(), MutJS::new(&bt_service)); return bt_service; } @@ -113,7 +113,7 @@ impl BluetoothDevice { DOMString::from(characteristic.uuid.clone()), &properties, characteristic.instance_id.clone()); - characteristic_map.insert(characteristic.instance_id.clone(), MutHeap::new(&bt_characteristic)); + characteristic_map.insert(characteristic.instance_id.clone(), MutJS::new(&bt_characteristic)); return bt_characteristic; } @@ -130,7 +130,7 @@ impl BluetoothDevice { characteristic, DOMString::from(descriptor.uuid.clone()), descriptor.instance_id.clone()); - descriptor_map.insert(descriptor.instance_id.clone(), MutHeap::new(&bt_descriptor)); + descriptor_map.insert(descriptor.instance_id.clone(), MutJS::new(&bt_descriptor)); return bt_descriptor; } } diff --git a/components/script/dom/bluetoothremotegattcharacteristic.rs b/components/script/dom/bluetoothremotegattcharacteristic.rs index eb41e6ec1db..6ac48edcf86 100644 --- a/components/script/dom/bluetoothremotegattcharacteristic.rs +++ b/components/script/dom/bluetoothremotegattcharacteristic.rs @@ -16,7 +16,7 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::Bluetoo use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; use dom::bindings::error::Error::{self, InvalidModification, Network, NotSupported, Security}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutHeap, Root}; +use dom::bindings::js::{MutJS, Root}; use dom::bindings::reflector::{DomObject, reflect_dom_object}; use dom::bindings::str::{ByteString, DOMString}; use dom::bluetooth::{AsyncBluetoothListener, response_async}; @@ -38,9 +38,9 @@ pub const MAXIMUM_ATTRIBUTE_LENGTH: usize = 512; #[dom_struct] pub struct BluetoothRemoteGATTCharacteristic { eventtarget: EventTarget, - service: MutHeap>, + service: MutJS, uuid: DOMString, - properties: MutHeap>, + properties: MutJS, value: DOMRefCell>, instance_id: String, } @@ -53,9 +53,9 @@ impl BluetoothRemoteGATTCharacteristic { -> BluetoothRemoteGATTCharacteristic { BluetoothRemoteGATTCharacteristic { eventtarget: EventTarget::new_inherited(), - service: MutHeap::new(service), + service: MutJS::new(service), uuid: uuid, - properties: MutHeap::new(properties), + properties: MutJS::new(properties), value: DOMRefCell::new(None), instance_id: instance_id, } diff --git a/components/script/dom/bluetoothremotegattdescriptor.rs b/components/script/dom/bluetoothremotegattdescriptor.rs index c31fae99070..541374e6841 100644 --- a/components/script/dom/bluetoothremotegattdescriptor.rs +++ b/components/script/dom/bluetoothremotegattdescriptor.rs @@ -13,7 +13,7 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTDescriptorBinding::Blue use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods; use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods; use dom::bindings::error::Error::{self, InvalidModification, Network, Security}; -use dom::bindings::js::{JS, MutHeap, Root}; +use dom::bindings::js::{MutJS, Root}; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; use dom::bindings::str::{ByteString, DOMString}; use dom::bluetooth::{AsyncBluetoothListener, response_async}; @@ -28,7 +28,7 @@ use std::rc::Rc; #[dom_struct] pub struct BluetoothRemoteGATTDescriptor { reflector_: Reflector, - characteristic: MutHeap>, + characteristic: MutJS, uuid: DOMString, value: DOMRefCell>, instance_id: String, @@ -41,7 +41,7 @@ impl BluetoothRemoteGATTDescriptor { -> BluetoothRemoteGATTDescriptor { BluetoothRemoteGATTDescriptor { reflector_: Reflector::new(), - characteristic: MutHeap::new(characteristic), + characteristic: MutJS::new(characteristic), uuid: uuid, value: DOMRefCell::new(None), instance_id: instance_id, diff --git a/components/script/dom/bluetoothremotegattserver.rs b/components/script/dom/bluetoothremotegattserver.rs index d9d57ae51f1..72f7cd546d3 100644 --- a/components/script/dom/bluetoothremotegattserver.rs +++ b/components/script/dom/bluetoothremotegattserver.rs @@ -9,7 +9,7 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding; use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods; use dom::bindings::error::Error::{self, Network, Security}; use dom::bindings::error::ErrorResult; -use dom::bindings::js::{JS, MutHeap, Root}; +use dom::bindings::js::{MutJS, Root}; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; use dom::bluetooth::{AsyncBluetoothListener, response_async}; use dom::bluetoothdevice::BluetoothDevice; @@ -25,7 +25,7 @@ use std::rc::Rc; #[dom_struct] pub struct BluetoothRemoteGATTServer { reflector_: Reflector, - device: MutHeap>, + device: MutJS, connected: Cell, } @@ -33,7 +33,7 @@ impl BluetoothRemoteGATTServer { pub fn new_inherited(device: &BluetoothDevice) -> BluetoothRemoteGATTServer { BluetoothRemoteGATTServer { reflector_: Reflector::new(), - device: MutHeap::new(device), + device: MutJS::new(device), connected: Cell::new(false), } } diff --git a/components/script/dom/bluetoothremotegattservice.rs b/components/script/dom/bluetoothremotegattservice.rs index f4aed154c7c..6881a78ff45 100644 --- a/components/script/dom/bluetoothremotegattservice.rs +++ b/components/script/dom/bluetoothremotegattservice.rs @@ -10,7 +10,7 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding; use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods; use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; use dom::bindings::error::Error::{self, Network, Security}; -use dom::bindings::js::{JS, MutHeap, Root}; +use dom::bindings::js::{MutJS, Root}; use dom::bindings::reflector::{DomObject, reflect_dom_object}; use dom::bindings::str::DOMString; use dom::bluetooth::{AsyncBluetoothListener, response_async}; @@ -27,7 +27,7 @@ use std::rc::Rc; #[dom_struct] pub struct BluetoothRemoteGATTService { eventtarget: EventTarget, - device: MutHeap>, + device: MutJS, uuid: DOMString, is_primary: bool, instance_id: String, @@ -41,7 +41,7 @@ impl BluetoothRemoteGATTService { -> BluetoothRemoteGATTService { BluetoothRemoteGATTService { eventtarget: EventTarget::new_inherited(), - device: MutHeap::new(device), + device: MutJS::new(device), uuid: uuid, is_primary: is_primary, instance_id: instance_id, diff --git a/components/script/dom/browsingcontext.rs b/components/script/dom/browsingcontext.rs index 76b8badbe76..1a7f26253a0 100644 --- a/components/script/dom/browsingcontext.rs +++ b/components/script/dom/browsingcontext.rs @@ -4,7 +4,7 @@ use dom::bindings::conversions::{ToJSValConvertible, root_from_handleobject}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableHeap, Root, RootedReference}; +use dom::bindings::js::{JS, MutNullableJS, Root, RootedReference}; use dom::bindings::proxyhandler::{fill_property_descriptor, get_property_descriptor}; use dom::bindings::reflector::{DomObject, MutDomObject, Reflector}; use dom::bindings::trace::JSTraceable; @@ -43,7 +43,7 @@ pub struct BrowsingContext { /// The current active document. /// Note that the session history is stored in the constellation, /// in the script thread we just track the current active document. - active_document: MutNullableHeap>, + active_document: MutNullableJS, /// The containing iframe element, if this is a same-origin iframe frame_element: Option>, diff --git a/components/script/dom/client.rs b/components/script/dom/client.rs index 496a13d32dc..d9d43ce7e01 100644 --- a/components/script/dom/client.rs +++ b/components/script/dom/client.rs @@ -4,7 +4,7 @@ use dom::bindings::codegen::Bindings::ClientBinding::{ClientMethods, Wrap}; use dom::bindings::codegen::Bindings::ClientBinding::FrameType; -use dom::bindings::js::{JS, Root, MutNullableHeap}; +use dom::bindings::js::{Root, MutNullableJS}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; use dom::bindings::str::{DOMString, USVString}; use dom::serviceworker::ServiceWorker; @@ -16,7 +16,7 @@ use uuid::Uuid; #[dom_struct] pub struct Client { reflector_: Reflector, - active_worker: MutNullableHeap>, + active_worker: MutNullableJS, url: ServoUrl, frame_type: FrameType, #[ignore_heap_size_of = "Defined in uuid"] diff --git a/components/script/dom/cssgroupingrule.rs b/components/script/dom/cssgroupingrule.rs index e8651c551d3..64b47142892 100644 --- a/components/script/dom/cssgroupingrule.rs +++ b/components/script/dom/cssgroupingrule.rs @@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::CSSGroupingRuleBinding; use dom::bindings::codegen::Bindings::CSSGroupingRuleBinding::CSSGroupingRuleMethods; use dom::bindings::error::{ErrorResult, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableHeap, Root}; +use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::reflector::{DomObject, reflect_dom_object}; use dom::bindings::str::DOMString; use dom::cssrule::CSSRule; @@ -22,7 +22,7 @@ pub struct CSSGroupingRule { cssrule: CSSRule, #[ignore_heap_size_of = "Arc"] rules: Arc>, - rulelist: MutNullableHeap>, + rulelist: MutNullableJS, } impl CSSGroupingRule { @@ -31,7 +31,7 @@ impl CSSGroupingRule { CSSGroupingRule { cssrule: CSSRule::new_inherited(parent_stylesheet), rules: rules, - rulelist: MutNullableHeap::new(None), + rulelist: MutNullableJS::new(None), } } diff --git a/components/script/dom/csskeyframesrule.rs b/components/script/dom/csskeyframesrule.rs index 46ed79435c1..3ddaa5c5b61 100644 --- a/components/script/dom/csskeyframesrule.rs +++ b/components/script/dom/csskeyframesrule.rs @@ -6,7 +6,7 @@ use cssparser::Parser; use dom::bindings::codegen::Bindings::CSSKeyframesRuleBinding; use dom::bindings::codegen::Bindings::CSSKeyframesRuleBinding::CSSKeyframesRuleMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableHeap, Root}; +use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::reflector::{DomObject, reflect_dom_object}; use dom::bindings::str::DOMString; use dom::csskeyframerule::CSSKeyframeRule; @@ -26,7 +26,7 @@ pub struct CSSKeyframesRule { cssrule: CSSRule, #[ignore_heap_size_of = "Arc"] keyframesrule: Arc>, - rulelist: MutNullableHeap>, + rulelist: MutNullableJS, } impl CSSKeyframesRule { @@ -35,7 +35,7 @@ impl CSSKeyframesRule { CSSKeyframesRule { cssrule: CSSRule::new_inherited(parent_stylesheet), keyframesrule: keyframesrule, - rulelist: MutNullableHeap::new(None), + rulelist: MutNullableJS::new(None), } } diff --git a/components/script/dom/cssmediarule.rs b/components/script/dom/cssmediarule.rs index 0e1fc145e7d..b6b04dde9d8 100644 --- a/components/script/dom/cssmediarule.rs +++ b/components/script/dom/cssmediarule.rs @@ -4,7 +4,7 @@ use dom::bindings::codegen::Bindings::CSSMediaRuleBinding; use dom::bindings::codegen::Bindings::CSSMediaRuleBinding::CSSMediaRuleMethods; -use dom::bindings::js::{JS, MutNullableHeap, Root}; +use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::reflector::{DomObject, reflect_dom_object}; use dom::bindings::str::DOMString; use dom::cssgroupingrule::CSSGroupingRule; @@ -22,7 +22,7 @@ pub struct CSSMediaRule { cssrule: CSSGroupingRule, #[ignore_heap_size_of = "Arc"] mediarule: Arc>, - medialist: MutNullableHeap>, + medialist: MutNullableJS, } impl CSSMediaRule { @@ -32,7 +32,7 @@ impl CSSMediaRule { CSSMediaRule { cssrule: CSSGroupingRule::new_inherited(parent_stylesheet, list), mediarule: mediarule, - medialist: MutNullableHeap::new(None), + medialist: MutNullableJS::new(None), } } diff --git a/components/script/dom/cssrulelist.rs b/components/script/dom/cssrulelist.rs index 988f839a87a..f667638b022 100644 --- a/components/script/dom/cssrulelist.rs +++ b/components/script/dom/cssrulelist.rs @@ -6,7 +6,7 @@ use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::CSSRuleListBinding; use dom::bindings::codegen::Bindings::CSSRuleListBinding::CSSRuleListMethods; use dom::bindings::error::{Error, ErrorResult, Fallible}; -use dom::bindings::js::{JS, MutNullableHeap, Root}; +use dom::bindings::js::{JS, MutNullableJS, Root}; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; use dom::csskeyframerule::CSSKeyframeRule; use dom::cssrule::CSSRule; @@ -38,7 +38,7 @@ pub struct CSSRuleList { parent_stylesheet: JS, #[ignore_heap_size_of = "Arc"] rules: RulesSource, - dom_rules: DOMRefCell>>> + dom_rules: DOMRefCell>> } pub enum RulesSource { @@ -51,10 +51,10 @@ impl CSSRuleList { pub fn new_inherited(parent_stylesheet: &CSSStyleSheet, rules: RulesSource) -> CSSRuleList { let dom_rules = match rules { RulesSource::Rules(ref rules) => { - rules.read().0.iter().map(|_| MutNullableHeap::new(None)).collect() + rules.read().0.iter().map(|_| MutNullableJS::new(None)).collect() } RulesSource::Keyframes(ref rules) => { - rules.read().keyframes.iter().map(|_| MutNullableHeap::new(None)).collect() + rules.read().keyframes.iter().map(|_| MutNullableJS::new(None)).collect() } }; @@ -92,7 +92,7 @@ impl CSSRuleList { let parent_stylesheet = &*self.parent_stylesheet; let dom_rule = CSSRule::new_specific(&window, parent_stylesheet, new_rule); - self.dom_rules.borrow_mut().insert(index, MutNullableHeap::new(Some(&*dom_rule))); + self.dom_rules.borrow_mut().insert(index, MutNullableJS::new(Some(&*dom_rule))); Ok((idx)) } @@ -158,7 +158,7 @@ impl CSSRuleList { if let RulesSource::Rules(..) = self.rules { panic!("Can only call append_lazy_rule with keyframes-backed CSSRules"); } - self.dom_rules.borrow_mut().push(MutNullableHeap::new(None)); + self.dom_rules.borrow_mut().push(MutNullableJS::new(None)); } } diff --git a/components/script/dom/cssstylesheet.rs b/components/script/dom/cssstylesheet.rs index 106b9b5805d..908cfad2cd5 100644 --- a/components/script/dom/cssstylesheet.rs +++ b/components/script/dom/cssstylesheet.rs @@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::CSSStyleSheetBinding; use dom::bindings::codegen::Bindings::CSSStyleSheetBinding::CSSStyleSheetMethods; use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; use dom::bindings::error::{ErrorResult, Fallible}; -use dom::bindings::js::{JS, Root, MutNullableHeap}; +use dom::bindings::js::{JS, MutNullableJS, Root}; use dom::bindings::reflector::{reflect_dom_object, DomObject}; use dom::bindings::str::DOMString; use dom::cssrulelist::{CSSRuleList, RulesSource}; @@ -20,7 +20,7 @@ use style::stylesheets::Stylesheet as StyleStyleSheet; pub struct CSSStyleSheet { stylesheet: StyleSheet, owner: JS, - rulelist: MutNullableHeap>, + rulelist: MutNullableJS, #[ignore_heap_size_of = "Arc"] style_stylesheet: Arc, } @@ -34,7 +34,7 @@ impl CSSStyleSheet { CSSStyleSheet { stylesheet: StyleSheet::new_inherited(type_, href, title), owner: JS::from_ref(owner), - rulelist: MutNullableHeap::new(None), + rulelist: MutNullableJS::new(None), style_stylesheet: stylesheet, } } diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 9704b4ba0ab..17ef9df0ed6 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -24,7 +24,7 @@ use dom::bindings::codegen::Bindings::WindowBinding::{FrameRequestCallback, Scro use dom::bindings::codegen::UnionTypes::NodeOrString; use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId}; -use dom::bindings::js::{JS, LayoutJS, MutNullableHeap, Root}; +use dom::bindings::js::{JS, LayoutJS, MutNullableJS, Root}; use dom::bindings::js::RootedReference; use dom::bindings::num::Finite; use dom::bindings::refcounted::{Trusted, TrustedPromise}; @@ -184,8 +184,8 @@ pub struct Document { window: JS, /// https://html.spec.whatwg.org/multipage/#concept-document-bc browsing_context: Option>, - implementation: MutNullableHeap>, - location: MutNullableHeap>, + implementation: MutNullableJS, + location: MutNullableJS, content_type: DOMString, last_modified: Option, encoding: Cell, @@ -197,29 +197,29 @@ pub struct Document { tag_map: DOMRefCell>>, tagns_map: DOMRefCell>>, classes_map: DOMRefCell, JS>>, - images: MutNullableHeap>, - embeds: MutNullableHeap>, - links: MutNullableHeap>, - forms: MutNullableHeap>, - scripts: MutNullableHeap>, - anchors: MutNullableHeap>, - applets: MutNullableHeap>, + images: MutNullableJS, + embeds: MutNullableJS, + links: MutNullableJS, + forms: MutNullableJS, + scripts: MutNullableJS, + anchors: MutNullableJS, + applets: MutNullableJS, /// List of stylesheets associated with nodes in this document. |None| if the list needs to be refreshed. stylesheets: DOMRefCell>>, /// Whether the list of stylesheets has changed since the last reflow was triggered. stylesheets_changed_since_reflow: Cell, - stylesheet_list: MutNullableHeap>, + stylesheet_list: MutNullableJS, ready_state: Cell, /// Whether the DOMContentLoaded event has already been dispatched. domcontentloaded_dispatched: Cell, /// The element that has most recently requested focus for itself. - possibly_focused: MutNullableHeap>, + possibly_focused: MutNullableJS, /// The element that currently has the document focus context. - focused: MutNullableHeap>, + focused: MutNullableJS, /// The script element that is currently executing. - current_script: MutNullableHeap>, + current_script: MutNullableJS, /// https://html.spec.whatwg.org/multipage/#pending-parsing-blocking-script - pending_parsing_blocking_script: MutNullableHeap>, + pending_parsing_blocking_script: MutNullableJS, /// Number of stylesheets that block executing the next parser-inserted script script_blocking_stylesheets_count: Cell, /// https://html.spec.whatwg.org/multipage/#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing @@ -245,14 +245,14 @@ pub struct Document { /// Tracks all outstanding loads related to this document. loader: DOMRefCell, /// The current active HTML parser, to allow resuming after interruptions. - current_parser: MutNullableHeap>, + current_parser: MutNullableJS, /// When we should kick off a reflow. This happens during parsing. reflow_timeout: Cell>, /// The cached first `base` element with an `href` attribute. - base_element: MutNullableHeap>, + base_element: MutNullableJS, /// This field is set to the document itself for inert documents. /// https://html.spec.whatwg.org/multipage/#appropriate-template-contents-owner-document - appropriate_template_contents_owner_document: MutNullableHeap>, + appropriate_template_contents_owner_document: MutNullableJS, /// Information on elements needing restyle to ship over to the layout thread when the /// time comes. pending_restyles: DOMRefCell, PendingRestyle>>, @@ -280,7 +280,7 @@ pub struct Document { /// https://html.spec.whatwg.org/multipage/#dom-document-referrer referrer: Option, /// https://html.spec.whatwg.org/multipage/#target-element - target_element: MutNullableHeap>, + target_element: MutNullableJS, /// https://w3c.github.io/uievents/#event-type-dblclick #[ignore_heap_size_of = "Defined in std"] last_click_info: DOMRefCell)>>, @@ -293,7 +293,7 @@ pub struct Document { /// See also: https://github.com/servo/servo/issues/10110 dom_count: Cell, /// Entry node for fullscreen. - fullscreen_element: MutNullableHeap>, + fullscreen_element: MutNullableJS, } #[derive(JSTraceable, HeapSizeOf)] @@ -1036,7 +1036,7 @@ impl Document { pub fn handle_mouse_move_event(&self, js_runtime: *mut JSRuntime, client_point: Option>, - prev_mouse_over_target: &MutNullableHeap>) { + prev_mouse_over_target: &MutNullableJS) { let client_point = match client_point { None => { // If there's no point, there's no target under the mouse @@ -1872,7 +1872,7 @@ impl Document { applets: Default::default(), stylesheets: DOMRefCell::new(None), stylesheets_changed_since_reflow: Cell::new(false), - stylesheet_list: MutNullableHeap::new(None), + stylesheet_list: MutNullableJS::new(None), ready_state: Cell::new(ready_state), domcontentloaded_dispatched: Cell::new(domcontentloaded_dispatched), possibly_focused: Default::default(), @@ -1907,11 +1907,11 @@ impl Document { origin: origin, referrer: referrer, referrer_policy: Cell::new(referrer_policy), - target_element: MutNullableHeap::new(None), + target_element: MutNullableJS::new(None), last_click_info: DOMRefCell::new(None), ignore_destructive_writes_counter: Default::default(), dom_count: Cell::new(1), - fullscreen_element: MutNullableHeap::new(None), + fullscreen_element: MutNullableJS::new(None), } } diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 67e5584b0f0..66021ce6104 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -22,7 +22,7 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::codegen::UnionTypes::NodeOrString; use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId}; -use dom::bindings::js::{JS, LayoutJS, MutNullableHeap}; +use dom::bindings::js::{JS, LayoutJS, MutNullableJS}; use dom::bindings::js::{Root, RootedReference}; use dom::bindings::refcounted::{Trusted, TrustedPromise}; use dom::bindings::reflector::DomObject; @@ -125,8 +125,8 @@ pub struct Element { id_attribute: DOMRefCell>, #[ignore_heap_size_of = "Arc"] style_attribute: DOMRefCell>>>, - attr_list: MutNullableHeap>, - class_list: MutNullableHeap>, + attr_list: MutNullableJS, + class_list: MutNullableJS, state: Cell, atomic_flags: AtomicElementFlags, } diff --git a/components/script/dom/event.rs b/components/script/dom/event.rs index d67d1f64e78..d471c25d873 100644 --- a/components/script/dom/event.rs +++ b/components/script/dom/event.rs @@ -6,7 +6,7 @@ use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::EventBinding; use dom::bindings::codegen::Bindings::EventBinding::{EventConstants, EventMethods}; use dom::bindings::error::Fallible; -use dom::bindings::js::{JS, MutNullableHeap, Root}; +use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::{Reflector, reflect_dom_object}; use dom::bindings::str::DOMString; @@ -80,8 +80,8 @@ impl From for EventCancelable { #[dom_struct] pub struct Event { reflector_: Reflector, - current_target: MutNullableHeap>, - target: MutNullableHeap>, + current_target: MutNullableJS, + target: MutNullableJS, type_: DOMRefCell, phase: Cell, canceled: Cell, diff --git a/components/script/dom/filereader.rs b/components/script/dom/filereader.rs index bb57ad5d9de..4227e84d6c0 100644 --- a/components/script/dom/filereader.rs +++ b/components/script/dom/filereader.rs @@ -9,7 +9,7 @@ use dom::bindings::codegen::Bindings::FileReaderBinding::{self, FileReaderConsta use dom::bindings::codegen::UnionTypes::StringOrObject; use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableHeap, Root}; +use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::{DomObject, reflect_dom_object}; use dom::bindings::str::DOMString; @@ -86,7 +86,7 @@ pub enum FileReaderResult { pub struct FileReader { eventtarget: EventTarget, ready_state: Cell, - error: MutNullableHeap>, + error: MutNullableJS, result: DOMRefCell>, generation_id: Cell, } @@ -96,7 +96,7 @@ impl FileReader { FileReader { eventtarget: EventTarget::new_inherited(), ready_state: Cell::new(FileReaderReadyState::Empty), - error: MutNullableHeap::new(None), + error: MutNullableJS::new(None), result: DOMRefCell::new(None), generation_id: Cell::new(GenerationId(0)), } diff --git a/components/script/dom/focusevent.rs b/components/script/dom/focusevent.rs index 1eb3983737d..c7e48531479 100644 --- a/components/script/dom/focusevent.rs +++ b/components/script/dom/focusevent.rs @@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::FocusEventBinding::FocusEventMethods; use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableHeap, Root, RootedReference}; +use dom::bindings::js::{MutNullableJS, Root, RootedReference}; use dom::bindings::reflector::reflect_dom_object; use dom::bindings::str::DOMString; use dom::event::{EventBubbles, EventCancelable}; @@ -20,7 +20,7 @@ use std::default::Default; #[dom_struct] pub struct FocusEvent { uievent: UIEvent, - related_target: MutNullableHeap>, + related_target: MutNullableJS, } impl FocusEvent { diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs index 19436804b19..ae08bc0e5fd 100644 --- a/components/script/dom/globalscope.rs +++ b/components/script/dom/globalscope.rs @@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::conversions::root_from_object; use dom::bindings::error::{ErrorInfo, report_pending_exception}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableHeap, Root}; +use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::reflector::DomObject; use dom::bindings::str::DOMString; use dom::crypto::Crypto; @@ -50,7 +50,7 @@ use timers::{OneshotTimers, TimerCallback}; #[dom_struct] pub struct GlobalScope { eventtarget: EventTarget, - crypto: MutNullableHeap>, + crypto: MutNullableJS, next_worker_id: Cell, /// Pipeline id associated with this global. diff --git a/components/script/dom/htmlanchorelement.rs b/components/script/dom/htmlanchorelement.rs index f92290b2c97..b86cd60b8fc 100644 --- a/components/script/dom/htmlanchorelement.rs +++ b/components/script/dom/htmlanchorelement.rs @@ -11,7 +11,7 @@ use dom::bindings::codegen::Bindings::HTMLAnchorElementBinding::HTMLAnchorElemen use dom::bindings::codegen::Bindings::MouseEventBinding::MouseEventMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableHeap, Root}; +use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::str::{DOMString, USVString}; use dom::document::Document; use dom::domtokenlist::DOMTokenList; @@ -36,7 +36,7 @@ use util::prefs::PREFS; #[dom_struct] pub struct HTMLAnchorElement { htmlelement: HTMLElement, - rel_list: MutNullableHeap>, + rel_list: MutNullableJS, url: DOMRefCell>, } diff --git a/components/script/dom/htmlareaelement.rs b/components/script/dom/htmlareaelement.rs index b8df3806a3f..79240885167 100644 --- a/components/script/dom/htmlareaelement.rs +++ b/components/script/dom/htmlareaelement.rs @@ -5,7 +5,7 @@ use dom::bindings::codegen::Bindings::HTMLAreaElementBinding; use dom::bindings::codegen::Bindings::HTMLAreaElementBinding::HTMLAreaElementMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableHeap, Root}; +use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::str::DOMString; use dom::document::Document; use dom::domtokenlist::DOMTokenList; @@ -19,7 +19,7 @@ use style::attr::AttrValue; #[dom_struct] pub struct HTMLAreaElement { htmlelement: HTMLElement, - rel_list: MutNullableHeap>, + rel_list: MutNullableJS, } impl HTMLAreaElement { diff --git a/components/script/dom/htmlcanvaselement.rs b/components/script/dom/htmlcanvaselement.rs index b9d7731d652..b174d2ec9a8 100644 --- a/components/script/dom/htmlcanvaselement.rs +++ b/components/script/dom/htmlcanvaselement.rs @@ -13,7 +13,7 @@ use dom::bindings::codegen::UnionTypes::CanvasRenderingContext2DOrWebGLRendering use dom::bindings::conversions::ConversionResult; use dom::bindings::error::{Error, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{HeapGCValue, JS, LayoutJS, Root}; +use dom::bindings::js::{JS, LayoutJS, Root}; use dom::bindings::num::Finite; use dom::bindings::str::DOMString; use dom::canvasrenderingcontext2d::{CanvasRenderingContext2D, LayoutCanvasRenderingContext2DHelpers}; @@ -47,8 +47,6 @@ pub enum CanvasContext { WebGL(JS), } -impl HeapGCValue for CanvasContext {} - #[dom_struct] pub struct HTMLCanvasElement { htmlelement: HTMLElement, diff --git a/components/script/dom/htmlcollection.rs b/components/script/dom/htmlcollection.rs index 959265e82e0..eacffd6cded 100644 --- a/components/script/dom/htmlcollection.rs +++ b/components/script/dom/htmlcollection.rs @@ -5,7 +5,7 @@ use dom::bindings::codegen::Bindings::HTMLCollectionBinding; use dom::bindings::codegen::Bindings::HTMLCollectionBinding::HTMLCollectionMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, Root, MutNullableHeap}; +use dom::bindings::js::{JS, Root, MutNullableJS}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; use dom::bindings::str::DOMString; use dom::bindings::trace::JSTraceable; @@ -59,7 +59,7 @@ pub struct HTMLCollection { // the length of the collection, and a cursor into the collection. // FIXME: make the cached cursor element a weak pointer cached_version: Cell, - cached_cursor_element: MutNullableHeap>, + cached_cursor_element: MutNullableJS, cached_cursor_index: Cell, cached_length: Cell, } @@ -73,7 +73,7 @@ impl HTMLCollection { filter: filter, // Default values for the cache cached_version: Cell::new(root.inclusive_descendants_version()), - cached_cursor_element: MutNullableHeap::new(None), + cached_cursor_element: MutNullableJS::new(None), cached_cursor_index: Cell::new(OptionU32::none()), cached_length: Cell::new(OptionU32::none()), } diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs index d4490357650..1d3c6c0346b 100644 --- a/components/script/dom/htmlelement.rs +++ b/components/script/dom/htmlelement.rs @@ -13,7 +13,7 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::error::{Error, ErrorResult}; use dom::bindings::inheritance::{ElementTypeId, HTMLElementTypeId, NodeTypeId}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableHeap, Root, RootedReference}; +use dom::bindings::js::{MutNullableJS, Root, RootedReference}; use dom::bindings::str::DOMString; use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration}; use dom::document::{Document, FocusType}; @@ -40,8 +40,8 @@ use style::element_state::*; #[dom_struct] pub struct HTMLElement { element: Element, - style_decl: MutNullableHeap>, - dataset: MutNullableHeap>, + style_decl: MutNullableJS, + dataset: MutNullableJS, } impl HTMLElement { diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index 90abdbafefd..eabcbc41e6e 100755 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -13,7 +13,7 @@ use dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementM use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTextAreaElementMethods; use dom::bindings::conversions::DerivedFrom; use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId}; -use dom::bindings::js::{JS, MutNullableHeap, Root}; +use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::DomObject; use dom::bindings::str::DOMString; @@ -61,7 +61,7 @@ pub struct GenerationId(u32); pub struct HTMLFormElement { htmlelement: HTMLElement, marked_for_reset: Cell, - elements: MutNullableHeap>, + elements: MutNullableJS, generation_id: Cell } diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index 44323e1c1ef..3f3ea8aa52a 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -19,7 +19,7 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethod use dom::bindings::conversions::ToJSValConvertible; use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, LayoutJS, MutNullableHeap, Root}; +use dom::bindings::js::{LayoutJS, MutNullableJS, Root}; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::DomObject; use dom::bindings::str::DOMString; @@ -80,7 +80,7 @@ pub struct HTMLIFrameElement { htmlelement: HTMLElement, frame_id: FrameId, pipeline_id: Cell>, - sandbox: MutNullableHeap>, + sandbox: MutNullableJS, sandbox_allowance: Cell>, load_blocker: DOMRefCell>, visibility: Cell, diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index 90cf630e9fe..eb344ef0a79 100755 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -13,7 +13,7 @@ use dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementM use dom::bindings::codegen::Bindings::KeyboardEventBinding::KeyboardEventMethods; use dom::bindings::error::{Error, ErrorResult}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, LayoutJS, MutNullableHeap, Root, RootedReference}; +use dom::bindings::js::{JS, LayoutJS, MutNullableJS, Root, RootedReference}; use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::{AttributeMutation, Element, LayoutElementHelpers, RawLayoutElementHelpers}; @@ -94,7 +94,7 @@ pub struct HTMLInputElement { // https://html.spec.whatwg.org/multipage/#concept-input-value-dirty-flag value_dirty: Cell, - filelist: MutNullableHeap>, + filelist: MutNullableJS, } #[derive(JSTraceable)] @@ -150,7 +150,7 @@ impl HTMLInputElement { SelectionDirection::None)), activation_state: DOMRefCell::new(InputActivationState::new()), value_dirty: Cell::new(false), - filelist: MutNullableHeap::new(None), + filelist: MutNullableJS::new(None), } } diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs index 1985e511c4d..145b53b3ec7 100644 --- a/components/script/dom/htmllinkelement.rs +++ b/components/script/dom/htmllinkelement.rs @@ -10,7 +10,7 @@ use dom::bindings::codegen::Bindings::DOMTokenListBinding::DOMTokenListMethods; use dom::bindings::codegen::Bindings::HTMLLinkElementBinding; use dom::bindings::codegen::Bindings::HTMLLinkElementBinding::HTMLLinkElementMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableHeap, Root, RootedReference}; +use dom::bindings::js::{MutNullableJS, Root, RootedReference}; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::DomObject; use dom::bindings::str::DOMString; @@ -55,10 +55,10 @@ unsafe_no_jsmanaged_fields!(Stylesheet); #[dom_struct] pub struct HTMLLinkElement { htmlelement: HTMLElement, - rel_list: MutNullableHeap>, + rel_list: MutNullableJS, #[ignore_heap_size_of = "Arc"] stylesheet: DOMRefCell>>, - cssom_stylesheet: MutNullableHeap>, + cssom_stylesheet: MutNullableJS, /// https://html.spec.whatwg.org/multipage/#a-style-sheet-that-is-blocking-scripts parser_inserted: Cell, @@ -72,7 +72,7 @@ impl HTMLLinkElement { rel_list: Default::default(), parser_inserted: Cell::new(creator == ElementCreator::ParserCreated), stylesheet: DOMRefCell::new(None), - cssom_stylesheet: MutNullableHeap::new(None), + cssom_stylesheet: MutNullableJS::new(None), } } diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs index 778c0d6b560..8a3f35c23d4 100644 --- a/components/script/dom/htmlmediaelement.rs +++ b/components/script/dom/htmlmediaelement.rs @@ -13,7 +13,7 @@ use dom::bindings::codegen::Bindings::HTMLMediaElementBinding::HTMLMediaElementM use dom::bindings::codegen::Bindings::MediaErrorBinding::MediaErrorConstants::*; use dom::bindings::codegen::Bindings::MediaErrorBinding::MediaErrorMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{Root, MutNullableHeap, JS}; +use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::DomObject; use dom::bindings::str::DOMString; @@ -218,7 +218,7 @@ pub struct HTMLMediaElement { current_src: DOMRefCell, generation_id: Cell, first_data_load: Cell, - error: MutNullableHeap>, + error: MutNullableJS, paused: Cell, autoplaying: Cell, video: DOMRefCell>, diff --git a/components/script/dom/htmlmetaelement.rs b/components/script/dom/htmlmetaelement.rs index bcf112cce94..e86f2c4a25a 100644 --- a/components/script/dom/htmlmetaelement.rs +++ b/components/script/dom/htmlmetaelement.rs @@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::HTMLMetaElementBinding; use dom::bindings::codegen::Bindings::HTMLMetaElementBinding::HTMLMetaElementMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableHeap, Root, RootedReference}; +use dom::bindings::js::{MutNullableJS, Root, RootedReference}; use dom::bindings::str::DOMString; use dom::cssstylesheet::CSSStyleSheet; use dom::document::Document; @@ -32,7 +32,7 @@ pub struct HTMLMetaElement { htmlelement: HTMLElement, #[ignore_heap_size_of = "Arc"] stylesheet: DOMRefCell>>, - cssom_stylesheet: MutNullableHeap>, + cssom_stylesheet: MutNullableJS, } impl HTMLMetaElement { @@ -42,7 +42,7 @@ impl HTMLMetaElement { HTMLMetaElement { htmlelement: HTMLElement::new_inherited(local_name, prefix, document), stylesheet: DOMRefCell::new(None), - cssom_stylesheet: MutNullableHeap::new(None), + cssom_stylesheet: MutNullableJS::new(None), } } diff --git a/components/script/dom/htmlselectelement.rs b/components/script/dom/htmlselectelement.rs index ad66f2b05f3..7f27a311e3d 100755 --- a/components/script/dom/htmlselectelement.rs +++ b/components/script/dom/htmlselectelement.rs @@ -14,7 +14,7 @@ use dom::bindings::codegen::UnionTypes::HTMLElementOrLong; use dom::bindings::codegen::UnionTypes::HTMLOptionElementOrHTMLOptGroupElement; //use dom::bindings::error::ErrorResult; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableHeap, Root}; +use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::{AttributeMutation, Element}; @@ -58,7 +58,7 @@ impl CollectionFilter for OptionsFilter { #[dom_struct] pub struct HTMLSelectElement { htmlelement: HTMLElement, - options: MutNullableHeap>, + options: MutNullableJS, } static DEFAULT_SELECT_SIZE: u32 = 0; diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs index 5a61d6f5b3a..8576a282052 100644 --- a/components/script/dom/htmlstyleelement.rs +++ b/components/script/dom/htmlstyleelement.rs @@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::HTMLStyleElementBinding; use dom::bindings::codegen::Bindings::HTMLStyleElementBinding::HTMLStyleElementMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableHeap, Root}; +use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::str::DOMString; use dom::cssstylesheet::CSSStyleSheet; use dom::document::Document; @@ -29,7 +29,7 @@ pub struct HTMLStyleElement { htmlelement: HTMLElement, #[ignore_heap_size_of = "Arc"] stylesheet: DOMRefCell>>, - cssom_stylesheet: MutNullableHeap>, + cssom_stylesheet: MutNullableJS, } impl HTMLStyleElement { @@ -39,7 +39,7 @@ impl HTMLStyleElement { HTMLStyleElement { htmlelement: HTMLElement::new_inherited(local_name, prefix, document), stylesheet: DOMRefCell::new(None), - cssom_stylesheet: MutNullableHeap::new(None), + cssom_stylesheet: MutNullableJS::new(None), } } diff --git a/components/script/dom/htmltableelement.rs b/components/script/dom/htmltableelement.rs index e533c9acdcd..741b53c38ac 100644 --- a/components/script/dom/htmltableelement.rs +++ b/components/script/dom/htmltableelement.rs @@ -10,7 +10,7 @@ use dom::bindings::codegen::Bindings::HTMLTableElementBinding::HTMLTableElementM use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, LayoutJS, MutNullableHeap, Root, RootedReference}; +use dom::bindings::js::{JS, LayoutJS, MutNullableJS, Root, RootedReference}; use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers}; @@ -31,7 +31,7 @@ pub struct HTMLTableElement { htmlelement: HTMLElement, border: Cell>, cellspacing: Cell>, - tbodies: MutNullableHeap>, + tbodies: MutNullableJS, } #[allow(unrooted_must_root)] diff --git a/components/script/dom/htmltablerowelement.rs b/components/script/dom/htmltablerowelement.rs index b95aba1c3e0..c6b04648dc2 100644 --- a/components/script/dom/htmltablerowelement.rs +++ b/components/script/dom/htmltablerowelement.rs @@ -9,7 +9,7 @@ use dom::bindings::codegen::Bindings::HTMLTableSectionElementBinding::HTMLTableS use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::error::{ErrorResult, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, LayoutJS, MutNullableHeap, Root, RootedReference}; +use dom::bindings::js::{LayoutJS, MutNullableJS, Root, RootedReference}; use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::{Element, RawLayoutElementHelpers}; @@ -36,7 +36,7 @@ impl CollectionFilter for CellsFilter { #[dom_struct] pub struct HTMLTableRowElement { htmlelement: HTMLElement, - cells: MutNullableHeap>, + cells: MutNullableJS, } impl HTMLTableRowElement { diff --git a/components/script/dom/htmltemplateelement.rs b/components/script/dom/htmltemplateelement.rs index 7ee8d03b163..1c9b2c0aacd 100644 --- a/components/script/dom/htmltemplateelement.rs +++ b/components/script/dom/htmltemplateelement.rs @@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::HTMLTemplateElementBinding; use dom::bindings::codegen::Bindings::HTMLTemplateElementBinding::HTMLTemplateElementMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableHeap, Root}; +use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::str::DOMString; use dom::document::Document; use dom::documentfragment::DocumentFragment; @@ -21,7 +21,7 @@ pub struct HTMLTemplateElement { htmlelement: HTMLElement, /// https://html.spec.whatwg.org/multipage/#template-contents - contents: MutNullableHeap>, + contents: MutNullableJS, } impl HTMLTemplateElement { @@ -31,7 +31,7 @@ impl HTMLTemplateElement { HTMLTemplateElement { htmlelement: HTMLElement::new_inherited(local_name, prefix, document), - contents: MutNullableHeap::new(None), + contents: MutNullableJS::new(None), } } diff --git a/components/script/dom/mod.rs b/components/script/dom/mod.rs index 5bc19eab627..6133b4a78a6 100644 --- a/components/script/dom/mod.rs +++ b/components/script/dom/mod.rs @@ -32,8 +32,8 @@ //! * rooting pointers on the stack: //! the [`Root`](bindings/js/struct.Root.html) smart pointer; //! * tracing pointers in member fields: the [`JS`](bindings/js/struct.JS.html), -//! [`MutNullableHeap`](bindings/js/struct.MutNullableHeap.html) and -//! [`MutHeap`](bindings/js/struct.MutHeap.html) smart pointers and +//! [`MutNullableJS`](bindings/js/struct.MutNullableJS.html) and +//! [`MutJS`](bindings/js/struct.MutJS.html) smart pointers and //! [the tracing implementation](bindings/trace/index.html); //! * rooting pointers from across thread boundaries or in channels: the //! [`Trusted`](bindings/refcounted/struct.Trusted.html) smart pointer; diff --git a/components/script/dom/mouseevent.rs b/components/script/dom/mouseevent.rs index 2b39d555204..9a01fcf1fde 100644 --- a/components/script/dom/mouseevent.rs +++ b/components/script/dom/mouseevent.rs @@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::MouseEventBinding::MouseEventMethods; use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableHeap, Root, RootedReference}; +use dom::bindings::js::{MutNullableJS, Root, RootedReference}; use dom::bindings::reflector::reflect_dom_object; use dom::bindings::str::DOMString; use dom::event::{Event, EventBubbles, EventCancelable}; @@ -30,7 +30,7 @@ pub struct MouseEvent { alt_key: Cell, meta_key: Cell, button: Cell, - related_target: MutNullableHeap>, + related_target: MutNullableJS, } impl MouseEvent { diff --git a/components/script/dom/navigator.rs b/components/script/dom/navigator.rs index 9318e437ad5..b7d781f5eb0 100644 --- a/components/script/dom/navigator.rs +++ b/components/script/dom/navigator.rs @@ -4,7 +4,7 @@ use dom::bindings::codegen::Bindings::NavigatorBinding; use dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorMethods; -use dom::bindings::js::{JS, MutNullableHeap, Root}; +use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::reflector::{Reflector, DomObject, reflect_dom_object}; use dom::bindings::str::DOMString; use dom::bluetooth::Bluetooth; @@ -17,10 +17,10 @@ use dom::window::Window; #[dom_struct] pub struct Navigator { reflector_: Reflector, - bluetooth: MutNullableHeap>, - plugins: MutNullableHeap>, - mime_types: MutNullableHeap>, - service_worker: MutNullableHeap>, + bluetooth: MutNullableJS, + plugins: MutNullableJS, + mime_types: MutNullableJS, + service_worker: MutNullableJS, } impl Navigator { diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 983f11f478c..736020e360a 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -21,7 +21,7 @@ use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::inheritance::{Castable, CharacterDataTypeId, ElementTypeId}; use dom::bindings::inheritance::{EventTargetTypeId, HTMLElementTypeId, NodeTypeId}; use dom::bindings::inheritance::{SVGElementTypeId, SVGGraphicsElementTypeId}; -use dom::bindings::js::{JS, LayoutJS, MutNullableHeap}; +use dom::bindings::js::{JS, LayoutJS, MutNullableJS}; use dom::bindings::js::Root; use dom::bindings::js::RootedReference; use dom::bindings::reflector::{DomObject, reflect_dom_object}; @@ -95,25 +95,25 @@ pub struct Node { eventtarget: EventTarget, /// The parent of this node. - parent_node: MutNullableHeap>, + parent_node: MutNullableJS, /// The first child of this node. - first_child: MutNullableHeap>, + first_child: MutNullableJS, /// The last child of this node. - last_child: MutNullableHeap>, + last_child: MutNullableJS, /// The next sibling of this node. - next_sibling: MutNullableHeap>, + next_sibling: MutNullableJS, /// The previous sibling of this node. - prev_sibling: MutNullableHeap>, + prev_sibling: MutNullableJS, /// The document that this node belongs to. - owner_doc: MutNullableHeap>, + owner_doc: MutNullableJS, /// The live list of children return by .childNodes. - child_list: MutNullableHeap>, + child_list: MutNullableJS, /// The live count of children of this node. children_count: Cell, @@ -1370,7 +1370,7 @@ impl Node { last_child: Default::default(), next_sibling: Default::default(), prev_sibling: Default::default(), - owner_doc: MutNullableHeap::new(doc), + owner_doc: MutNullableJS::new(doc), child_list: Default::default(), children_count: Cell::new(0u32), flags: Cell::new(flags), diff --git a/components/script/dom/nodeiterator.rs b/components/script/dom/nodeiterator.rs index d9e46a5ea44..5a87a9b4c41 100644 --- a/components/script/dom/nodeiterator.rs +++ b/components/script/dom/nodeiterator.rs @@ -9,7 +9,7 @@ use dom::bindings::codegen::Bindings::NodeFilterBinding::NodeFilterConstants; use dom::bindings::codegen::Bindings::NodeIteratorBinding; use dom::bindings::codegen::Bindings::NodeIteratorBinding::NodeIteratorMethods; use dom::bindings::error::Fallible; -use dom::bindings::js::{JS, MutHeap, Root}; +use dom::bindings::js::{JS, MutJS, Root}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; use dom::document::Document; use dom::node::Node; @@ -21,7 +21,7 @@ pub struct NodeIterator { reflector_: Reflector, root_node: JS, #[ignore_heap_size_of = "Defined in rust-mozjs"] - reference_node: MutHeap>, + reference_node: MutJS, pointer_before_reference_node: Cell, what_to_show: u32, #[ignore_heap_size_of = "Can't measure due to #6870"] @@ -35,7 +35,7 @@ impl NodeIterator { NodeIterator { reflector_: Reflector::new(), root_node: JS::from_ref(root_node), - reference_node: MutHeap::new(root_node), + reference_node: MutJS::new(root_node), pointer_before_reference_node: Cell::new(true), what_to_show: what_to_show, filter: filter diff --git a/components/script/dom/nodelist.rs b/components/script/dom/nodelist.rs index 391d21d5865..21e05fc7dcc 100644 --- a/components/script/dom/nodelist.rs +++ b/components/script/dom/nodelist.rs @@ -5,7 +5,7 @@ use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::codegen::Bindings::NodeListBinding; use dom::bindings::codegen::Bindings::NodeListBinding::NodeListMethods; -use dom::bindings::js::{JS, MutNullableHeap, Root, RootedReference}; +use dom::bindings::js::{JS, MutNullableJS, Root, RootedReference}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; use dom::node::{ChildrenMutation, Node}; use dom::window::Window; @@ -111,7 +111,7 @@ impl NodeList { pub struct ChildrenList { node: JS, #[ignore_heap_size_of = "Defined in rust-mozjs"] - last_visited: MutNullableHeap>, + last_visited: MutNullableJS, last_index: Cell, } @@ -120,7 +120,7 @@ impl ChildrenList { let last_visited = node.GetFirstChild(); ChildrenList { node: JS::from_ref(node), - last_visited: MutNullableHeap::new(last_visited.r()), + last_visited: MutNullableJS::new(last_visited.r()), last_index: Cell::new(0u32), } } diff --git a/components/script/dom/range.rs b/components/script/dom/range.rs index 723239ea3d3..e9e3a484d41 100644 --- a/components/script/dom/range.rs +++ b/components/script/dom/range.rs @@ -13,7 +13,7 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::inheritance::{CharacterDataTypeId, NodeTypeId}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutHeap, Root, RootedReference}; +use dom::bindings::js::{JS, MutJS, Root, RootedReference}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; use dom::bindings::str::DOMString; use dom::bindings::trace::JSTraceable; @@ -934,7 +934,7 @@ impl RangeMethods for Range { #[privatize] #[derive(HeapSizeOf)] pub struct BoundaryPoint { - node: MutHeap>, + node: MutJS, offset: Cell, } @@ -943,7 +943,7 @@ impl BoundaryPoint { debug_assert!(!node.is_doctype()); debug_assert!(offset <= node.len()); BoundaryPoint { - node: MutHeap::new(node), + node: MutJS::new(node), offset: Cell::new(offset), } } diff --git a/components/script/dom/request.rs b/components/script/dom/request.rs index cb338d65b29..74b61768a5e 100644 --- a/components/script/dom/request.rs +++ b/components/script/dom/request.rs @@ -17,7 +17,7 @@ use dom::bindings::codegen::Bindings::RequestBinding::RequestMode; use dom::bindings::codegen::Bindings::RequestBinding::RequestRedirect; use dom::bindings::codegen::Bindings::RequestBinding::RequestType; use dom::bindings::error::{Error, Fallible}; -use dom::bindings::js::{JS, MutNullableHeap, Root}; +use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; use dom::bindings::str::{ByteString, DOMString, USVString}; use dom::globalscope::GlobalScope; @@ -45,7 +45,7 @@ pub struct Request { reflector_: Reflector, request: DOMRefCell, body_used: Cell, - headers: MutNullableHeap>, + headers: MutNullableJS, mime_type: DOMRefCell>, #[ignore_heap_size_of = "Rc"] body_promise: DOMRefCell, BodyType)>>, diff --git a/components/script/dom/response.rs b/components/script/dom/response.rs index 278ead3c36d..06a066d410c 100644 --- a/components/script/dom/response.rs +++ b/components/script/dom/response.rs @@ -10,7 +10,7 @@ use dom::bindings::codegen::Bindings::ResponseBinding; use dom::bindings::codegen::Bindings::ResponseBinding::{ResponseMethods, ResponseType as DOMResponseType}; use dom::bindings::codegen::Bindings::XMLHttpRequestBinding::BodyInit; use dom::bindings::error::{Error, Fallible}; -use dom::bindings::js::{JS, MutNullableHeap, Root}; +use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; use dom::bindings::str::{ByteString, USVString}; use dom::globalscope::GlobalScope; @@ -32,7 +32,7 @@ use url::Position; #[dom_struct] pub struct Response { reflector_: Reflector, - headers_reflector: MutNullableHeap>, + headers_reflector: MutNullableJS, mime_type: DOMRefCell>, body_used: Cell, /// `None` can be considered a StatusCode of `0`. diff --git a/components/script/dom/serviceworkercontainer.rs b/components/script/dom/serviceworkercontainer.rs index e5662f56dee..6757fc0179d 100644 --- a/components/script/dom/serviceworkercontainer.rs +++ b/components/script/dom/serviceworkercontainer.rs @@ -5,7 +5,7 @@ use dom::bindings::codegen::Bindings::ServiceWorkerContainerBinding::{ServiceWorkerContainerMethods, Wrap}; use dom::bindings::codegen::Bindings::ServiceWorkerContainerBinding::RegistrationOptions; use dom::bindings::error::Error; -use dom::bindings::js::{JS, MutNullableHeap, Root}; +use dom::bindings::js::{JS, MutNullableJS, Root}; use dom::bindings::reflector::{DomObject, reflect_dom_object}; use dom::bindings::str::USVString; use dom::client::Client; @@ -22,7 +22,7 @@ use std::rc::Rc; #[dom_struct] pub struct ServiceWorkerContainer { eventtarget: EventTarget, - controller: MutNullableHeap>, + controller: MutNullableJS, client: JS } diff --git a/components/script/dom/servoparser/xml.rs b/components/script/dom/servoparser/xml.rs index bcbfa6c4169..616263651c3 100644 --- a/components/script/dom/servoparser/xml.rs +++ b/components/script/dom/servoparser/xml.rs @@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableHeap, Root}; +use dom::bindings::js::{JS, MutNullableJS, Root}; use dom::bindings::str::DOMString; use dom::bindings::trace::JSTraceable; use dom::comment::Comment; @@ -97,7 +97,7 @@ unsafe impl JSTraceable for XmlTokenizer, Sink>> { struct Sink { base_url: ServoUrl, document: JS, - script: MutNullableHeap>, + script: MutNullableJS, } impl<'a> TreeSink for Sink { diff --git a/components/script/dom/storageevent.rs b/components/script/dom/storageevent.rs index 172a7be9ed8..9778976dc0f 100644 --- a/components/script/dom/storageevent.rs +++ b/components/script/dom/storageevent.rs @@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::StorageEventBinding; use dom::bindings::codegen::Bindings::StorageEventBinding::StorageEventMethods; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableHeap, Root, RootedReference}; +use dom::bindings::js::{MutNullableJS, Root, RootedReference}; use dom::bindings::reflector::reflect_dom_object; use dom::bindings::str::DOMString; use dom::event::{Event, EventBubbles, EventCancelable}; @@ -23,7 +23,7 @@ pub struct StorageEvent { old_value: Option, new_value: Option, url: DOMString, - storage_area: MutNullableHeap> + storage_area: MutNullableJS } @@ -39,7 +39,7 @@ impl StorageEvent { old_value: old_value, new_value: new_value, url: url, - storage_area: MutNullableHeap::new(storage_area) + storage_area: MutNullableJS::new(storage_area) } } diff --git a/components/script/dom/touch.rs b/components/script/dom/touch.rs index 32eeb24b6e1..9b4e61788d3 100644 --- a/components/script/dom/touch.rs +++ b/components/script/dom/touch.rs @@ -4,7 +4,7 @@ use dom::bindings::codegen::Bindings::TouchBinding; use dom::bindings::codegen::Bindings::TouchBinding::TouchMethods; -use dom::bindings::js::{JS, MutHeap, Root}; +use dom::bindings::js::{MutJS, Root}; use dom::bindings::num::Finite; use dom::bindings::reflector::{Reflector, reflect_dom_object}; use dom::eventtarget::EventTarget; @@ -14,7 +14,7 @@ use dom::window::Window; pub struct Touch { reflector_: Reflector, identifier: i32, - target: MutHeap>, + target: MutJS, screen_x: f64, screen_y: f64, client_x: f64, @@ -31,7 +31,7 @@ impl Touch { Touch { reflector_: Reflector::new(), identifier: identifier, - target: MutHeap::new(target), + target: MutJS::new(target), screen_x: *screen_x, screen_y: *screen_y, client_x: *client_x, diff --git a/components/script/dom/touchevent.rs b/components/script/dom/touchevent.rs index 9b4b3a250d5..f20dc4dc012 100644 --- a/components/script/dom/touchevent.rs +++ b/components/script/dom/touchevent.rs @@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::TouchEventBinding; use dom::bindings::codegen::Bindings::TouchEventBinding::TouchEventMethods; use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutHeap, Root}; +use dom::bindings::js::{MutJS, Root}; use dom::bindings::reflector::reflect_dom_object; use dom::bindings::str::DOMString; use dom::event::{EventBubbles, EventCancelable}; @@ -18,9 +18,9 @@ use std::cell::Cell; #[dom_struct] pub struct TouchEvent { uievent: UIEvent, - touches: MutHeap>, - target_touches: MutHeap>, - changed_touches: MutHeap>, + touches: MutJS, + target_touches: MutJS, + changed_touches: MutJS, alt_key: Cell, meta_key: Cell, ctrl_key: Cell, @@ -33,9 +33,9 @@ impl TouchEvent { target_touches: &TouchList) -> TouchEvent { TouchEvent { uievent: UIEvent::new_inherited(), - touches: MutHeap::new(touches), - target_touches: MutHeap::new(target_touches), - changed_touches: MutHeap::new(changed_touches), + touches: MutJS::new(touches), + target_touches: MutJS::new(target_touches), + changed_touches: MutJS::new(changed_touches), ctrl_key: Cell::new(false), shift_key: Cell::new(false), alt_key: Cell::new(false), diff --git a/components/script/dom/treewalker.rs b/components/script/dom/treewalker.rs index 1dc3d22f1cf..194cebf98cd 100644 --- a/components/script/dom/treewalker.rs +++ b/components/script/dom/treewalker.rs @@ -9,7 +9,7 @@ use dom::bindings::codegen::Bindings::NodeFilterBinding::NodeFilterConstants; use dom::bindings::codegen::Bindings::TreeWalkerBinding; use dom::bindings::codegen::Bindings::TreeWalkerBinding::TreeWalkerMethods; use dom::bindings::error::Fallible; -use dom::bindings::js::{JS, MutHeap}; +use dom::bindings::js::{JS, MutJS}; use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; use dom::document::Document; @@ -21,7 +21,7 @@ use std::rc::Rc; pub struct TreeWalker { reflector_: Reflector, root_node: JS, - current_node: MutHeap>, + current_node: MutJS, what_to_show: u32, #[ignore_heap_size_of = "function pointers and Rc are hard"] filter: Filter @@ -34,7 +34,7 @@ impl TreeWalker { TreeWalker { reflector_: Reflector::new(), root_node: JS::from_ref(root_node), - current_node: MutHeap::new(root_node), + current_node: MutJS::new(root_node), what_to_show: what_to_show, filter: filter } diff --git a/components/script/dom/uievent.rs b/components/script/dom/uievent.rs index 289088b2977..b8c09a48994 100644 --- a/components/script/dom/uievent.rs +++ b/components/script/dom/uievent.rs @@ -7,8 +7,7 @@ use dom::bindings::codegen::Bindings::UIEventBinding; use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableHeap, RootedReference}; -use dom::bindings::js::Root; +use dom::bindings::js::{MutNullableJS, Root, RootedReference}; use dom::bindings::reflector::reflect_dom_object; use dom::bindings::str::DOMString; use dom::event::{Event, EventBubbles, EventCancelable}; @@ -21,7 +20,7 @@ use std::default::Default; #[dom_struct] pub struct UIEvent { event: Event, - view: MutNullableHeap>, + view: MutNullableJS, detail: Cell } diff --git a/components/script/dom/url.rs b/components/script/dom/url.rs index 2f3e3c3f923..cea4c898119 100644 --- a/components/script/dom/url.rs +++ b/components/script/dom/url.rs @@ -6,7 +6,7 @@ use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods; use dom::bindings::codegen::Bindings::URLBinding::{self, URLMethods}; use dom::bindings::error::{Error, ErrorResult, Fallible}; -use dom::bindings::js::{JS, MutNullableHeap, Root}; +use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; use dom::bindings::str::{DOMString, USVString}; use dom::blob::Blob; @@ -30,7 +30,7 @@ pub struct URL { url: DOMRefCell, // https://url.spec.whatwg.org/#dom-url-searchparams - search_params: MutNullableHeap>, + search_params: MutNullableJS, } impl URL { diff --git a/components/script/dom/webglframebuffer.rs b/components/script/dom/webglframebuffer.rs index 02a767958e2..2f18362122d 100644 --- a/components/script/dom/webglframebuffer.rs +++ b/components/script/dom/webglframebuffer.rs @@ -7,7 +7,7 @@ use canvas_traits::CanvasMsg; use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::WebGLFramebufferBinding; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; -use dom::bindings::js::{HeapGCValue, JS, Root}; +use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::reflect_dom_object; use dom::webglobject::WebGLObject; use dom::webglrenderbuffer::WebGLRenderbuffer; @@ -25,8 +25,6 @@ enum WebGLFramebufferAttachment { Texture { texture: JS, level: i32 }, } -impl HeapGCValue for WebGLFramebufferAttachment {} - #[dom_struct] pub struct WebGLFramebuffer { webgl_object: WebGLObject, diff --git a/components/script/dom/webglprogram.rs b/components/script/dom/webglprogram.rs index 3f18c0e313b..ad33fc2f22f 100644 --- a/components/script/dom/webglprogram.rs +++ b/components/script/dom/webglprogram.rs @@ -6,7 +6,7 @@ use canvas_traits::CanvasMsg; use dom::bindings::codegen::Bindings::WebGLProgramBinding; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; -use dom::bindings::js::{JS, MutNullableHeap, Root}; +use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::reflector::{DomObject, reflect_dom_object}; use dom::bindings::str::DOMString; use dom::webglactiveinfo::WebGLActiveInfo; @@ -27,8 +27,8 @@ pub struct WebGLProgram { is_deleted: Cell, link_called: Cell, linked: Cell, - fragment_shader: MutNullableHeap>, - vertex_shader: MutNullableHeap>, + fragment_shader: MutNullableJS, + vertex_shader: MutNullableJS, #[ignore_heap_size_of = "Defined in ipc-channel"] renderer: IpcSender, } diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index 98b160095d5..828ebd256f8 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -13,7 +13,7 @@ use dom::bindings::conversions::{array_buffer_to_vec, array_buffer_view_data, ar use dom::bindings::conversions::{array_buffer_view_to_vec, array_buffer_view_to_vec_checked}; use dom::bindings::error::{Error, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, LayoutJS, MutNullableHeap, Root}; +use dom::bindings::js::{JS, LayoutJS, MutNullableJS, Root}; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; use dom::bindings::str::DOMString; use dom::event::{Event, EventBubbles, EventCancelable}; @@ -124,13 +124,13 @@ pub struct WebGLRenderingContext { #[ignore_heap_size_of = "Defined in webrender_traits"] last_error: Cell>, texture_unpacking_settings: Cell, - bound_framebuffer: MutNullableHeap>, - bound_renderbuffer: MutNullableHeap>, - bound_texture_2d: MutNullableHeap>, - bound_texture_cube_map: MutNullableHeap>, - bound_buffer_array: MutNullableHeap>, - bound_buffer_element_array: MutNullableHeap>, - current_program: MutNullableHeap>, + bound_framebuffer: MutNullableJS, + bound_renderbuffer: MutNullableJS, + bound_texture_2d: MutNullableJS, + bound_texture_cube_map: MutNullableJS, + bound_buffer_array: MutNullableJS, + bound_buffer_element_array: MutNullableJS, + current_program: MutNullableJS, #[ignore_heap_size_of = "Because it's small"] current_vertex_attrib_0: Cell<(f32, f32, f32, f32)>, #[ignore_heap_size_of = "Because it's small"] @@ -159,13 +159,13 @@ impl WebGLRenderingContext { canvas: JS::from_ref(canvas), last_error: Cell::new(None), texture_unpacking_settings: Cell::new(CONVERT_COLORSPACE), - bound_framebuffer: MutNullableHeap::new(None), - bound_texture_2d: MutNullableHeap::new(None), - bound_texture_cube_map: MutNullableHeap::new(None), - bound_buffer_array: MutNullableHeap::new(None), - bound_buffer_element_array: MutNullableHeap::new(None), - bound_renderbuffer: MutNullableHeap::new(None), - current_program: MutNullableHeap::new(None), + bound_framebuffer: MutNullableJS::new(None), + bound_texture_2d: MutNullableJS::new(None), + bound_texture_cube_map: MutNullableJS::new(None), + bound_buffer_array: MutNullableJS::new(None), + bound_buffer_element_array: MutNullableJS::new(None), + bound_renderbuffer: MutNullableJS::new(None), + current_program: MutNullableJS::new(None), current_vertex_attrib_0: Cell::new((0f32, 0f32, 0f32, 1f32)), current_scissor: Cell::new((0, 0, size.width, size.height)), current_clear_color: Cell::new((0.0, 0.0, 0.0, 0.0)) diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index db6490b41fd..3cd48b46590 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -19,7 +19,7 @@ use dom::bindings::codegen::Bindings::WindowBinding::{ScrollBehavior, ScrollToOp use dom::bindings::codegen::UnionTypes::RequestOrUSVString; use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableHeap, Root}; +use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::num::Finite; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::DomObject; @@ -159,19 +159,19 @@ pub struct Window { history_traversal_task_source: HistoryTraversalTaskSource, #[ignore_heap_size_of = "task sources are hard"] file_reading_task_source: FileReadingTaskSource, - navigator: MutNullableHeap>, + navigator: MutNullableJS, #[ignore_heap_size_of = "channels are hard"] image_cache_thread: ImageCacheThread, #[ignore_heap_size_of = "channels are hard"] image_cache_chan: ImageCacheChan, - browsing_context: MutNullableHeap>, - history: MutNullableHeap>, - performance: MutNullableHeap>, + browsing_context: MutNullableJS, + history: MutNullableJS, + performance: MutNullableJS, navigation_start: u64, navigation_start_precise: f64, - screen: MutNullableHeap>, - session_storage: MutNullableHeap>, - local_storage: MutNullableHeap>, + screen: MutNullableJS, + session_storage: MutNullableJS, + local_storage: MutNullableJS, status: DOMRefCell, /// For sending timeline markers. Will be ignored if @@ -241,7 +241,7 @@ pub struct Window { /// All the MediaQueryLists we need to update media_query_lists: WeakMediaQueryListVec, - test_runner: MutNullableHeap>, + test_runner: MutNullableJS, } impl Window { diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs index 430757bce53..221d60c1570 100644 --- a/components/script/dom/workerglobalscope.rs +++ b/components/script/dom/workerglobalscope.rs @@ -10,7 +10,7 @@ use dom::bindings::codegen::Bindings::WorkerGlobalScopeBinding::WorkerGlobalScop use dom::bindings::codegen::UnionTypes::RequestOrUSVString; use dom::bindings::error::{Error, ErrorResult, Fallible, report_pending_exception}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableHeap, Root}; +use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::DomObject; use dom::bindings::str::DOMString; @@ -73,8 +73,8 @@ pub struct WorkerGlobalScope { closing: Option>, #[ignore_heap_size_of = "Defined in js"] runtime: Runtime, - location: MutNullableHeap>, - navigator: MutNullableHeap>, + location: MutNullableJS, + navigator: MutNullableJS, #[ignore_heap_size_of = "Defined in ipc-channel"] /// Optional `IpcSender` for sending the `DevtoolScriptControlMsg` diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index 2e1fcd465e8..578c8b7b822 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -14,7 +14,7 @@ use dom::bindings::codegen::Bindings::XMLHttpRequestBinding::XMLHttpRequestRespo use dom::bindings::conversions::ToJSValConvertible; use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutHeapJSVal, MutNullableHeap, Root}; +use dom::bindings::js::{JS, MutHeapJSVal, MutNullableJS, Root}; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::{DomObject, reflect_dom_object}; use dom::bindings::str::{ByteString, DOMString, USVString, is_token}; @@ -122,8 +122,8 @@ pub struct XMLHttpRequest { status_text: DOMRefCell, response: DOMRefCell, response_type: Cell, - response_xml: MutNullableHeap>, - response_blob: MutNullableHeap>, + response_xml: MutNullableJS, + response_blob: MutNullableJS, #[ignore_heap_size_of = "Defined in rust-mozjs"] response_json: MutHeapJSVal, #[ignore_heap_size_of = "Defined in hyper"] diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index f55d9279138..680bf2e8c9a 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -32,7 +32,7 @@ use dom::bindings::codegen::Bindings::TransitionEventBinding::TransitionEventIni use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::conversions::{ConversionResult, FromJSValConvertible, StringificationBehavior}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableHeap, Root, RootCollection}; +use dom::bindings::js::{JS, MutNullableJS, Root, RootCollection}; use dom::bindings::js::{RootCollectionPtr, RootedReference}; use dom::bindings::num::Finite; use dom::bindings::refcounted::Trusted; @@ -461,7 +461,7 @@ pub struct ScriptThread { js_runtime: Rc, /// The topmost element over the mouse. - topmost_mouse_over_target: MutNullableHeap>, + topmost_mouse_over_target: MutNullableJS, /// List of pipelines that have been owned and closed by this script thread. closed_pipelines: DOMRefCell>, @@ -686,7 +686,7 @@ impl ScriptThread { devtools_sender: ipc_devtools_sender, js_runtime: Rc::new(runtime), - topmost_mouse_over_target: MutNullableHeap::new(Default::default()), + topmost_mouse_over_target: MutNullableJS::new(Default::default()), closed_pipelines: DOMRefCell::new(HashSet::new()), scheduler_chan: state.scheduler_chan, diff --git a/tests/compiletest/plugin/compile-fail/ban-domrefcell.rs b/tests/compiletest/plugin/compile-fail/ban-domrefcell.rs index 4e65ad410a6..967654ebcce 100644 --- a/tests/compiletest/plugin/compile-fail/ban-domrefcell.rs +++ b/tests/compiletest/plugin/compile-fail/ban-domrefcell.rs @@ -13,7 +13,7 @@ use script::dom::node::Node; struct Foo { bar: DOMRefCell> - //~^ ERROR Banned type DOMRefCell> detected. Use MutHeap> instead, + //~^ ERROR Banned type DOMRefCell> detected. Use MutJS> instead, } fn main() {} diff --git a/tests/compiletest/plugin/compile-fail/ban.rs b/tests/compiletest/plugin/compile-fail/ban.rs index b789597d59d..b0ea769b4a8 100644 --- a/tests/compiletest/plugin/compile-fail/ban.rs +++ b/tests/compiletest/plugin/compile-fail/ban.rs @@ -12,7 +12,7 @@ use std::cell::Cell; struct Foo { bar: Cell - //~^ ERROR Banned type Cell detected. Use MutHeap instead, + //~^ ERROR Banned type Cell detected. Use MutJS instead, } fn main() {} From 26ab0f82a8a27bb8333eaea94458ea61c866e578 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 12 Dec 2016 10:29:35 -1000 Subject: [PATCH 4/4] Properly root the running animation list in a RootedVec --- components/script/dom/bindings/trace.rs | 20 +++++++++++++++++--- components/script/dom/document.rs | 9 ++++++--- components/script/dom/macros.rs | 11 ++++++----- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index 9c61daaaabb..50307275cd7 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -668,11 +668,25 @@ pub struct RootedVec<'a, T: 'static + JSTraceable> { root: &'a mut RootableVec, } -impl<'a, T: 'static + JSTraceable + DomObject> RootedVec<'a, JS> { +impl<'a, T: 'static + JSTraceable> RootedVec<'a, T> { /// Create a vector of items of type T that is rooted for /// the lifetime of this struct - pub fn new>>(root: &'a mut RootableVec>, iter: I) - -> RootedVec<'a, JS> { + pub fn new(root: &'a mut RootableVec) -> Self { + unsafe { + RootedTraceableSet::add(root); + } + RootedVec { + root: root, + } + } +} + +impl<'a, T: 'static + JSTraceable + DomObject> RootedVec<'a, JS> { + /// Create a vector of items of type JS that is rooted for + /// the lifetime of this struct + pub fn from_iter(root: &'a mut RootableVec>, iter: I) -> Self + where I: Iterator> + { unsafe { RootedTraceableSet::add(root); } diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 17ef9df0ed6..8957fcf5ab9 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -1521,8 +1521,11 @@ impl Document { /// https://html.spec.whatwg.org/multipage/#run-the-animation-frame-callbacks pub fn run_the_animation_frame_callbacks(&self) { - let mut animation_frame_list = - mem::replace(&mut *self.animation_frame_list.borrow_mut(), vec![]); + rooted_vec!(let mut animation_frame_list); + mem::swap( + &mut *animation_frame_list, + &mut *self.animation_frame_list.borrow_mut()); + self.running_animation_callbacks.set(true); let timing = self.window.Performance().Now(); @@ -1538,7 +1541,7 @@ impl Document { // message quickly followed by an AnimationCallbacksPresent message. if self.animation_frame_list.borrow().is_empty() { mem::swap(&mut *self.animation_frame_list.borrow_mut(), - &mut animation_frame_list); + &mut *animation_frame_list); let global_scope = self.window.upcast::(); let event = ConstellationMsg::ChangeRunningAnimationsState(global_scope.pipeline_id(), AnimationState::NoAnimationCallbacksPresent); diff --git a/components/script/dom/macros.rs b/components/script/dom/macros.rs index 99b06bae39d..f2174bdd552 100644 --- a/components/script/dom/macros.rs +++ b/components/script/dom/macros.rs @@ -537,14 +537,15 @@ macro_rules! document_and_element_event_handlers( #[macro_export] macro_rules! rooted_vec { (let mut $name:ident) => { - rooted_vec!(let mut $name <- ::std::iter::empty()) + let mut root = $crate::dom::bindings::trace::RootableVec::new_unrooted(); + let mut $name = $crate::dom::bindings::trace::RootedVec::new(&mut root); }; (let $name:ident <- $iter:expr) => { - let mut __root = $crate::dom::bindings::trace::RootableVec::new_unrooted(); - let $name = $crate::dom::bindings::trace::RootedVec::new(&mut __root, $iter); + let mut root = $crate::dom::bindings::trace::RootableVec::new_unrooted(); + let $name = $crate::dom::bindings::trace::RootedVec::from_iter(&mut root, $iter); }; (let mut $name:ident <- $iter:expr) => { - let mut __root = $crate::dom::bindings::trace::RootableVec::new_unrooted(); - let mut $name = $crate::dom::bindings::trace::RootedVec::new(&mut __root, $iter); + let mut root = $crate::dom::bindings::trace::RootableVec::new_unrooted(); + let mut $name = $crate::dom::bindings::trace::RootedVec::from_iter(&mut root, $iter); } }