diff options
Diffstat (limited to 'src/components/script/dom/node.rs')
-rw-r--r-- | src/components/script/dom/node.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/components/script/dom/node.rs b/src/components/script/dom/node.rs index 258717492af..6e94d2f8ef0 100644 --- a/src/components/script/dom/node.rs +++ b/src/components/script/dom/node.rs @@ -7,12 +7,13 @@ 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; -use dom::element::{Element, ElementTypeId, HTMLImageElement, HTMLImageElementTypeId, HTMLIframeElementTypeId, HTMLIframeElement}; +use dom::element::{Element, ElementTypeId, HTMLImageElementTypeId, HTMLIframeElementTypeId, HTMLIframeElement}; use dom::element::{HTMLStyleElementTypeId}; +use dom::htmlimageelement::HTMLImageElement; use dom::window::Window; use std::cast; @@ -235,6 +236,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 { |