aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/main/layout/flow.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/main/layout/flow.rs')
-rw-r--r--src/components/main/layout/flow.rs191
1 files changed, 185 insertions, 6 deletions
diff --git a/src/components/main/layout/flow.rs b/src/components/main/layout/flow.rs
index 890d2fecd68..cc4db0cb350 100644
--- a/src/components/main/layout/flow.rs
+++ b/src/components/main/layout/flow.rs
@@ -36,6 +36,13 @@ use layout::incremental::RestyleDamage;
use layout::inline::InlineFlow;
use layout::parallel::FlowParallelInfo;
use layout::parallel;
+use layout::table_wrapper::TableWrapperFlow;
+use layout::table::TableFlow;
+use layout::table_colgroup::TableColGroupFlow;
+use layout::table_rowgroup::TableRowGroupFlow;
+use layout::table_row::TableRowFlow;
+use layout::table_caption::TableCaptionFlow;
+use layout::table_cell::TableCellFlow;
use layout::wrapper::ThreadSafeLayoutNode;
use layout::flow_list::{FlowList, Link, Rawlink, FlowListIterator, MutFlowListIterator};
@@ -84,6 +91,41 @@ pub trait Flow {
fail!("called as_inline() on a non-inline flow")
}
+ /// If this is a table wrapper flow, returns the underlying object. Fails otherwise.
+ fn as_table_wrapper<'a>(&'a mut self) -> &'a mut TableWrapperFlow {
+ fail!("called as_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 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")
+ }
+
+ /// If this is a table rowgroup flow, returns the underlying object. Fails otherwise.
+ fn as_table_rowgroup<'a>(&'a mut self) -> &'a mut 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 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")
+ }
+
+ /// If this is a table cell flow, returns the underlying object. Fails otherwise.
+ fn as_table_cell<'a>(&'a mut self) -> &'a mut TableCellFlow {
+ fail!("called as_table_cell() on a non-tablecell flow")
+ }
+
// Main methods
/// Pass 1 of reflow: computes minimum and preferred widths.
@@ -222,6 +264,30 @@ pub trait ImmutableFlowUtils {
/// Returns true if this flow is a block or a float flow.
fn is_block_like(self) -> bool;
+ /// Returns true if this flow is a table flow.
+ fn is_table(self) -> bool;
+
+ /// Returns true if this flow is a table caption flow.
+ fn is_table_caption(self) -> bool;
+
+ /// Returns true if this flow is a proper table child.
+ fn is_proper_table_child(self) -> bool;
+
+ /// Returns true if this flow is a table row flow.
+ fn is_table_row(self) -> bool;
+
+ /// Returns true if this flow is a table cell flow.
+ fn is_table_cell(self) -> bool;
+
+ /// Returns true if this flow is a table colgroup flow.
+ fn is_table_colgroup(self) -> bool;
+
+ /// Returns true if this flow is a table rowgroup flow.
+ fn is_table_rowgroup(self) -> bool;
+
+ /// Returns true if this flow is one of table-related flows.
+ fn is_table_kind(self) -> bool;
+
/// Returns true if this flow has no children.
fn is_leaf(self) -> bool;
@@ -309,6 +375,13 @@ pub trait MutableOwnedFlowUtils {
pub enum FlowClass {
BlockFlowClass,
InlineFlowClass,
+ TableWrapperFlowClass,
+ TableFlowClass,
+ TableColGroupFlowClass,
+ TableRowGroupFlowClass,
+ TableRowFlowClass,
+ TableCaptionFlowClass,
+ TableCellFlowClass,
}
/// A top-down traversal.
@@ -753,7 +826,76 @@ impl<'a> ImmutableFlowUtils for &'a Flow {
fn is_block_like(self) -> bool {
match self.class() {
BlockFlowClass => true,
- InlineFlowClass => false,
+ _ => false,
+ }
+ }
+
+ /// Returns true if this flow is a proper table child.
+ /// 'Proper table child' is defined as table-row flow, table-rowgroup flow,
+ /// table-column-group flow, or table-caption flow.
+ fn is_proper_table_child(self) -> bool {
+ match self.class() {
+ TableRowFlowClass | TableRowGroupFlowClass |
+ TableColGroupFlowClass | TableCaptionFlowClass => true,
+ _ => false,
+ }
+ }
+
+ /// Returns true if this flow is a table row flow.
+ fn is_table_row(self) -> bool {
+ match self.class() {
+ TableRowFlowClass => true,
+ _ => false,
+ }
+ }
+
+ /// Returns true if this flow is a table cell flow.
+ fn is_table_cell(self) -> bool {
+ match self.class() {
+ TableCellFlowClass => true,
+ _ => false,
+ }
+ }
+
+ /// Returns true if this flow is a table colgroup flow.
+ fn is_table_colgroup(self) -> bool {
+ match self.class() {
+ TableColGroupFlowClass => true,
+ _ => false,
+ }
+ }
+
+ /// Returns true if this flow is a table flow.
+ fn is_table(self) -> bool {
+ match self.class() {
+ TableFlowClass => true,
+ _ => false,
+ }
+ }
+
+ /// Returns true if this flow is a table caption flow.
+ fn is_table_caption(self) -> bool {
+ match self.class() {
+ TableCaptionFlowClass => true,
+ _ => false,
+ }
+ }
+
+ /// Returns true if this flow is a table rowgroup flow.
+ fn is_table_rowgroup(self) -> bool {
+ match self.class() {
+ TableRowGroupFlowClass => true,
+ _ => false,
+ }
+ }
+
+ /// Returns true if this flow is one of table-related flows.
+ fn is_table_kind(self) -> bool {
+ match self.class() {
+ TableWrapperFlowClass | TableFlowClass |
+ TableColGroupFlowClass | TableRowGroupFlowClass |
+ TableRowFlowClass | TableCaptionFlowClass | TableCellFlowClass => true,
+ _ => false,
}
}
@@ -776,11 +918,11 @@ impl<'a> ImmutableFlowUtils for &'a Flow {
fn is_block_container(self) -> bool {
match self.class() {
// TODO: Change this when inline-blocks are supported.
- InlineFlowClass => false,
- BlockFlowClass => {
+ BlockFlowClass | TableCaptionFlowClass | TableCellFlowClass => {
// FIXME: Actually check the type of the node
self.child_count() != 0
}
+ _ => false,
}
}
@@ -788,7 +930,7 @@ impl<'a> ImmutableFlowUtils for &'a Flow {
fn is_block_flow(self) -> bool {
match self.class() {
BlockFlowClass => true,
- InlineFlowClass => false,
+ _ => false,
}
}
@@ -796,7 +938,7 @@ impl<'a> ImmutableFlowUtils for &'a Flow {
fn is_inline_flow(self) -> bool {
match self.class() {
InlineFlowClass => true,
- BlockFlowClass => false,
+ _ => false,
}
}
@@ -948,13 +1090,50 @@ impl<'a> MutableFlowUtils for &'a mut Flow {
index,
lists),
InlineFlowClass => self.as_inline().build_display_list_inline(builder, container_block_size, dirty, index, lists),
+ TableWrapperFlowClass => self.as_table_wrapper().build_display_list_table_wrapper(builder,
+ container_block_size,
+ absolute_cb_abs_position,
+ dirty,
+ index,
+ lists),
+ TableFlowClass => self.as_table().build_display_list_table(builder,
+ container_block_size,
+ absolute_cb_abs_position,
+ dirty,
+ index,
+ lists),
+ TableRowGroupFlowClass => self.as_table_rowgroup().build_display_list_table_rowgroup(builder,
+ container_block_size,
+ absolute_cb_abs_position,
+ dirty,
+ index,
+ lists),
+ TableRowFlowClass => self.as_table_row().build_display_list_table_row(builder,
+ container_block_size,
+ absolute_cb_abs_position,
+ dirty,
+ index,
+ lists),
+ TableCaptionFlowClass => self.as_table_caption().build_display_list_table_caption(builder,
+ container_block_size,
+ absolute_cb_abs_position,
+ dirty,
+ index,
+ lists),
+ TableCellFlowClass => self.as_table_cell().build_display_list_table_cell(builder,
+ container_block_size,
+ absolute_cb_abs_position,
+ dirty,
+ index,
+ lists),
+ TableColGroupFlowClass => index,
};
if lists.with_mut(|lists| lists.lists[index].list.len() == 0) {
return true;
}
- if self.is_block_container() {
+ if self.is_block_container() || self.is_table_kind() {
let block = self.as_block();
let mut child_lists = DisplayListCollection::new();
child_lists.add_list(DisplayList::new());