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 0008790c973..3748917038f 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -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 } } @@ -5498,7 +5498,7 @@ impl ${name}Cast { #[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)] diff --git a/components/script/dom/bindings/js.rs b/components/script/dom/bindings/js.rs index cc36600318c..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. @@ -431,13 +430,6 @@ impl LayoutJS { } } -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 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()) }