diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2017-09-26 01:30:06 +0200 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2017-09-26 09:49:04 +0200 |
commit | e2dac78d3600cb4b2b4474f1db4f0fcaadbe24ea (patch) | |
tree | 3a0ae2014f80a0e7af0d76e7f7e3d043769293a8 /components/script/dom/bindings/root.rs | |
parent | c52fd0a78041ec22db1c4b391556368cd8b87b02 (diff) | |
download | servo-e2dac78d3600cb4b2b4474f1db4f0fcaadbe24ea.tar.gz servo-e2dac78d3600cb4b2b4474f1db4f0fcaadbe24ea.zip |
Rename LayoutJS<T> to LayoutDom<T>
Diffstat (limited to 'components/script/dom/bindings/root.rs')
-rw-r--r-- | components/script/dom/bindings/root.rs | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/components/script/dom/bindings/root.rs b/components/script/dom/bindings/root.rs index dbfe4023d63..f845bd3bd30 100644 --- a/components/script/dom/bindings/root.rs +++ b/components/script/dom/bindings/root.rs @@ -68,10 +68,10 @@ impl<T> HeapSizeOf for Dom<T> { } impl<T> Dom<T> { - /// Returns `LayoutJS<T>` containing the same pointer. - pub unsafe fn to_layout(&self) -> LayoutJS<T> { + /// Returns `LayoutDom<T>` containing the same pointer. + pub unsafe fn to_layout(&self) -> LayoutDom<T> { debug_assert!(thread_state::get().is_layout()); - LayoutJS { + LayoutDom { ptr: self.ptr.clone(), } } @@ -124,32 +124,32 @@ unsafe impl<T: DomObject> JSTraceable for Dom<T> { /// An unrooted reference to a DOM object for use in layout. `Layout*Helpers` /// traits must be implemented on this. #[allow_unrooted_interior] -pub struct LayoutJS<T> { +pub struct LayoutDom<T> { ptr: NonZero<*const T>, } -impl<T: Castable> LayoutJS<T> { +impl<T: Castable> LayoutDom<T> { /// Cast a DOM object root upwards to one of the interfaces it derives from. - pub fn upcast<U>(&self) -> LayoutJS<U> + pub fn upcast<U>(&self) -> LayoutDom<U> where U: Castable, T: DerivedFrom<U> { debug_assert!(thread_state::get().is_layout()); let ptr: *const T = self.ptr.get(); - LayoutJS { + LayoutDom { ptr: unsafe { NonZero::new_unchecked(ptr as *const U) }, } } /// Cast a DOM object downwards to one of the interfaces it might implement. - pub fn downcast<U>(&self) -> Option<LayoutJS<U>> + pub fn downcast<U>(&self) -> Option<LayoutDom<U>> where U: DerivedFrom<T> { debug_assert!(thread_state::get().is_layout()); unsafe { if (*self.unsafe_get()).is::<U>() { let ptr: *const T = self.ptr.get(); - Some(LayoutJS { + Some(LayoutDom { ptr: NonZero::new_unchecked(ptr as *const U), }) } else { @@ -159,7 +159,7 @@ impl<T: Castable> LayoutJS<T> { } } -impl<T: DomObject> LayoutJS<T> { +impl<T: DomObject> LayoutDom<T> { /// Get the reflector. pub unsafe fn get_jsobject(&self) -> *mut JSObject { debug_assert!(thread_state::get().is_layout()); @@ -167,7 +167,7 @@ impl<T: DomObject> LayoutJS<T> { } } -impl<T> Copy for LayoutJS<T> {} +impl<T> Copy for LayoutDom<T> {} impl<T> PartialEq for Dom<T> { fn eq(&self, other: &Dom<T>) -> bool { @@ -177,13 +177,13 @@ impl<T> PartialEq for Dom<T> { impl<T> Eq for Dom<T> {} -impl<T> PartialEq for LayoutJS<T> { - fn eq(&self, other: &LayoutJS<T>) -> bool { +impl<T> PartialEq for LayoutDom<T> { + fn eq(&self, other: &LayoutDom<T>) -> bool { self.ptr == other.ptr } } -impl<T> Eq for LayoutJS<T> {} +impl<T> Eq for LayoutDom<T> {} impl<T> Hash for Dom<T> { fn hash<H: Hasher>(&self, state: &mut H) { @@ -191,7 +191,7 @@ impl<T> Hash for Dom<T> { } } -impl<T> Hash for LayoutJS<T> { +impl<T> Hash for LayoutDom<T> { fn hash<H: Hasher>(&self, state: &mut H) { self.ptr.hash(state) } @@ -208,23 +208,23 @@ impl <T> Clone for Dom<T> { } } -impl <T> Clone for LayoutJS<T> { +impl <T> Clone for LayoutDom<T> { #[inline] - fn clone(&self) -> LayoutJS<T> { + fn clone(&self) -> LayoutDom<T> { debug_assert!(thread_state::get().is_layout()); - LayoutJS { + LayoutDom { ptr: self.ptr.clone(), } } } -impl LayoutJS<Node> { +impl LayoutDom<Node> { /// Create a new JS-owned value wrapped from an address known to be a /// `Node` pointer. - pub unsafe fn from_trusted_node_address(inner: TrustedNodeAddress) -> LayoutJS<Node> { + pub unsafe fn from_trusted_node_address(inner: TrustedNodeAddress) -> LayoutDom<Node> { debug_assert!(thread_state::get().is_layout()); let TrustedNodeAddress(addr) = inner; - LayoutJS { + LayoutDom { ptr: NonZero::new_unchecked(addr as *const Node), } } @@ -327,10 +327,10 @@ impl<T: DomObject> MutNullableDom<T> { } } - /// Retrieve a copy of the inner optional `Dom<T>` as `LayoutJS<T>`. + /// Retrieve a copy of the inner optional `Dom<T>` as `LayoutDom<T>`. /// For use by layout, which can't use safe types like Temporary. #[allow(unrooted_must_root)] - pub unsafe fn get_inner_as_layout(&self) -> Option<LayoutJS<T>> { + pub unsafe fn get_inner_as_layout(&self) -> Option<LayoutDom<T>> { debug_assert!(thread_state::get().is_layout()); ptr::read(self.ptr.get()).map(|js| js.to_layout()) } @@ -442,7 +442,7 @@ unsafe impl<T: DomObject> JSTraceable for OnceCellJS<T> { } } -impl<T: DomObject> LayoutJS<T> { +impl<T: DomObject> LayoutDom<T> { /// Returns an unsafe pointer to the interior of this JS object. This is /// the only method that be safely accessed from layout. (The fact that /// this is unsafe is what necessitates the layout wrappers.) |