diff --git a/components/layout_2020/flow/float.rs b/components/layout_2020/flow/float.rs index 841fc2e19b7..657e7bef608 100644 --- a/components/layout_2020/flow/float.rs +++ b/components/layout_2020/flow/float.rs @@ -981,22 +981,6 @@ impl SequentialLayoutState { Some(clear_position - position_with_zero_clearance) } - /// Helper function that computes the clearance and adds `block_start_margin` accordingly. - /// If there is no clearance, `block_start_margin` can just be adjoined to `current_margin`. - /// But clearance prevents them from collapsing, so `collapse_margins()` is called. - pub(crate) fn calculate_clearance_and_adjoin_margin( - &mut self, - style: &Arc, - block_start_margin: &CollapsedMargin, - ) -> Option { - let clearance = self.calculate_clearance(ClearSide::from_style(style), &block_start_margin); - if clearance.is_some() { - self.collapse_margins(); - } - self.adjoin_assign(&block_start_margin); - clearance - } - /// Adds a new adjoining margin. pub(crate) fn adjoin_assign(&mut self, margin: &CollapsedMargin) { self.current_margin.adjoin_assign(margin) diff --git a/components/layout_2020/flow/mod.rs b/components/layout_2020/flow/mod.rs index 5ccadcf013d..dc46e8dc53d 100644 --- a/components/layout_2020/flow/mod.rs +++ b/components/layout_2020/flow/mod.rs @@ -654,7 +654,11 @@ fn layout_in_flow_non_replaced_block_level_same_formatting_context( // Introduce clearance if necessary. clearance = sequential_layout_state - .calculate_clearance_and_adjoin_margin(style, &block_start_margin); + .calculate_clearance(ClearSide::from_style(style), &block_start_margin); + if clearance.is_some() { + sequential_layout_state.collapse_margins(); + } + sequential_layout_state.adjoin_assign(&block_start_margin); if !start_margin_can_collapse_with_children { sequential_layout_state.collapse_margins(); }