diff options
author | Patrick Walton <pcwalton@mimiga.net> | 2014-12-07 23:01:35 -0800 |
---|---|---|
committer | Patrick Walton <pcwalton@mimiga.net> | 2014-12-15 17:41:51 -0800 |
commit | 56b78de5bce995198fbeb41adc58d7625ec93372 (patch) | |
tree | 3267aae2b7b71c577accf5307eb2a1fa707dbd05 /components/script | |
parent | 14bafb11bec973cd1362ff38a8e4aa2385c6ff37 (diff) | |
download | servo-56b78de5bce995198fbeb41adc58d7625ec93372.tar.gz servo-56b78de5bce995198fbeb41adc58d7625ec93372.zip |
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.
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/element.rs | 13 | ||||
-rw-r--r-- | components/script/dom/htmltablecellelement.rs | 11 | ||||
-rw-r--r-- | components/script/dom/htmltableelement.rs | 3 |
3 files changed, 25 insertions, 2 deletions
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 0cdf78b697d..6795511a3d0 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -44,8 +44,9 @@ use dom::node::{window_from_node}; use dom::nodelist::NodeList; use dom::virtualmethods::{VirtualMethods, vtable_for}; use devtools_traits::AttrInfo; -use style::{mod, BgColorSimpleColorAttribute, BorderUnsignedIntegerAttribute, IntegerAttribute}; -use style::{LengthAttribute, SimpleColorAttribute, SizeIntegerAttribute, UnsignedIntegerAttribute}; +use style::{mod, BgColorSimpleColorAttribute, BorderUnsignedIntegerAttribute}; +use style::{ColSpanUnsignedIntegerAttribute, IntegerAttribute, LengthAttribute}; +use style::{SimpleColorAttribute, SizeIntegerAttribute, UnsignedIntegerAttribute}; use style::{WidthLengthAttribute, matches, parse_selector_list_from_str}; use servo_util::namespace; use servo_util::str::{DOMString, LengthOrPercentageOrAuto, SimpleColor}; @@ -349,6 +350,14 @@ impl RawLayoutElementHelpers for Element { None } } + ColSpanUnsignedIntegerAttribute => { + if self.is_htmltablecellelement() { + let this: &HTMLTableCellElement = mem::transmute(self); + this.get_colspan() + } else { + panic!("I'm not a table cell!") + } + } } } diff --git a/components/script/dom/htmltablecellelement.rs b/components/script/dom/htmltablecellelement.rs index 25a5e9e78b0..81a6ba3f9f0 100644 --- a/components/script/dom/htmltablecellelement.rs +++ b/components/script/dom/htmltablecellelement.rs @@ -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), _ => () } diff --git a/components/script/dom/htmltableelement.rs b/components/script/dom/htmltableelement.rs index 4ece4c8b9f9..d88017fe151 100644 --- a/components/script/dom/htmltableelement.rs +++ b/components/script/dom/htmltableelement.rs @@ -108,6 +108,7 @@ impl HTMLTableElementHelpers for HTMLTableElement { fn get_border(&self) -> Option<u32> { self.border.get() } + fn get_width(&self) -> LengthOrPercentageOrAuto { self.width.get() } @@ -135,6 +136,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTableElement> { .as_slice() .chars()).unwrap_or(1))) } + &atom!("width") => self.width.set(str::parse_length(attr.value().as_slice())), _ => () } } @@ -148,6 +150,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTableElement> { match attr.local_name() { &atom!("bgcolor") => self.background_color.set(None), &atom!("border") => self.border.set(None), + &atom!("width") => self.width.set(AutoLpa), _ => () } } |