aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmltablecellelement.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/htmltablecellelement.rs')
-rw-r--r--components/script/dom/htmltablecellelement.rs37
1 files changed, 31 insertions, 6 deletions
diff --git a/components/script/dom/htmltablecellelement.rs b/components/script/dom/htmltablecellelement.rs
index cee07540301..9ca84b0e70f 100644
--- a/components/script/dom/htmltablecellelement.rs
+++ b/components/script/dom/htmltablecellelement.rs
@@ -2,8 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-use dom::attr::Attr;
-use dom::attr::AttrHelpers;
+use dom::attr::{Attr, AttrHelpers};
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLTableCellElementDerived};
use dom::bindings::js::JSRef;
use dom::bindings::utils::{Reflectable, Reflector};
@@ -15,13 +14,15 @@ use dom::htmlelement::HTMLElement;
use dom::node::ElementNodeTypeId;
use dom::virtualmethods::VirtualMethods;
-use servo_util::str::{AutoLpa, DOMString, LengthOrPercentageOrAuto};
-use servo_util::str;
+use cssparser::RGBA;
+use servo_util::str::{mod, AutoLpa, DOMString, LengthOrPercentageOrAuto};
use std::cell::Cell;
#[dom_struct]
pub struct HTMLTableCellElement {
htmlelement: HTMLElement,
+ background_color: Cell<Option<RGBA>>,
+ colspan: Cell<Option<u32>>,
width: Cell<LengthOrPercentageOrAuto>,
}
@@ -36,10 +37,16 @@ impl HTMLTableCellElementDerived for EventTarget {
}
impl HTMLTableCellElement {
- pub fn new_inherited(type_id: ElementTypeId, tag_name: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLTableCellElement {
+ pub fn new_inherited(type_id: ElementTypeId,
+ tag_name: DOMString,
+ prefix: Option<DOMString>,
+ document: JSRef<Document>)
+ -> HTMLTableCellElement {
HTMLTableCellElement {
htmlelement: HTMLElement::new_inherited(type_id, tag_name, prefix, document),
- width: Cell::new(AutoLpa)
+ background_color: Cell::new(None),
+ colspan: Cell::new(None),
+ width: Cell::new(AutoLpa),
}
}
@@ -50,10 +57,20 @@ impl HTMLTableCellElement {
}
pub trait HTMLTableCellElementHelpers {
+ fn get_background_color(&self) -> Option<RGBA>;
+ fn get_colspan(&self) -> Option<u32>;
fn get_width(&self) -> LengthOrPercentageOrAuto;
}
impl HTMLTableCellElementHelpers for HTMLTableCellElement {
+ fn get_background_color(&self) -> Option<RGBA> {
+ self.background_color.get()
+ }
+
+ fn get_colspan(&self) -> Option<u32> {
+ self.colspan.get()
+ }
+
fn get_width(&self) -> LengthOrPercentageOrAuto {
self.width.get()
}
@@ -72,6 +89,12 @@ 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!("colspan") => {
+ self.colspan.set(str::parse_unsigned_integer(attr.value().as_slice().chars()));
+ }
&atom!("width") => self.width.set(str::parse_length(attr.value().as_slice())),
_ => ()
}
@@ -84,6 +107,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTableCellElement> {
}
match attr.local_name() {
+ &atom!("bgcolor") => self.background_color.set(None),
+ &atom!("colspan") => self.colspan.set(None),
&atom!("width") => self.width.set(AutoLpa),
_ => ()
}