diff options
author | Manish Goregaokar <manishsmail@gmail.com> | 2014-12-10 11:56:20 +0530 |
---|---|---|
committer | Manish Goregaokar <manishsmail@gmail.com> | 2014-12-27 02:53:36 +0530 |
commit | 21a888341d3e184b0835c4de73959b851d275571 (patch) | |
tree | e019676e6d0cc048d26ce610f9725628eac5efca /components/script/dom/htmltablesectionelement.rs | |
parent | d761877ef692f46970315ee0008fe0f3254323eb (diff) | |
download | servo-21a888341d3e184b0835c4de73959b851d275571.tar.gz servo-21a888341d3e184b0835c4de73959b851d275571.zip |
Ensure that Reflectors are the first field
Diffstat (limited to 'components/script/dom/htmltablesectionelement.rs')
-rw-r--r-- | components/script/dom/htmltablesectionelement.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/components/script/dom/htmltablesectionelement.rs b/components/script/dom/htmltablesectionelement.rs index 40e7f91ac0a..5894d20bab5 100644 --- a/components/script/dom/htmltablesectionelement.rs +++ b/components/script/dom/htmltablesectionelement.rs @@ -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), + _ => {} + } + } +} |