Remove PositioningContext::create_and_layout_positioned

It has only one call site.
This commit is contained in:
Anthony Ramine 2020-06-11 14:10:26 +02:00
parent b53959d23d
commit d0a1066d2d

View file

@ -218,27 +218,6 @@ impl PositioningContext {
new_fragment
}
/// Given `fragment_layout_fn`, a closure which lays out a fragment in a provided
/// `PositioningContext`, create a positioning context for a positioned fragment and lay out
/// the fragment and all its children. Returns the resulting `BoxFragment`.
fn create_and_layout_positioned(
layout_context: &LayoutContext,
style: &ComputedValues,
for_nearest_containing_block_for_all_descendants: &mut Vec<HoistedAbsolutelyPositionedBox>,
fragment_layout_fn: impl FnOnce(&mut Self) -> BoxFragment,
) -> BoxFragment {
let mut new_context = match Self::new_for_style(style) {
Some(new_context) => new_context,
None => unreachable!(),
};
let mut new_fragment = fragment_layout_fn(&mut new_context);
new_context.layout_collected_children(layout_context, &mut new_fragment);
for_nearest_containing_block_for_all_descendants
.extend(new_context.for_nearest_containing_block_for_all_descendants);
new_fragment
}
// Lay out the hoisted boxes collected into this `PositioningContext` and add them
// to the given `BoxFragment`.
pub fn layout_collected_children(
@ -467,11 +446,8 @@ impl HoistedAbsolutelyPositionedBox {
block_end: block_axis.margin_end,
};
PositioningContext::create_and_layout_positioned(
layout_context,
style,
for_nearest_containing_block_for_all_descendants,
|positioning_context| {
let mut positioning_context = PositioningContext::new_for_style(style).unwrap();
let mut new_fragment = {
let size;
let fragments;
match absolutely_positioned_box.context.contents.as_replaced() {
@ -490,10 +466,8 @@ impl HoistedAbsolutelyPositionedBox {
Anchor::Start(start) => start,
Anchor::End(end) => end,
};
let available_size = cbis -
anchor -
pbm.padding_border_sums.inline -
margin.inline_sum();
let available_size =
cbis - anchor - pbm.padding_border_sums.inline - margin.inline_sum();
absolutely_positioned_box
.context
.content_sizes
@ -514,7 +488,7 @@ impl HoistedAbsolutelyPositionedBox {
let dummy_tree_rank = 0;
let independent_layout = non_replaced.layout(
layout_context,
positioning_context,
&mut positioning_context,
&containing_block_for_children,
dummy_tree_rank,
);
@ -532,9 +506,7 @@ impl HoistedAbsolutelyPositionedBox {
let pb = &pbm.padding + &pbm.border;
let inline_start = match inline_axis.anchor {
Anchor::Start(start) => start + pb.inline_start + margin.inline_start,
Anchor::End(end) => {
cbis - end - pb.inline_end - margin.inline_end - size.inline
},
Anchor::End(end) => cbis - end - pb.inline_end - margin.inline_end - size.inline,
};
let block_start = match block_axis.anchor {
Anchor::Start(start) => start + pb.block_start + margin.block_start,
@ -559,8 +531,11 @@ impl HoistedAbsolutelyPositionedBox {
margin,
CollapsedBlockMargins::zero(),
)
},
)
};
positioning_context.layout_collected_children(layout_context, &mut new_fragment);
for_nearest_containing_block_for_all_descendants
.extend(positioning_context.for_nearest_containing_block_for_all_descendants);
new_fragment
}
}