From 7dbffeed203a3d2c6d9f35ed39e915b7ada6a831 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Fri, 31 Jul 2015 16:40:06 +1000 Subject: [PATCH] Fix panic when html element has display: table. --- components/layout/flow.rs | 5 ++++- components/layout/list_item.rs | 4 ++++ components/layout/multicol.rs | 4 ++++ components/layout/table.rs | 4 ++++ components/layout/table_wrapper.rs | 8 ++++++++ 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/components/layout/flow.rs b/components/layout/flow.rs index 90835cfac31..64ee4d2e0d2 100644 --- a/components/layout/flow.rs +++ b/components/layout/flow.rs @@ -295,7 +295,10 @@ pub trait Flow: fmt::Debug + Sync { } /// Marks this flow as the root flow. The default implementation is a no-op. - fn mark_as_root(&mut self) {} + fn mark_as_root(&mut self) { + debug!("called mark_as_root() on a flow of type {:?}", self.class()); + panic!("called mark_as_root() on an unhandled flow"); + } // Note that the following functions are mostly called using static method // dispatch, so it's ok to have them in this trait. Plus, they have diff --git a/components/layout/list_item.rs b/components/layout/list_item.rs index 86775638c27..a1a108848ac 100644 --- a/components/layout/list_item.rs +++ b/components/layout/list_item.rs @@ -74,6 +74,10 @@ impl Flow for ListItemFlow { &mut self.block_flow } + fn as_immutable_block<'a>(&'a self) -> &'a BlockFlow { + &self.block_flow + } + fn bubble_inline_sizes(&mut self) { // The marker contributes no intrinsic inline-size, so… self.block_flow.bubble_inline_sizes() diff --git a/components/layout/multicol.rs b/components/layout/multicol.rs index bf4e4e11ea8..20cc7d5c1c5 100644 --- a/components/layout/multicol.rs +++ b/components/layout/multicol.rs @@ -48,6 +48,10 @@ impl Flow for MulticolFlow { &mut self.block_flow } + fn as_immutable_block<'a>(&'a self) -> &'a BlockFlow { + &self.block_flow + } + fn bubble_inline_sizes(&mut self) { // FIXME(SimonSapin) http://dev.w3.org/csswg/css-sizing/#multicol-intrinsic self.block_flow.bubble_inline_sizes(); diff --git a/components/layout/table.rs b/components/layout/table.rs index 8de0878203d..633454097e2 100644 --- a/components/layout/table.rs +++ b/components/layout/table.rs @@ -210,6 +210,10 @@ impl Flow for TableFlow { &self.block_flow } + fn mark_as_root(&mut self) { + self.block_flow.mark_as_root(); + } + fn column_intrinsic_inline_sizes<'a>(&'a mut self) -> &'a mut Vec { &mut self.column_intrinsic_inline_sizes } diff --git a/components/layout/table_wrapper.rs b/components/layout/table_wrapper.rs index 80a3bc71ae9..56934ea875a 100644 --- a/components/layout/table_wrapper.rs +++ b/components/layout/table_wrapper.rs @@ -273,6 +273,14 @@ impl Flow for TableWrapperFlow { &mut self.block_flow } + fn as_immutable_block<'a>(&'a self) -> &'a BlockFlow { + &self.block_flow + } + + fn mark_as_root(&mut self) { + self.block_flow.mark_as_root(); + } + fn bubble_inline_sizes(&mut self) { // Get the intrinsic column inline-sizes info from the table flow. for kid in self.block_flow.base.child_iter() {