aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/node.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/script/dom/node.rs')
-rw-r--r--src/components/script/dom/node.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/components/script/dom/node.rs b/src/components/script/dom/node.rs
index 258717492af..920eb7a003c 100644
--- a/src/components/script/dom/node.rs
+++ b/src/components/script/dom/node.rs
@@ -7,7 +7,7 @@
use dom::bindings::codegen::TextBinding;
use dom::bindings::node;
use dom::bindings::utils::{WrapperCache, DOMString, null_string, ErrorResult};
-use dom::bindings::utils::{BindingObject, CacheableWrapper};
+use dom::bindings::utils::{BindingObject, CacheableWrapper, rust_box};
use dom::bindings;
use dom::characterdata::CharacterData;
use dom::document::AbstractDocument;
@@ -235,6 +235,15 @@ impl<'self, View> AbstractNode<View> {
}
}
+ /// Allow consumers to recreate an AbstractNode from the raw boxed type.
+ /// Must only be used in situations where the boxed type is in the inheritance
+ /// chain for nodes.
+ pub fn from_box<T>(ptr: *mut rust_box<T>) -> AbstractNode<View> {
+ AbstractNode {
+ obj: ptr as *mut Node<View>
+ }
+ }
+
/// Returns the layout data, unsafely cast to whatever type layout wishes. Only layout is
/// allowed to call this. This is wildly unsafe and is therefore marked as such.
pub unsafe fn unsafe_layout_data<T>(self) -> @mut T {