implement NodeList and consolidate common scope and context retrieval

This commit is contained in:
Tim Taubert 2013-10-05 19:17:52 -07:00
parent bc3eeb6f1c
commit 9fe9145be4
13 changed files with 180 additions and 72 deletions

View file

@ -192,14 +192,6 @@ impl<'self> Element {
}
}
}
fn get_scope_and_cx(&self) -> (*JSObject, *JSContext) {
let doc = self.node.owner_doc;
let win = doc.with_base(|doc| doc.window.unwrap());
let cx = win.page.js_info.get_ref().js_compartment.cx.ptr;
let scope = win.reflector().get_jsobject();
(scope, cx)
}
}
impl Element {
@ -251,17 +243,17 @@ impl Element {
}
pub fn GetElementsByTagName(&self, _localname: &DOMString) -> @mut HTMLCollection {
let (scope, cx) = self.get_scope_and_cx();
let (scope, cx) = self.node.get_scope_and_cx();
HTMLCollection::new(~[], cx, scope)
}
pub fn GetElementsByTagNameNS(&self, _namespace: &DOMString, _localname: &DOMString) -> Fallible<@mut HTMLCollection> {
let (scope, cx) = self.get_scope_and_cx();
let (scope, cx) = self.node.get_scope_and_cx();
Ok(HTMLCollection::new(~[], cx, scope))
}
pub fn GetElementsByClassName(&self, _names: &DOMString) -> @mut HTMLCollection {
let (scope, cx) = self.get_scope_and_cx();
let (scope, cx) = self.node.get_scope_and_cx();
HTMLCollection::new(~[], cx, scope)
}