diff options
Diffstat (limited to 'components/script/dom/htmltablecellelement.rs')
-rw-r--r-- | components/script/dom/htmltablecellelement.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/components/script/dom/htmltablecellelement.rs b/components/script/dom/htmltablecellelement.rs index 622389397e9..25a5e9e78b0 100644 --- a/components/script/dom/htmltablecellelement.rs +++ b/components/script/dom/htmltablecellelement.rs @@ -14,13 +14,13 @@ use dom::htmlelement::HTMLElement; use dom::node::ElementNodeTypeId; use dom::virtualmethods::VirtualMethods; -use servo_util::str::{AutoLpa, DOMString, LengthOrPercentageOrAuto}; -use servo_util::str; +use servo_util::str::{mod, AutoLpa, DOMString, LengthOrPercentageOrAuto, SimpleColor}; use std::cell::Cell; #[dom_struct] pub struct HTMLTableCellElement { htmlelement: HTMLElement, + background_color: Cell<Option<SimpleColor>>, border: Cell<Option<u32>>, width: Cell<LengthOrPercentageOrAuto>, } @@ -43,6 +43,7 @@ impl HTMLTableCellElement { -> HTMLTableCellElement { HTMLTableCellElement { htmlelement: HTMLElement::new_inherited(type_id, tag_name, prefix, document), + background_color: Cell::new(None), border: Cell::new(None), width: Cell::new(AutoLpa), } @@ -55,11 +56,16 @@ impl HTMLTableCellElement { } pub trait HTMLTableCellElementHelpers { + fn get_background_color(&self) -> Option<SimpleColor>; fn get_border(&self) -> Option<u32>; fn get_width(&self) -> LengthOrPercentageOrAuto; } impl HTMLTableCellElementHelpers for HTMLTableCellElement { + fn get_background_color(&self) -> Option<SimpleColor> { + self.background_color.get() + } + fn get_border(&self) -> Option<u32> { self.border.get() } @@ -82,6 +88,9 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTableCellElement> { } match attr.local_name() { + &atom!("bgcolor") => { + self.background_color.set(str::parse_legacy_color(attr.value().as_slice()).ok()) + } &atom!("border") => { // According to HTML5 § 14.3.9, invalid values map to 1px. self.border.set(Some(str::parse_unsigned_integer(attr.value() @@ -100,6 +109,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTableCellElement> { } match attr.local_name() { + &atom!("bgcolor") => self.background_color.set(None), &atom!("border") => self.border.set(None), &atom!("width") => self.width.set(AutoLpa), _ => () |