mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
implement NodeList and consolidate common scope and context retrieval
This commit is contained in:
parent
bc3eeb6f1c
commit
9fe9145be4
13 changed files with 180 additions and 72 deletions
|
@ -2,10 +2,9 @@
|
|||
* 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 js::jsapi::{JSObject, JSContext};
|
||||
|
||||
pub struct HTMLMapElement {
|
||||
htmlelement: HTMLElement
|
||||
|
@ -20,16 +19,8 @@ impl HTMLMapElement {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
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 Areas(&self) -> @mut HTMLCollection {
|
||||
let (scope, cx) = self.get_scope_and_cx();
|
||||
HTMLCollection::new(~[], cx, scope)
|
||||
let (scope, cx) = self.htmlelement.element.node.get_scope_and_cx();
|
||||
HTMLCollection::new(~[], cx, scope)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue