aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorTetsuharu OHZEKI <saneyuki.snyk@gmail.com>2015-01-25 02:57:38 +0900
committerTetsuharu OHZEKI <saneyuki.snyk@gmail.com>2015-02-01 01:54:38 +0900
commit9f57fa17d0e5b188b4c33145c659f2abf2315a22 (patch)
treecb1ef3b0e4d7933106aab59f4ceeac857260b842 /components/script
parent8889041c1957232fe1acabb255c131686c4a924a (diff)
downloadservo-9f57fa17d0e5b188b4c33145c659f2abf2315a22.tar.gz
servo-9f57fa17d0e5b188b4c33145c659f2abf2315a22.zip
Add LayoutJS<Node>::from_trusted_node_address()
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/bindings/js.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/components/script/dom/bindings/js.rs b/components/script/dom/bindings/js.rs
index 2e229a28df3..3b74bd65194 100644
--- a/components/script/dom/bindings/js.rs
+++ b/components/script/dom/bindings/js.rs
@@ -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> {