From e5615705abf4e4945da94ead0e8f589b6e812148 Mon Sep 17 00:00:00 2001 From: Ilyong Cho Date: Wed, 11 Sep 2013 13:46:48 +0900 Subject: [PATCH] More accurate margin collapsing --- src/components/main/layout/block.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/main/layout/block.rs b/src/components/main/layout/block.rs index 212441c87980..00103010bece 100644 --- a/src/components/main/layout/block.rs +++ b/src/components/main/layout/block.rs @@ -7,7 +7,7 @@ use layout::box::{RenderBox}; use layout::context::LayoutContext; use layout::display_list_builder::{DisplayListBuilder, ExtraDisplayListData}; -use layout::flow::{BlockFlow, FlowContext, FlowData, InlineBlockFlow, FloatFlow}; +use layout::flow::{BlockFlow, FlowContext, FlowData, InlineBlockFlow, FloatFlow, InlineFlow}; use layout::inline::InlineLayout; use layout::model::{MaybeAuto, Specified, Auto}; use layout::float_context::{FloatContext, Invalid}; @@ -333,6 +333,7 @@ impl BlockFlowData { margin_bottom = model.margin.bottom; } } + for kid in self.common.child_iter() { match *kid { BlockFlow(ref info) => { @@ -359,10 +360,18 @@ impl BlockFlowData { } first_inflow = false; } + InlineFlow(ref info) => { + collapsing = Au(0); + // Non-empty inline flows prevent collapsing between the previous margion and the next. + if info.common.position.size.height > Au(0) { + collapsible = Au(0); + } + } // Margins between a floated box and any other box do not collapse. _ => { collapsing = Au(0); } + // TODO: Handling for AbsoluteFlow, InlineBlockFlow and TableFlow? } do kid.with_mut_base |child_node| {