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

@ -2458,8 +2458,8 @@ def CreateBindingJSObject(descriptor, parent):
if descriptor.proxy:
handler = """ //let cache = ptr::to_unsafe_ptr(aObject.get_wrappercache());
let script_context = task_from_context(aCx);
let handler = (*script_context).dom_static.proxy_handlers.get(&(PrototypeList::id::%s as uint));
let page = page_from_context(aCx);
let handler = (*page).js_info.get_ref().dom_static.proxy_handlers.get(&(PrototypeList::id::%s as uint));
""" % descriptor.name
create = handler + """ let obj = NewProxyObject(aCx, *handler,
ptr::to_unsafe_ptr(&RUST_PRIVATE_TO_JSVAL(squirrel_away(aObject) as *libc::c_void)),
@ -2629,8 +2629,8 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
elif props.hasNonChromeOnly():
idsToInit.append(props.variableName(False))
if len(idsToInit) > 0:
setup = CGList([CGGeneric("let script_context = task_from_context(aCx);"),
CGList([CGGeneric("let %s_ids_mut = (*script_context).dom_static.attribute_ids.get(&(PrototypeList::id::%s as uint));" % (varname, self.descriptor.name)) for varname in idsToInit], '\n')], '\n')
setup = CGList([CGGeneric("let page = page_from_context(aCx);"),
CGList([CGGeneric("let %s_ids_mut = (*page).js_info.get_ref().dom_static.attribute_ids.get(&(PrototypeList::id::%s as uint));" % (varname, self.descriptor.name)) for varname in idsToInit], '\n')], '\n')
initIds = CGList(
[CGGeneric("!InitIds(aCx, %s, *%s_ids_mut)" % (varname, varname)) for
varname in idsToInit], ' ||\n')
@ -2818,7 +2818,7 @@ class CGDefineDOMInterfaceMethod(CGAbstractMethod):
else:
getter = "GetConstructorObject"
body = " let script_context = task_from_context(aCx);\n"
body = "let page = page_from_context(aCx);"
#XXXjdm This self.descriptor.concrete check shouldn't be necessary
if not self.descriptor.concrete or self.descriptor.proxy:
body += """ let traps = ProxyTraps {
@ -2851,12 +2851,12 @@ class CGDefineDOMInterfaceMethod(CGAbstractMethod):
getElementIfPresent: ptr::null(),
getPrototypeOf: ptr::null()
};
(*script_context).dom_static.proxy_handlers.insert(PrototypeList::id::%s as uint,
(*page).js_info.get_mut_ref().dom_static.proxy_handlers.insert(PrototypeList::id::%s as uint,
CreateProxyHandler(ptr::to_unsafe_ptr(&traps), ptr::to_unsafe_ptr(&Class) as *libc::c_void));
""" % self.descriptor.name
else:
body += """ (*script_context).dom_static.attribute_ids.insert(PrototypeList::id::%s as uint,
body += """ (*page).js_info.get_ref().dom_static.attribute_ids.insert(PrototypeList::id::%s as uint,
vec::cast_to_mut(vec::from_slice(sAttributes_ids)));
""" % self.descriptor.name
body = "" #XXXjdm xray stuff isn't necessary yet
@ -3445,12 +3445,12 @@ class CGXrayHelper(CGAbstractExternMethod):
def definition_body(self):
varNames = self.properties.variableNames(True)
setup = "let script_context = task_from_context(cx);\n"
setup = "let page = page_from_context(cx);\n"
methods = self.properties.methods
if methods.hasNonChromeOnly() or methods.hasChromeOnly():
methodArgs = "Some(vec::zip_slice(%(methods)s, *method_ids))" % varNames
setup += "let method_ids = (*script_context).dom_static.method_ids.get(&(PrototypeList::id::ClientRect as uint));\n"
setup += "let method_ids = (*page).js_info.get_ref().dom_static.method_ids.get(&(PrototypeList::id::ClientRect as uint));\n"
else:
methodArgs = "None"
methodArgs = CGGeneric(methodArgs)
@ -3458,7 +3458,7 @@ class CGXrayHelper(CGAbstractExternMethod):
attrs = self.properties.attrs
if attrs.hasNonChromeOnly() or attrs.hasChromeOnly():
attrArgs = "Some(vec::zip_slice(%(attrs)s, *attr_ids))" % varNames
setup += "let attr_ids = (*script_context).dom_static.attribute_ids.get(&(PrototypeList::id::ClientRect as uint));\n"
setup += "let attr_ids = (*page).js_info.get_ref().dom_static.attribute_ids.get(&(PrototypeList::id::ClientRect as uint));\n"
else:
attrArgs = "None"
attrArgs = CGGeneric(attrArgs)
@ -3466,7 +3466,7 @@ class CGXrayHelper(CGAbstractExternMethod):
consts = self.properties.consts
if consts.hasNonChromeOnly() or consts.hasChromeOnly():
constArgs = "Some(vec::zip_slice(%(consts)s, *const_ids))" % varNames
setup += "let const_ids = (*script_context).dom_static.constant_ids.get(&(PrototypeList::id::ClientRect as uint));\n"
setup += "let const_ids = (*page).js_info.get_ref().dom_static.constant_ids.get(&(PrototypeList::id::ClientRect as uint));\n"
else:
constArgs = "None"
constArgs = CGGeneric(constArgs)
@ -3751,8 +3751,8 @@ class CGClassConstructHook(CGAbstractExternMethod):
//XXXjdm Gecko obtains a GlobalObject from the global (maybe from the private value,
// or through unwrapping a slot or something). We'll punt and get the Window
// from the context for now.
let script_context = task_from_context(cx);
let global = (*script_context).root_frame.get_ref().window;
let page = page_from_context(cx);
let global = (*page).frame.get_ref().window;
let obj = global.get_wrappercache().get_wrapper();
"""
preArgs = ["global"]
@ -4365,7 +4365,7 @@ class CGBindingRoot(CGThing):
'dom::uievent::*', #XXXjdm
'dom::windowproxy::*', #XXXjdm
'dom::bindings::codegen::*', #XXXjdm
'script_task::task_from_context',
'script_task::{JSPageInfo, page_from_context}',
'dom::bindings::utils::EnumEntry',
'dom::node::ScriptView',
'std::cast',