Generate bindings for HTMLDivElement, and pass abstract type to methods that need access to the opaque wrappers.

This commit is contained in:
Josh Matthews 2013-08-06 16:08:38 -04:00
parent 08ed6d318e
commit 65a33f60e5
10 changed files with 161 additions and 131 deletions

View file

@ -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 {