aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/node.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2017-05-10 18:20:31 -0400
committerJosh Matthews <josh@joshmatthews.net>2017-05-15 14:12:08 -0400
commitb0bf2b4bad636acfba66d55571b417ebae795408 (patch)
tree5a729fc75babf869f51a16a4bccab1a023115da4 /components/script/dom/node.rs
parent2ca80a800f8c1f85135bbdb605f69641ae9aa7d0 (diff)
downloadservo-b0bf2b4bad636acfba66d55571b417ebae795408.tar.gz
servo-b0bf2b4bad636acfba66d55571b417ebae795408.zip
Make methods storing layout-originating nodes unsafe.
Diffstat (limited to 'components/script/dom/node.rs')
-rw-r--r--components/script/dom/node.rs18
1 files changed, 8 insertions, 10 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index 81a06850757..6d16cac6731 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -927,20 +927,18 @@ fn first_node_not_in<I>(mut nodes: I, not_in: &[NodeOrString]) -> Option<Root<No
/// If the given untrusted node address represents a valid DOM node in the given runtime,
/// returns it.
#[allow(unsafe_code)]
-pub fn from_untrusted_node_address(_runtime: *mut JSRuntime, candidate: UntrustedNodeAddress)
+pub unsafe fn from_untrusted_node_address(_runtime: *mut JSRuntime, candidate: UntrustedNodeAddress)
-> Root<Node> {
- unsafe {
- // https://github.com/servo/servo/issues/6383
- let candidate: uintptr_t = mem::transmute(candidate.0);
+ // https://github.com/servo/servo/issues/6383
+ let candidate: uintptr_t = mem::transmute(candidate.0);
// let object: *mut JSObject = jsfriendapi::bindgen::JS_GetAddressableObject(runtime,
// candidate);
- let object: *mut JSObject = mem::transmute(candidate);
- if object.is_null() {
- panic!("Attempted to create a `JS<Node>` from an invalid pointer!")
- }
- let boxed_node = conversions::private_from_object(object) as *const Node;
- Root::from_ref(&*boxed_node)
+ let object: *mut JSObject = mem::transmute(candidate);
+ if object.is_null() {
+ panic!("Attempted to create a `JS<Node>` from an invalid pointer!")
}
+ let boxed_node = conversions::private_from_object(object) as *const Node;
+ Root::from_ref(&*boxed_node)
}
#[allow(unsafe_code)]