aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2014-12-17 16:44:37 -0800
committerPatrick Walton <pcwalton@mimiga.net>2015-03-12 12:00:40 -0700
commit586c12ccc4de666c0cfbef84689c2e8ed7d7719d (patch)
tree55413c66c201e37efbd2370736c7e91343297a24 /components/script
parente8f1a046c6c704915419cb75181f6e0bc402ef98 (diff)
downloadservo-586c12ccc4de666c0cfbef84689c2e8ed7d7719d.tar.gz
servo-586c12ccc4de666c0cfbef84689c2e8ed7d7719d.zip
layout: Implement `border-spacing` per CSS 2.1 § 17.6.1 and the legacy
`cellspacing` attribute per HTML5 § 14.3.9. Table layout code has been refactored to push the spacing down to rowgroups and rows; this will aid the implementation of `border-collapse` as well. This commit also fixes two nasty issues in table layout: * In fixed layout, extra space would not be divided among columns that had auto width but had nonzero minimum width. * In automatic layout, extra space would be distributed to constrained columns as well even if unconstrained columns with percentage equal to zero were present.
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/element.rs10
-rw-r--r--components/script/dom/htmltableelement.rs11
-rw-r--r--components/script/dom/webidls/CSSStyleDeclaration.webidl2
3 files changed, 23 insertions, 0 deletions
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index 4aad2fe59ff..3576f20f78c 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -317,6 +317,16 @@ impl RawLayoutElementHelpers for Element {
None
}
}
+ UnsignedIntegerAttribute::CellSpacing => {
+ if self.is_htmltableelement() {
+ let this: &HTMLTableElement = mem::transmute(self);
+ this.get_cellspacing()
+ } else {
+ // Don't panic since `display` can cause this to be called on arbitrary
+ // elements.
+ None
+ }
+ }
UnsignedIntegerAttribute::ColSpan => {
if self.is_htmltablecellelement() {
let this: &HTMLTableCellElement = mem::transmute(self);
diff --git a/components/script/dom/htmltableelement.rs b/components/script/dom/htmltableelement.rs
index e1494f67007..d7d85eb19bc 100644
--- a/components/script/dom/htmltableelement.rs
+++ b/components/script/dom/htmltableelement.rs
@@ -26,6 +26,7 @@ pub struct HTMLTableElement {
htmlelement: HTMLElement,
background_color: Cell<Option<RGBA>>,
border: Cell<Option<u32>>,
+ cellspacing: Cell<Option<u32>>,
width: Cell<LengthOrPercentageOrAuto>,
}
@@ -45,6 +46,7 @@ impl HTMLTableElement {
document),
background_color: Cell::new(None),
border: Cell::new(None),
+ cellspacing: Cell::new(None),
width: Cell::new(LengthOrPercentageOrAuto::Auto),
}
}
@@ -94,6 +96,7 @@ impl<'a> HTMLTableElementMethods for JSRef<'a, HTMLTableElement> {
pub trait HTMLTableElementHelpers {
fn get_background_color(&self) -> Option<RGBA>;
fn get_border(&self) -> Option<u32>;
+ fn get_cellspacing(&self) -> Option<u32>;
fn get_width(&self) -> LengthOrPercentageOrAuto;
}
@@ -106,6 +109,10 @@ impl HTMLTableElementHelpers for HTMLTableElement {
self.border.get()
}
+ fn get_cellspacing(&self) -> Option<u32> {
+ self.cellspacing.get()
+ }
+
fn get_width(&self) -> LengthOrPercentageOrAuto {
self.width.get()
}
@@ -132,6 +139,9 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTableElement> {
.as_slice()
.chars()).unwrap_or(1)))
}
+ &atom!("cellspacing") => {
+ self.cellspacing.set(str::parse_unsigned_integer(attr.value().as_slice().chars()))
+ }
&atom!("width") => self.width.set(str::parse_length(attr.value().as_slice())),
_ => ()
}
@@ -145,6 +155,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!("cellspacing") => self.cellspacing.set(None),
&atom!("width") => self.width.set(LengthOrPercentageOrAuto::Auto),
_ => ()
}
diff --git a/components/script/dom/webidls/CSSStyleDeclaration.webidl b/components/script/dom/webidls/CSSStyleDeclaration.webidl
index bde48aaaff3..be5afa7244d 100644
--- a/components/script/dom/webidls/CSSStyleDeclaration.webidl
+++ b/components/script/dom/webidls/CSSStyleDeclaration.webidl
@@ -41,8 +41,10 @@ partial interface CSSStyleDeclaration {
[TreatNullAs=EmptyString] attribute DOMString backgroundSize;
[TreatNullAs=EmptyString] attribute DOMString border;
+ [TreatNullAs=EmptyString] attribute DOMString borderCollapse;
[TreatNullAs=EmptyString] attribute DOMString borderColor;
[TreatNullAs=EmptyString] attribute DOMString borderRadius;
+ [TreatNullAs=EmptyString] attribute DOMString borderSpacing;
[TreatNullAs=EmptyString] attribute DOMString borderStyle;
[TreatNullAs=EmptyString] attribute DOMString borderWidth;
[TreatNullAs=EmptyString] attribute DOMString borderBottom;