style: Implement basic column spans.

This patch provides some of the groundwork for column spans greater than
1. It implements the column-span CSS property (prefixed so as not to be
exposed to content) as well as the corresponding colspan attribute;
although the former is not well-specified outside of CSS multi-column
layout, INTRINSIC refers to it. Although width is distributed to
spanning columns, they do not yet contribute minimum and preferred
widths; this will be implemented in a follow-up.

Additionally, this patch cleans up some miscellaneous formatting issues
and improves the handling of table rowgroups.
This commit is contained in:
Patrick Walton 2014-12-07 23:01:35 -08:00
parent 14bafb11be
commit 56b78de5bc
13 changed files with 269 additions and 129 deletions

View file

@ -22,6 +22,7 @@ pub struct HTMLTableCellElement {
htmlelement: HTMLElement,
background_color: Cell<Option<SimpleColor>>,
border: Cell<Option<u32>>,
colspan: Cell<Option<u32>>,
width: Cell<LengthOrPercentageOrAuto>,
}
@ -45,6 +46,7 @@ impl HTMLTableCellElement {
htmlelement: HTMLElement::new_inherited(type_id, tag_name, prefix, document),
background_color: Cell::new(None),
border: Cell::new(None),
colspan: Cell::new(None),
width: Cell::new(AutoLpa),
}
}
@ -58,6 +60,7 @@ impl HTMLTableCellElement {
pub trait HTMLTableCellElementHelpers {
fn get_background_color(&self) -> Option<SimpleColor>;
fn get_border(&self) -> Option<u32>;
fn get_colspan(&self) -> Option<u32>;
fn get_width(&self) -> LengthOrPercentageOrAuto;
}
@ -70,6 +73,10 @@ impl HTMLTableCellElementHelpers for HTMLTableCellElement {
self.border.get()
}
fn get_colspan(&self) -> Option<u32> {
self.colspan.get()
}
fn get_width(&self) -> LengthOrPercentageOrAuto {
self.width.get()
}
@ -97,6 +104,9 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTableCellElement> {
.as_slice()
.chars()).unwrap_or(1)))
}
&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())),
_ => ()
}
@ -111,6 +121,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!("colspan") => self.colspan.set(None),
&atom!("width") => self.width.set(AutoLpa),
_ => ()
}