mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Regroup branches specific to SameFormattingContextBlock
This commit is contained in:
parent
c0962aa3fc
commit
672d971d58
1 changed files with 55 additions and 60 deletions
|
@ -276,7 +276,7 @@ impl BlockLevelBox {
|
||||||
style,
|
style,
|
||||||
BlockLevelKind::SameFormattingContextBlock(contents),
|
BlockLevelKind::SameFormattingContextBlock(contents),
|
||||||
tree_rank,
|
tree_rank,
|
||||||
float_context
|
float_context,
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
BlockLevelBox::Independent(contents) => match contents.as_replaced() {
|
BlockLevelBox::Independent(contents) => match contents.as_replaced() {
|
||||||
|
@ -292,7 +292,7 @@ impl BlockLevelBox {
|
||||||
&contents.style,
|
&contents.style,
|
||||||
BlockLevelKind::EstablishesAnIndependentFormattingContext(non_replaced),
|
BlockLevelKind::EstablishesAnIndependentFormattingContext(non_replaced),
|
||||||
tree_rank,
|
tree_rank,
|
||||||
float_context
|
float_context,
|
||||||
)),
|
)),
|
||||||
},
|
},
|
||||||
BlockLevelBox::OutOfFlowAbsolutelyPositionedBox(box_) => {
|
BlockLevelBox::OutOfFlowAbsolutelyPositionedBox(box_) => {
|
||||||
|
@ -398,25 +398,56 @@ fn layout_in_flow_non_replaced_block_level<'a>(
|
||||||
"Mixed writing modes are not supported yet"
|
"Mixed writing modes are not supported yet"
|
||||||
);
|
);
|
||||||
|
|
||||||
let this_start_margin_can_collapse_with_children = CollapsibleWithParentStartMargin(
|
let mut block_margins_collapsed_with_children = CollapsedBlockMargins::from_margin(&margin);
|
||||||
matches!(block_level_kind, BlockLevelKind::SameFormattingContextBlock(_)) &&
|
|
||||||
pb.block_start == Length::zero(),
|
|
||||||
);
|
|
||||||
let this_end_margin_can_collapse_with_children = block_size == LengthOrAuto::Auto &&
|
|
||||||
min_box_size.block == Length::zero() &&
|
|
||||||
pb.block_end == Length::zero() &&
|
|
||||||
matches!(block_level_kind, BlockLevelKind::SameFormattingContextBlock(_));
|
|
||||||
|
|
||||||
positioning_context.for_maybe_position_relative(layout_context, style, |positioning_context| {
|
positioning_context.for_maybe_position_relative(layout_context, style, |positioning_context| {
|
||||||
let mut flow_layout = match block_level_kind {
|
let fragments;
|
||||||
BlockLevelKind::SameFormattingContextBlock(contents) => contents.layout(
|
let mut content_block_size;
|
||||||
layout_context,
|
match block_level_kind {
|
||||||
positioning_context,
|
BlockLevelKind::SameFormattingContextBlock(contents) => {
|
||||||
&containing_block_for_children,
|
let this_start_margin_can_collapse_with_children = pb.block_start == Length::zero();
|
||||||
tree_rank,
|
let this_end_margin_can_collapse_with_children = pb.block_end == Length::zero() &&
|
||||||
float_context,
|
block_size == LengthOrAuto::Auto &&
|
||||||
this_start_margin_can_collapse_with_children,
|
min_box_size.block == Length::zero();
|
||||||
),
|
|
||||||
|
let flow_layout = contents.layout(
|
||||||
|
layout_context,
|
||||||
|
positioning_context,
|
||||||
|
&containing_block_for_children,
|
||||||
|
tree_rank,
|
||||||
|
float_context,
|
||||||
|
CollapsibleWithParentStartMargin(this_start_margin_can_collapse_with_children),
|
||||||
|
);
|
||||||
|
fragments = flow_layout.fragments;
|
||||||
|
content_block_size = flow_layout.content_block_size;
|
||||||
|
let mut collapsible_margins_in_children =
|
||||||
|
flow_layout.collapsible_margins_in_children;
|
||||||
|
|
||||||
|
if this_start_margin_can_collapse_with_children {
|
||||||
|
block_margins_collapsed_with_children
|
||||||
|
.start
|
||||||
|
.adjoin_assign(&collapsible_margins_in_children.start);
|
||||||
|
if collapsible_margins_in_children.collapsed_through {
|
||||||
|
block_margins_collapsed_with_children.start.adjoin_assign(
|
||||||
|
&std::mem::replace(
|
||||||
|
&mut collapsible_margins_in_children.end,
|
||||||
|
CollapsedMargin::zero(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if this_end_margin_can_collapse_with_children {
|
||||||
|
block_margins_collapsed_with_children
|
||||||
|
.end
|
||||||
|
.adjoin_assign(&collapsible_margins_in_children.end);
|
||||||
|
} else {
|
||||||
|
content_block_size += collapsible_margins_in_children.end.solve();
|
||||||
|
}
|
||||||
|
block_margins_collapsed_with_children.collapsed_through =
|
||||||
|
this_start_margin_can_collapse_with_children &&
|
||||||
|
this_end_margin_can_collapse_with_children &&
|
||||||
|
collapsible_margins_in_children.collapsed_through;
|
||||||
|
},
|
||||||
BlockLevelKind::EstablishesAnIndependentFormattingContext(non_replaced) => {
|
BlockLevelKind::EstablishesAnIndependentFormattingContext(non_replaced) => {
|
||||||
let independent_layout = non_replaced.layout(
|
let independent_layout = non_replaced.layout(
|
||||||
layout_context,
|
layout_context,
|
||||||
|
@ -424,49 +455,13 @@ fn layout_in_flow_non_replaced_block_level<'a>(
|
||||||
&containing_block_for_children,
|
&containing_block_for_children,
|
||||||
tree_rank,
|
tree_rank,
|
||||||
);
|
);
|
||||||
FlowLayout {
|
fragments = independent_layout.fragments;
|
||||||
fragments: independent_layout.fragments,
|
content_block_size = independent_layout.content_block_size;
|
||||||
content_block_size: independent_layout.content_block_size,
|
},
|
||||||
collapsible_margins_in_children: CollapsedBlockMargins::zero(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
let mut block_margins_collapsed_with_children = CollapsedBlockMargins::from_margin(&margin);
|
|
||||||
if this_start_margin_can_collapse_with_children.0 {
|
|
||||||
block_margins_collapsed_with_children
|
|
||||||
.start
|
|
||||||
.adjoin_assign(&flow_layout.collapsible_margins_in_children.start);
|
|
||||||
if flow_layout
|
|
||||||
.collapsible_margins_in_children
|
|
||||||
.collapsed_through
|
|
||||||
{
|
|
||||||
block_margins_collapsed_with_children
|
|
||||||
.start
|
|
||||||
.adjoin_assign(&std::mem::replace(
|
|
||||||
&mut flow_layout.collapsible_margins_in_children.end,
|
|
||||||
CollapsedMargin::zero(),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if this_end_margin_can_collapse_with_children {
|
|
||||||
block_margins_collapsed_with_children
|
|
||||||
.end
|
|
||||||
.adjoin_assign(&flow_layout.collapsible_margins_in_children.end);
|
|
||||||
} else {
|
|
||||||
flow_layout.content_block_size +=
|
|
||||||
flow_layout.collapsible_margins_in_children.end.solve();
|
|
||||||
}
|
|
||||||
block_margins_collapsed_with_children.collapsed_through =
|
|
||||||
this_start_margin_can_collapse_with_children.0 &&
|
|
||||||
this_end_margin_can_collapse_with_children &&
|
|
||||||
flow_layout
|
|
||||||
.collapsible_margins_in_children
|
|
||||||
.collapsed_through;
|
|
||||||
let relative_adjustement = relative_adjustement(style, inline_size, block_size);
|
let relative_adjustement = relative_adjustement(style, inline_size, block_size);
|
||||||
let block_size = block_size.auto_is(|| {
|
let block_size = block_size.auto_is(|| {
|
||||||
flow_layout
|
content_block_size.clamp_between_extremums(min_box_size.block, max_box_size.block)
|
||||||
.content_block_size
|
|
||||||
.clamp_between_extremums(min_box_size.block, max_box_size.block)
|
|
||||||
});
|
});
|
||||||
let content_rect = Rect {
|
let content_rect = Rect {
|
||||||
start_corner: Vec2 {
|
start_corner: Vec2 {
|
||||||
|
@ -480,7 +475,7 @@ fn layout_in_flow_non_replaced_block_level<'a>(
|
||||||
};
|
};
|
||||||
BoxFragment {
|
BoxFragment {
|
||||||
style: style.clone(),
|
style: style.clone(),
|
||||||
children: flow_layout.fragments,
|
children: fragments,
|
||||||
content_rect,
|
content_rect,
|
||||||
padding,
|
padding,
|
||||||
border,
|
border,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue