aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/flow.rs
diff options
context:
space:
mode:
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
}
})
})