mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Move WebIDL methods to traits implemented by JSRef types.
This commit is contained in:
parent
dfdda0098a
commit
76783b029e
106 changed files with 3644 additions and 1912 deletions
|
@ -29,18 +29,26 @@ impl AttrList {
|
|||
reflect_dom_object(~AttrList::new_inherited(window.unrooted(), elem.unrooted()),
|
||||
window, AttrListBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn Length(&self) -> u32 {
|
||||
pub trait AttrListMethods {
|
||||
fn Length(&self) -> u32;
|
||||
fn Item(&self, index: u32) -> Option<Unrooted<Attr>>;
|
||||
fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<Unrooted<Attr>>;
|
||||
}
|
||||
|
||||
impl<'a> AttrListMethods for JSRef<'a, AttrList> {
|
||||
fn Length(&self) -> u32 {
|
||||
let roots = RootCollection::new();
|
||||
self.owner.root(&roots).attrs.len() as u32
|
||||
}
|
||||
|
||||
pub fn Item(&self, index: u32) -> Option<Unrooted<Attr>> {
|
||||
fn Item(&self, index: u32) -> Option<Unrooted<Attr>> {
|
||||
let roots = RootCollection::new();
|
||||
self.owner.root(&roots).attrs.as_slice().get(index as uint).map(|x| Unrooted::new(x.clone()))
|
||||
}
|
||||
|
||||
pub fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<Unrooted<Attr>> {
|
||||
fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<Unrooted<Attr>> {
|
||||
let item = self.Item(index);
|
||||
*found = item.is_some();
|
||||
item
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue