Move WebIDL methods to traits implemented by JSRef types.

This commit is contained in:
Josh Matthews 2014-04-10 21:29:54 -04:00
parent dfdda0098a
commit 76783b029e
106 changed files with 3644 additions and 1912 deletions

View file

@ -30,12 +30,20 @@ impl ClientRectList {
reflect_dom_object(~ClientRectList::new_inherited(window.unrooted(), rects),
window, ClientRectListBinding::Wrap)
}
}
pub fn Length(&self) -> u32 {
pub trait ClientRectListMethods {
fn Length(&self) -> u32;
fn Item(&self, index: u32) -> Option<Unrooted<ClientRect>>;
fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<Unrooted<ClientRect>>;
}
impl<'a> ClientRectListMethods for JSRef<'a, ClientRectList> {
fn Length(&self) -> u32 {
self.rects.len() as u32
}
pub fn Item(&self, index: u32) -> Option<Unrooted<ClientRect>> {
fn Item(&self, index: u32) -> Option<Unrooted<ClientRect>> {
if index < self.rects.len() as u32 {
Some(Unrooted::new(self.rects.get(index as uint).clone()))
} else {
@ -43,7 +51,7 @@ impl ClientRectList {
}
}
pub fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<Unrooted<ClientRect>> {
fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<Unrooted<ClientRect>> {
*found = index < self.rects.len() as u32;
self.Item(index)
}