mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
style: Parse the legacy bgcolor
attribute per the HTML5 specification.
Additionally, this patch cleans up some miscellaneous formatting issues.
This commit is contained in:
parent
10f1ed5e31
commit
14bafb11be
19 changed files with 370 additions and 36 deletions
|
@ -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),
|
||||
_ => ()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue