diff options
-rw-r--r-- | components/layout/block.rs | 5 | ||||
-rw-r--r-- | components/layout/model.rs | 19 |
2 files changed, 15 insertions, 9 deletions
diff --git a/components/layout/block.rs b/components/layout/block.rs index 763698d85a4..2d768b0c55d 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -809,6 +809,7 @@ impl BlockFlow { // At this point, `cur_b` is at the content edge of our box. Now iterate over children. let mut floats = self.base.floats.clone(); let thread_id = self.base.thread_id; + let mut had_float_children = false; for (child_index, kid) in self.base.child_iter_mut().enumerate() { if flow::base(kid).flags.contains(IS_ABSOLUTELY_POSITIONED) { // Assume that the *hypothetical box* for an absolute flow starts immediately @@ -844,6 +845,7 @@ impl BlockFlow { // before. flow::mut_base(kid).floats = floats.clone(); if flow::base(kid).flags.is_float() { + had_float_children = true; flow::mut_base(kid).position.start.b = cur_b; { let kid_block = kid.as_mut_block(); @@ -932,7 +934,8 @@ impl BlockFlow { margin_collapse_info.finish_and_compute_collapsible_margins( &self.fragment, self.base.block_container_explicit_block_size, - can_collapse_block_end_margin_with_kids); + can_collapse_block_end_margin_with_kids, + !had_float_children); self.base.collapsible_margins = collapsible_margins; translate_including_floats(&mut cur_b, delta, &mut floats); diff --git a/components/layout/model.rs b/components/layout/model.rs index 8b18a1f02ad..7bb4cf23cbe 100644 --- a/components/layout/model.rs +++ b/components/layout/model.rs @@ -126,17 +126,20 @@ impl MarginCollapseInfo { pub fn finish_and_compute_collapsible_margins(mut self, fragment: &Fragment, containing_block_size: Option<Au>, - can_collapse_block_end_margin_with_kids: bool) + can_collapse_block_end_margin_with_kids: bool, + mut may_collapse_through: bool) -> (CollapsibleMargins, Au) { let state = match self.state { MarginCollapseState::AccumulatingCollapsibleTopMargin => { - let may_collapse_through = match fragment.style().content_block_size() { - LengthOrPercentageOrAuto::Auto => true, - LengthOrPercentageOrAuto::Length(Au(0)) => true, - LengthOrPercentageOrAuto::Percentage(0.) => true, - LengthOrPercentageOrAuto::Percentage(_) if containing_block_size.is_none() => true, - _ => false, - }; + may_collapse_through = may_collapse_through && + match fragment.style().content_block_size() { + LengthOrPercentageOrAuto::Auto => true, + LengthOrPercentageOrAuto::Length(Au(0)) => true, + LengthOrPercentageOrAuto::Percentage(0.) => true, + LengthOrPercentageOrAuto::Percentage(_) if + containing_block_size.is_none() => true, + _ => false, + }; if may_collapse_through { match fragment.style().min_block_size() { |