Ensure that Reflectors are the first field

This commit is contained in:
Manish Goregaokar 2014-12-10 11:56:20 +05:30
parent d761877ef6
commit 21a888341d
14 changed files with 146 additions and 21 deletions

View file

@ -49,3 +49,45 @@ impl HTMLTableSectionElement {
}
}
pub trait HTMLTableSectionElementHelpers {
fn get_background_color(&self) -> Option<RGBA>;
}
impl HTMLTableSectionElementHelpers for HTMLTableSectionElement {
fn get_background_color(&self) -> Option<RGBA> {
self.background_color.get()
}
}
impl<'a> VirtualMethods for JSRef<'a, HTMLTableSectionElement> {
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> {
let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self);
Some(htmlelement as &VirtualMethods)
}
fn after_set_attr(&self, attr: JSRef<Attr>) {
match self.super_type() {
Some(ref s) => s.after_set_attr(attr),
_ => ()
}
match attr.local_name() {
&atom!("bgcolor") => {
self.background_color.set(str::parse_legacy_color(attr.value().as_slice()).ok())
}
_ => {}
}
}
fn before_remove_attr(&self, attr: JSRef<Attr>) {
match self.super_type() {
Some(ref s) => s.before_remove_attr(attr),
_ => ()
}
match attr.local_name() {
&atom!("bgcolor") => self.background_color.set(None),
_ => {}
}
}
}