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

@ -2,14 +2,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::utils::{DOMString, ErrorResult, Reflectable};
use dom::bindings::utils::{DOMString, ErrorResult};
use dom::htmlcollection::HTMLCollection;
use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, ScriptView};
use dom::validitystate::ValidityState;
use js::jsapi::{JSContext, JSObject};
pub struct HTMLFieldSetElement {
htmlelement: HTMLElement
}
@ -39,16 +37,8 @@ impl HTMLFieldSetElement {
None
}
fn get_scope_and_cx(&self) -> (*JSObject, *JSContext) {
let doc = self.htmlelement.element.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)
}
pub fn Elements(&self) -> @mut HTMLCollection {
let (scope, cx) = self.get_scope_and_cx();
let (scope, cx) = self.htmlelement.element.node.get_scope_and_cx();
HTMLCollection::new(~[], cx, scope)
}