mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Remove useless unsafe methods on LayoutJS<T>
This commit is contained in:
parent
9369b616ce
commit
4e7b9d319c
5 changed files with 6 additions and 17 deletions
|
@ -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<Node>) -> 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<Node>) -> ThreadSafeLayoutNode<'ln> {
|
||||
ThreadSafeLayoutNode {
|
||||
node: LayoutNode {
|
||||
node: node.transmute_copy(),
|
||||
chain: self.node.chain,
|
||||
},
|
||||
node: self.node.new_with_this_lifetime(node),
|
||||
pseudo: PseudoElementType::Normal,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5471,7 +5471,7 @@ impl ${name}Cast {
|
|||
pub fn to_layout_js<T: ${toBound}+Reflectable>(base: &LayoutJS<T>) -> Option<LayoutJS<${name}>> {
|
||||
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<T: ${fromBound}+Reflectable>(derived: &LayoutJS<T>) -> LayoutJS<${name}> {
|
||||
unsafe { derived.transmute_copy() }
|
||||
unsafe { mem::transmute_copy(derived) }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
|
|
@ -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<T: Reflectable> LayoutJS<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<From> LayoutJS<From> {
|
||||
/// Return `self` as a `LayoutJS` of another type.
|
||||
pub unsafe fn transmute_copy<To>(&self) -> LayoutJS<To> {
|
||||
mem::transmute_copy(self)
|
||||
}
|
||||
}
|
||||
|
||||
/// Get an `Option<JSRef<T>>` out of an `Option<Root<T>>`
|
||||
pub trait RootedReference<T> {
|
||||
/// Obtain a safe optional reference to the wrapped JS owned-value that
|
||||
|
|
|
@ -389,7 +389,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
|
|||
if (*self.unsafe_get()).namespace != ns!(HTML) {
|
||||
return false
|
||||
}
|
||||
let node: LayoutJS<Node> = self.transmute_copy();
|
||||
let node = NodeCast::from_layout_js(&self);
|
||||
node.owner_doc_for_layout().is_html_document_for_layout()
|
||||
}
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ impl LayoutHTMLInputElementHelpers for LayoutJS<HTMLInputElement> {
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_raw_attr_value(input: LayoutJS<HTMLInputElement>) -> Option<String> {
|
||||
let elem: LayoutJS<Element> = 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())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue