diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index 8c30d649db3..40d675bd4d6 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -197,7 +197,7 @@ impl<'a> PartialEq for LayoutNode<'a> { impl<'ln> TLayoutNode for LayoutNode<'ln> { unsafe fn new_with_this_lifetime(&self, node: &LayoutJS) -> LayoutNode<'ln> { LayoutNode { - node: node.transmute_copy(), + node: *node, chain: self.chain, } } @@ -728,10 +728,7 @@ impl<'ln> TLayoutNode for ThreadSafeLayoutNode<'ln> { /// Creates a new layout node with the same lifetime as this layout node. unsafe fn new_with_this_lifetime(&self, node: &LayoutJS) -> ThreadSafeLayoutNode<'ln> { ThreadSafeLayoutNode { - node: LayoutNode { - node: node.transmute_copy(), - chain: self.node.chain, - }, + node: self.node.new_with_this_lifetime(node), pseudo: PseudoElementType::Normal, } } diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 1ef3cc0b810..3748917038f 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -5453,7 +5453,7 @@ impl ${name}Cast { #[inline(always)] pub fn to_ref<'a, T: ${toBound}+Reflectable>(base: JSRef<'a, T>) -> Option> { match base.${checkFn}() { - true => unsafe { Some(base.transmute()) }, + true => Some(unsafe { mem::transmute(base) }), false => None } } @@ -5461,7 +5461,7 @@ impl ${name}Cast { #[inline(always)] pub fn to_borrowed_ref<'a, 'b, T: ${toBound}+Reflectable>(base: &'a JSRef<'b, T>) -> Option<&'a JSRef<'b, ${name}>> { match base.${checkFn}() { - true => unsafe { Some(base.transmute_borrowed()) }, + true => Some(unsafe { mem::transmute(base) }), false => None } } @@ -5471,7 +5471,7 @@ impl ${name}Cast { pub fn to_layout_js(base: &LayoutJS) -> Option> { unsafe { match (*base.unsafe_get()).${checkFn}() { - true => Some(base.transmute_copy()), + true => Some(mem::transmute_copy(base)), false => None } } @@ -5479,33 +5479,31 @@ impl ${name}Cast { #[inline(always)] pub fn to_temporary(base: Temporary) -> Option> { - let base = base.root(); - let base = base.r(); - match base.${checkFn}() { - true => Some(Temporary::from_rooted(unsafe { base.transmute() })), + match base.root().r().${checkFn}() { + true => Some(unsafe { mem::transmute(base) }), false => None } } #[inline(always)] pub fn from_ref<'a, T: ${fromBound}+Reflectable>(derived: JSRef<'a, T>) -> JSRef<'a, ${name}> { - unsafe { derived.transmute() } + unsafe { mem::transmute(derived) } } #[inline(always)] pub fn from_borrowed_ref<'a, 'b, T: ${fromBound}+Reflectable>(derived: &'a JSRef<'b, T>) -> &'a JSRef<'b, ${name}> { - unsafe { derived.transmute_borrowed() } + unsafe { mem::transmute(derived) } } #[inline(always)] #[allow(unrooted_must_root)] pub fn from_layout_js(derived: &LayoutJS) -> LayoutJS<${name}> { - unsafe { derived.transmute_copy() } + unsafe { mem::transmute_copy(derived) } } #[inline(always)] pub fn from_temporary(derived: Temporary) -> Temporary<${name}> { - unsafe { derived.transmute() } + unsafe { mem::transmute(derived) } } #[inline(always)] diff --git a/components/script/dom/bindings/js.rs b/components/script/dom/bindings/js.rs index 6b3ce4a555c..cb8aaf04160 100644 --- a/components/script/dom/bindings/js.rs +++ b/components/script/dom/bindings/js.rs @@ -64,7 +64,6 @@ use std::cell::{Cell, UnsafeCell}; use std::default::Default; use std::intrinsics::return_address; use std::marker::PhantomData; -use std::mem; use std::ops::Deref; /// An unrooted, JS-owned value. Must not be held across a GC. @@ -186,13 +185,6 @@ impl Temporary { unsafe fn inner(&self) -> JS { self.inner.clone() } - - /// Returns `self` as a `Temporary` of another type. For use by - /// `InheritTypes` only. - //XXXjdm It would be lovely if this could be private. - pub unsafe fn transmute(self) -> Temporary { - mem::transmute(self) - } } /// A traced reference to a DOM object. Must only be used as a field in other @@ -438,20 +430,6 @@ impl LayoutJS { } } -impl JS { - /// Return `self` as a `JS` of another type. - pub unsafe fn transmute_copy(&self) -> JS { - mem::transmute_copy(self) - } -} - -impl LayoutJS { - /// Return `self` as a `LayoutJS` of another type. - pub unsafe fn transmute_copy(&self) -> LayoutJS { - mem::transmute_copy(self) - } -} - /// Get an `Option>` out of an `Option>` pub trait RootedReference { /// Obtain a safe optional reference to the wrapped JS owned-value that @@ -748,18 +726,6 @@ impl<'a, 'b, T> PartialEq> for JSRef<'a, T> { } impl<'a,T> JSRef<'a,T> { - /// Return `self` as a `JSRef` of another type. - //XXXjdm It would be lovely if this could be private. - pub unsafe fn transmute(self) -> JSRef<'a, To> { - mem::transmute(self) - } - - /// Return `self` as a borrowed reference to a `JSRef` of another type. - // FIXME(zwarich): It would be nice to get rid of this entirely. - pub unsafe fn transmute_borrowed<'b, To>(&'b self) -> &'b JSRef<'a, To> { - mem::transmute(self) - } - /// Return an unrooted `JS` for the inner pointer. pub fn unrooted(&self) -> JS { JS { diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index d47cf4feeaa..3f0ba0e8ca1 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -389,7 +389,7 @@ impl LayoutElementHelpers for LayoutJS { if (*self.unsafe_get()).namespace != ns!(HTML) { return false } - let node: LayoutJS = self.transmute_copy(); + let node = NodeCast::from_layout_js(&self); node.owner_doc_for_layout().is_html_document_for_layout() } diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index a34357c37b1..d8f5407a9d1 100644 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -164,7 +164,7 @@ impl LayoutHTMLInputElementHelpers for LayoutJS { #[allow(unsafe_code)] unsafe fn get_raw_attr_value(input: LayoutJS) -> Option { - let elem: LayoutJS = input.transmute_copy(); + let elem = ElementCast::from_layout_js(&input); (*elem.unsafe_get()).get_attr_val_for_layout(&ns!(""), &atom!("value")) .map(|s| s.to_owned()) }