structural changes to support Iframes

This commit is contained in:
Tim Kuehn 2013-07-12 20:19:48 -07:00
parent eaa20edcd7
commit e9888b299c
30 changed files with 1416 additions and 835 deletions

View file

@ -13,7 +13,6 @@ use dom::htmlcollection::HTMLCollection;
use dom::node::{AbstractNode, ScriptView, Node};
use dom::window::Window;
use dom::windowproxy::WindowProxy;
use script_task::global_script_context;
use js::JSPROP_ENUMERATE;
use js::glue::*;
@ -37,20 +36,20 @@ pub fn Document(root: AbstractNode<ScriptView>, window: Option<@mut Window>) ->
wrapper: WrapperCache::new(),
window: window
};
let compartment = global_script_context().js_compartment;
let compartment = (*window.get_ref().page).js_info.get_ref().js_compartment;
do root.with_base |base| {
assert!(base.wrapper.get_wrapper().is_not_null());
let rootable = base.wrapper.get_rootable();
JS_AddObjectRoot(compartment.cx.ptr, rootable);
}
let cx = global_script_context().js_compartment.cx.ptr;
let cx = (*window.get_ref().page).js_info.get_ref().js_compartment.cx.ptr;
doc.wrap_object_shared(cx, ptr::null()); //XXXjdm a proper scope would be nice
match window {
Some(win) => {
//FIXME: This is a hack until Window is autogenerated
let compartment = (*win.script_task).js_compartment;
let compartment = (*win.page).js_info.get_ref().js_compartment;
compartment.define_property(~"document",
RUST_OBJECT_TO_JSVAL(doc.wrapper.wrapper),
GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
@ -89,7 +88,8 @@ impl Document {
parent: Element::new(HTMLHtmlElementTypeId, ~"html")
};
let root = unsafe { Node::as_abstract_node(root) };
let cx = unsafe {(*_owner.page).js_info.get_ref().js_compartment.cx.ptr};
let root = unsafe { Node::as_abstract_node(cx, root) };
Document(root, None)
}
@ -129,15 +129,27 @@ impl Document {
}
}
};
HTMLCollection::new(elements)
let win = self.window.get_ref();
let cx = unsafe {(*win.page).js_info.get_ref().js_compartment.cx.ptr};
let cache = win.get_wrappercache();
let scope = cache.get_wrapper();
HTMLCollection::new(elements, cx, scope)
}
pub fn GetElementsByTagNameNS(&self, _ns: DOMString, _tag: DOMString) -> @mut HTMLCollection {
HTMLCollection::new(~[])
let win = self.window.get_ref();
let cx = unsafe {(*win.page).js_info.get_ref().js_compartment.cx.ptr};
let cache = win.get_wrappercache();
let scope = cache.get_wrapper();
HTMLCollection::new(~[], cx, scope)
}
pub fn GetElementsByClassName(&self, _class: DOMString) -> @mut HTMLCollection {
HTMLCollection::new(~[])
let win = self.window.get_ref();
let cx = unsafe {(*win.page).js_info.get_ref().js_compartment.cx.ptr};
let cache = win.get_wrappercache();
let scope = cache.get_wrapper();
HTMLCollection::new(~[], cx, scope)
}
@ -276,7 +288,11 @@ impl Document {
}
}
};
HTMLCollection::new(elements)
let win = self.window.get_ref();
let cx = unsafe {(*win.page).js_info.get_ref().js_compartment.cx.ptr};
let cache = win.get_wrappercache();
let scope = cache.get_wrapper();
HTMLCollection::new(elements, cx, scope)
}
pub fn content_changed(&self) {
@ -287,7 +303,7 @@ impl Document {
pub fn teardown(&self) {
unsafe {
let compartment = global_script_context().js_compartment;
let compartment = (*self.window.get_ref().page).js_info.get_ref().js_compartment;
do self.root.with_base |node| {
assert!(node.wrapper.get_wrapper().is_not_null());
let rootable = node.wrapper.get_rootable();