More accurate margin collapsing

This commit is contained in:
Ilyong Cho 2013-09-11 13:46:48 +09:00
parent 25a3d4a93f
commit e5615705ab

View file

@ -7,7 +7,7 @@
use layout::box::{RenderBox}; use layout::box::{RenderBox};
use layout::context::LayoutContext; use layout::context::LayoutContext;
use layout::display_list_builder::{DisplayListBuilder, ExtraDisplayListData}; 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::inline::InlineLayout;
use layout::model::{MaybeAuto, Specified, Auto}; use layout::model::{MaybeAuto, Specified, Auto};
use layout::float_context::{FloatContext, Invalid}; use layout::float_context::{FloatContext, Invalid};
@ -333,6 +333,7 @@ impl BlockFlowData {
margin_bottom = model.margin.bottom; margin_bottom = model.margin.bottom;
} }
} }
for kid in self.common.child_iter() { for kid in self.common.child_iter() {
match *kid { match *kid {
BlockFlow(ref info) => { BlockFlow(ref info) => {
@ -359,10 +360,18 @@ impl BlockFlowData {
} }
first_inflow = false; 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. // Margins between a floated box and any other box do not collapse.
_ => { _ => {
collapsing = Au(0); collapsing = Au(0);
} }
// TODO: Handling for AbsoluteFlow, InlineBlockFlow and TableFlow?
} }
do kid.with_mut_base |child_node| { do kid.with_mut_base |child_node| {