Move call to for_maybe_position_relative out of layout_in_flow_non_replaced_block_level

This commit is contained in:
Simon Sapin 2019-12-13 12:41:58 +01:00
parent 672d971d58
commit 04b701b9e0

View file

@ -269,7 +269,11 @@ impl BlockLevelBox {
) -> Fragment { ) -> Fragment {
match self { match self {
BlockLevelBox::SameFormattingContextBlock { style, contents } => { BlockLevelBox::SameFormattingContextBlock { style, contents } => {
Fragment::Box(layout_in_flow_non_replaced_block_level( Fragment::Box(positioning_context.for_maybe_position_relative(
layout_context,
style,
|positioning_context| {
layout_in_flow_non_replaced_block_level(
layout_context, layout_context,
positioning_context, positioning_context,
containing_block, containing_block,
@ -277,15 +281,21 @@ impl BlockLevelBox {
BlockLevelKind::SameFormattingContextBlock(contents), BlockLevelKind::SameFormattingContextBlock(contents),
tree_rank, tree_rank,
float_context, float_context,
)
},
)) ))
}, },
BlockLevelBox::Independent(contents) => match contents.as_replaced() { BlockLevelBox::Independent(contents) => {
Ok(replaced) => Fragment::Box(layout_in_flow_replaced_block_level( Fragment::Box(positioning_context.for_maybe_position_relative(
layout_context,
&contents.style,
|positioning_context| match contents.as_replaced() {
Ok(replaced) => layout_in_flow_replaced_block_level(
containing_block, containing_block,
&contents.style, &contents.style,
replaced, replaced,
)), ),
Err(non_replaced) => Fragment::Box(layout_in_flow_non_replaced_block_level( Err(non_replaced) => layout_in_flow_non_replaced_block_level(
layout_context, layout_context,
positioning_context, positioning_context,
containing_block, containing_block,
@ -293,7 +303,9 @@ impl BlockLevelBox {
BlockLevelKind::EstablishesAnIndependentFormattingContext(non_replaced), BlockLevelKind::EstablishesAnIndependentFormattingContext(non_replaced),
tree_rank, tree_rank,
float_context, float_context,
)), ),
},
))
}, },
BlockLevelBox::OutOfFlowAbsolutelyPositionedBox(box_) => { BlockLevelBox::OutOfFlowAbsolutelyPositionedBox(box_) => {
positioning_context.push(box_.layout(Vec2::zero(), tree_rank)); positioning_context.push(box_.layout(Vec2::zero(), tree_rank));
@ -302,6 +314,7 @@ impl BlockLevelBox {
)) ))
}, },
BlockLevelBox::OutOfFlowFloatBox(_box_) => { BlockLevelBox::OutOfFlowFloatBox(_box_) => {
// FIXME: call for_maybe_position_relative here
// TODO // TODO
Fragment::Anonymous(AnonymousFragment::no_op( Fragment::Anonymous(AnonymousFragment::no_op(
containing_block.style.writing_mode, containing_block.style.writing_mode,
@ -400,7 +413,6 @@ fn layout_in_flow_non_replaced_block_level<'a>(
let mut block_margins_collapsed_with_children = CollapsedBlockMargins::from_margin(&margin); let mut block_margins_collapsed_with_children = CollapsedBlockMargins::from_margin(&margin);
positioning_context.for_maybe_position_relative(layout_context, style, |positioning_context| {
let fragments; let fragments;
let mut content_block_size; let mut content_block_size;
match block_level_kind { match block_level_kind {
@ -420,20 +432,19 @@ fn layout_in_flow_non_replaced_block_level<'a>(
); );
fragments = flow_layout.fragments; fragments = flow_layout.fragments;
content_block_size = flow_layout.content_block_size; content_block_size = flow_layout.content_block_size;
let mut collapsible_margins_in_children = let mut collapsible_margins_in_children = flow_layout.collapsible_margins_in_children;
flow_layout.collapsible_margins_in_children;
if this_start_margin_can_collapse_with_children { if this_start_margin_can_collapse_with_children {
block_margins_collapsed_with_children block_margins_collapsed_with_children
.start .start
.adjoin_assign(&collapsible_margins_in_children.start); .adjoin_assign(&collapsible_margins_in_children.start);
if collapsible_margins_in_children.collapsed_through { if collapsible_margins_in_children.collapsed_through {
block_margins_collapsed_with_children.start.adjoin_assign( block_margins_collapsed_with_children
&std::mem::replace( .start
.adjoin_assign(&std::mem::replace(
&mut collapsible_margins_in_children.end, &mut collapsible_margins_in_children.end,
CollapsedMargin::zero(), CollapsedMargin::zero(),
), ));
);
} }
} }
if this_end_margin_can_collapse_with_children { if this_end_margin_can_collapse_with_children {
@ -482,7 +493,6 @@ fn layout_in_flow_non_replaced_block_level<'a>(
margin, margin,
block_margins_collapsed_with_children, block_margins_collapsed_with_children,
} }
})
} }
/// https://drafts.csswg.org/css2/visudet.html#block-replaced-width /// https://drafts.csswg.org/css2/visudet.html#block-replaced-width