servo: Merge #1829 - Remove page_from_context (from Ms2ger:page_from_context); r=jdm

Source-Repo: https://github.com/servo/servo
Source-Revision: b9b4eebab5664d026435d70bf3f2ac40c5b56826
This commit is contained in:
Ms2ger 2014-03-05 15:13:29 -05:00
Родитель e17dd84789
Коммит 8a6b3d8aae
2 изменённых файлов: 3 добавлений и 51 удалений

Просмотреть файл

@ -2675,38 +2675,6 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
# if we don't need to create anything, why are we generating this?
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 = []
for var in self.properties.arrayNames():
props = getattr(self.properties, var)
@ -2773,7 +2741,7 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
chrome = None
functionBody = CGList(
[CGGeneric(getParentProto), initIds, prefCache, chrome,
[CGGeneric(getParentProto), prefCache, chrome,
CGGeneric(call % self.properties.variableNames(False))],
"\n\n")
#return CGIndenter(CGWrapper(functionBody, pre="/*", post="*/return ptr::null()")).define()
@ -5294,7 +5262,7 @@ class CGBindingRoot(CGThing):
'dom::bindings::codegen::*', #XXXjdm
'dom::bindings::codegen::UnionTypes::*', #XXXjdm
'dom::bindings::codegen::UnionConversions::*', #XXXjdm
'script_task::{JSPageInfo, page_from_context}',
'script_task::JSPageInfo',
'dom::bindings::proxyhandler',
'dom::bindings::proxyhandler::*',
'servo_util::str::DOMString',

Просмотреть файл

@ -35,8 +35,7 @@ use geom::size::Size2D;
use js::JSVAL_NULL;
use js::global::DEBUG_FNS;
use js::glue::RUST_JSVAL_TO_OBJECT;
use js::jsapi::{JSContext, JSObject, JS_InhibitGC, JS_AllowGC};
use js::jsapi::{JS_CallFunctionValue, JS_GetContextPrivate};
use js::jsapi::{JSObject, JS_InhibitGC, JS_AllowGC, JS_CallFunctionValue};
use js::rust::{Compartment, Cx, CxUtils, RtUtils};
use js;
use servo_msg::compositor_msg::{FinishedLoading, Loading, PerformingLayout, ScriptListener};
@ -420,15 +419,7 @@ impl Page {
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 {
js_context.borrow().set_cx_private(page_ptr as *());
JS_InhibitGC(js_context.borrow().ptr);
}
@ -489,13 +480,6 @@ pub struct ScriptTask {
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 {
/// Creates a new script task.
pub fn new(id: PipelineId,