aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmltablecellelement.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2014-12-07 22:59:38 -0800
committerPatrick Walton <pcwalton@mimiga.net>2014-12-15 17:41:44 -0800
commit14bafb11bec973cd1362ff38a8e4aa2385c6ff37 (patch)
treee1dd41c6f1a2829e2be800cb27e7bdd4ee5f0a4f /components/script/dom/htmltablecellelement.rs
parent10f1ed5e311e7092d3e24b58c4960f5e8a511ac0 (diff)
downloadservo-14bafb11bec973cd1362ff38a8e4aa2385c6ff37.tar.gz
servo-14bafb11bec973cd1362ff38a8e4aa2385c6ff37.zip
style: Parse the legacy `bgcolor` attribute per the HTML5 specification.
Additionally, this patch cleans up some miscellaneous formatting issues.
Diffstat (limited to 'components/script/dom/htmltablecellelement.rs')
-rw-r--r--components/script/dom/htmltablecellelement.rs14
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),
_ => ()