auto merge of #1829 : Ms2ger/servo/page_from_context, r=jdm

This commit is contained in:
bors-servo 2014-03-05 15:13:29 -05:00
commit b9b4eebab5
2 changed files with 3 additions and 51 deletions

View file

@ -2675,38 +2675,6 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
# if we don't need to create anything, why are we generating this? # if we don't need to create anything, why are we generating this?
assert needInterfaceObject or needInterfacePrototypeObject assert needInterfaceObject or needInterfacePrototypeObject
idsToInit = []
if False: #XXXjdm don't need xray stuff yet
for var in self.properties.xrayRelevantArrayNames():
props = getattr(self.properties, var)
# We only have non-chrome ids to init if we have no chrome ids.
if props.hasChromeOnly():
idsToInit.append(props.variableName(True))
elif props.hasNonChromeOnly():
idsToInit.append(props.variableName(False))
if len(idsToInit) > 0:
setup = CGList([CGGeneric("let page = page_from_context(aCx);"),
CGList([CGGeneric("let mut js_info = (*page).js_info();\n"
"let %s_ids_mut = js_info.get().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')
if len(idsToInit) > 1:
initIds = CGWrapper(initIds, pre="(", post=")", reindent=True)
initIds = CGList(
[CGGeneric("%s_ids_mut[0] == JSID_VOID &&" % idsToInit[0]), initIds],
"\n")
initIds = CGWrapper(initIds, pre="if ", post=" {", reindent=True)
initIds = CGList(
[setup,
initIds,
CGGeneric((" %s_ids_mut[0] = JSID_VOID;\n"
" return ptr::null();") % idsToInit[0]),
CGGeneric("}")],
"\n")
else:
initIds = None
prefCacheData = [] prefCacheData = []
for var in self.properties.arrayNames(): for var in self.properties.arrayNames():
props = getattr(self.properties, var) props = getattr(self.properties, var)
@ -2773,7 +2741,7 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
chrome = None chrome = None
functionBody = CGList( functionBody = CGList(
[CGGeneric(getParentProto), initIds, prefCache, chrome, [CGGeneric(getParentProto), prefCache, chrome,
CGGeneric(call % self.properties.variableNames(False))], CGGeneric(call % self.properties.variableNames(False))],
"\n\n") "\n\n")
#return CGIndenter(CGWrapper(functionBody, pre="/*", post="*/return ptr::null()")).define() #return CGIndenter(CGWrapper(functionBody, pre="/*", post="*/return ptr::null()")).define()
@ -5294,7 +5262,7 @@ class CGBindingRoot(CGThing):
'dom::bindings::codegen::*', #XXXjdm 'dom::bindings::codegen::*', #XXXjdm
'dom::bindings::codegen::UnionTypes::*', #XXXjdm 'dom::bindings::codegen::UnionTypes::*', #XXXjdm
'dom::bindings::codegen::UnionConversions::*', #XXXjdm 'dom::bindings::codegen::UnionConversions::*', #XXXjdm
'script_task::{JSPageInfo, page_from_context}', 'script_task::JSPageInfo',
'dom::bindings::proxyhandler', 'dom::bindings::proxyhandler',
'dom::bindings::proxyhandler::*', 'dom::bindings::proxyhandler::*',
'servo_util::str::DOMString', 'servo_util::str::DOMString',

View file

@ -35,8 +35,7 @@ use geom::size::Size2D;
use js::JSVAL_NULL; use js::JSVAL_NULL;
use js::global::DEBUG_FNS; use js::global::DEBUG_FNS;
use js::glue::RUST_JSVAL_TO_OBJECT; use js::glue::RUST_JSVAL_TO_OBJECT;
use js::jsapi::{JSContext, JSObject, JS_InhibitGC, JS_AllowGC}; use js::jsapi::{JSObject, JS_InhibitGC, JS_AllowGC, JS_CallFunctionValue};
use js::jsapi::{JS_CallFunctionValue, JS_GetContextPrivate};
use js::rust::{Compartment, Cx, CxUtils, RtUtils}; use js::rust::{Compartment, Cx, CxUtils, RtUtils};
use js; use js;
use servo_msg::compositor_msg::{FinishedLoading, Loading, PerformingLayout, ScriptListener}; use servo_msg::compositor_msg::{FinishedLoading, Loading, PerformingLayout, ScriptListener};
@ -420,15 +419,7 @@ impl Page {
Err(()) => fail!("Failed to create a compartment"), Err(()) => fail!("Failed to create a compartment"),
}; };
// Indirection for Rust Issue #6248, dynamic freeze scope artifically extended
let page_ptr = {
let borrowed_page = &*self;
borrowed_page as *Page
};
unsafe { unsafe {
js_context.borrow().set_cx_private(page_ptr as *());
JS_InhibitGC(js_context.borrow().ptr); JS_InhibitGC(js_context.borrow().ptr);
} }
@ -489,13 +480,6 @@ pub struct ScriptTask {
mouse_over_targets: RefCell<Option<~[JS<Node>]>> mouse_over_targets: RefCell<Option<~[JS<Node>]>>
} }
/// Returns the relevant page from the associated JS Context.
pub fn page_from_context(js_context: *JSContext) -> *Page {
unsafe {
JS_GetContextPrivate(js_context) as *Page
}
}
impl ScriptTask { impl ScriptTask {
/// Creates a new script task. /// Creates a new script task.
pub fn new(id: PipelineId, pub fn new(id: PipelineId,