Add LayoutJS<Node>::from_trusted_node_address()

This commit is contained in:
Tetsuharu OHZEKI 2015-01-25 02:57:38 +09:00
parent 8889041c19
commit 9f57fa17d0
3 changed files with 14 additions and 4 deletions

View file

@ -191,6 +191,16 @@ impl JS<Node> {
}
}
impl LayoutJS<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> {
let TrustedNodeAddress(addr) = inner;
LayoutJS {
ptr: NonZero::new(addr as *const Node)
}
}
}
impl<T: Reflectable> JS<T> {
/// Create a new JS-owned value wrapped from a raw Rust pointer.
pub unsafe fn from_raw(raw: *const T) -> JS<T> {