aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/flow.rs
diff options
context:
space:
mode:
authorGlenn Watson <gw@intuitionlibrary.com>2014-09-19 14:41:15 +1000
committerGlenn Watson <gw@intuitionlibrary.com>2014-09-19 14:48:53 +1000
commit0d0d2365aab705e3e180c55c83d548427d37b4d4 (patch)
treebbadc837f88cc564e015beab16c99f0997f16c29 /components/layout/flow.rs
parentb11a110e85ca5670a1d492b6deb616fe8a90cf5b (diff)
downloadservo-0d0d2365aab705e3e180c55c83d548427d37b4d4.tar.gz
servo-0d0d2365aab705e3e180c55c83d548427d37b4d4.zip
Adds support for table layout trace and updates viewer for tables.
Diffstat (limited to 'components/layout/flow.rs')
-rw-r--r--components/layout/flow.rs36
1 files changed, 35 insertions, 1 deletions
diff --git a/components/layout/flow.rs b/components/layout/flow.rs
index 7a4c98a8361..192550149c7 100644
--- a/components/layout/flow.rs
+++ b/components/layout/flow.rs
@@ -103,11 +103,22 @@ pub trait Flow: fmt::Show + ToString + Share {
fail!("called as_table_wrapper() on a non-tablewrapper flow")
}
+ /// If this is a table wrapper flow, returns the underlying object, borrowed immutably. Fails
+ /// otherwise.
+ fn as_immutable_table_wrapper<'a>(&'a self) -> &'a TableWrapperFlow {
+ fail!("called as_immutable_table_wrapper() on a non-tablewrapper flow")
+ }
+
/// If this is a table flow, returns the underlying object. Fails otherwise.
fn as_table<'a>(&'a mut self) -> &'a mut TableFlow {
fail!("called as_table() on a non-table flow")
}
+ /// If this is a table flow, returns the underlying object, borrowed immutably. Fails otherwise.
+ fn as_immutable_table<'a>(&'a self) -> &'a TableFlow {
+ fail!("called as_table() on a non-table flow")
+ }
+
/// If this is a table colgroup flow, returns the underlying object. Fails otherwise.
fn as_table_colgroup<'a>(&'a mut self) -> &'a mut TableColGroupFlow {
fail!("called as_table_colgroup() on a non-tablecolgroup flow")
@@ -118,11 +129,23 @@ pub trait Flow: fmt::Show + ToString + Share {
fail!("called as_table_rowgroup() on a non-tablerowgroup flow")
}
+ /// If this is a table rowgroup flow, returns the underlying object, borrowed immutably. Fails
+ /// otherwise.
+ fn as_immutable_table_rowgroup<'a>(&'a self) -> &'a TableRowGroupFlow {
+ fail!("called as_table_rowgroup() on a non-tablerowgroup flow")
+ }
+
/// If this is a table row flow, returns the underlying object. Fails otherwise.
fn as_table_row<'a>(&'a mut self) -> &'a mut TableRowFlow {
fail!("called as_table_row() on a non-tablerow flow")
}
+ /// If this is a table row flow, returns the underlying object, borrowed immutably. Fails
+ /// otherwise.
+ fn as_immutable_table_row<'a>(&'a self) -> &'a TableRowFlow {
+ fail!("called as_table_row() on a non-tablerow flow")
+ }
+
/// If this is a table cell flow, returns the underlying object. Fails otherwise.
fn as_table_caption<'a>(&'a mut self) -> &'a mut TableCaptionFlow {
fail!("called as_table_caption() on a non-tablecaption flow")
@@ -133,6 +156,12 @@ pub trait Flow: fmt::Show + ToString + Share {
fail!("called as_table_cell() on a non-tablecell flow")
}
+ /// If this is a table cell flow, returns the underlying object, borrowed immutably. Fails
+ /// otherwise.
+ fn as_immutable_table_cell<'a>(&'a self) -> &'a TableCellFlow {
+ fail!("called as_table_cell() on a non-tablecell flow")
+ }
+
/// If this is a table row or table rowgroup or table flow, returns column inline-sizes.
/// Fails otherwise.
fn col_inline_sizes<'a>(&'a mut self) -> &'a mut Vec<Au> {
@@ -289,7 +318,12 @@ impl<'a, E, S: Encoder<E>> Encodable<S, E> for &'a Flow {
match self.class() {
BlockFlowClass => self.as_immutable_block().encode(e),
InlineFlowClass => self.as_immutable_inline().encode(e),
- _ => { Ok(()) } // TODO: Support tables
+ TableFlowClass => self.as_immutable_table().encode(e),
+ TableWrapperFlowClass => self.as_immutable_table_wrapper().encode(e),
+ TableRowGroupFlowClass => self.as_immutable_table_rowgroup().encode(e),
+ TableRowFlowClass => self.as_immutable_table_row().encode(e),
+ TableCellFlowClass => self.as_immutable_table_cell().encode(e),
+ _ => { Ok(()) } // TODO: Support captions
}
})
})