Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layout `position: fixed` in the initial containing block #25273

Merged
merged 13 commits into from Dec 13, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Regroup branches specific to `SameFormattingContextBlock`

  • Loading branch information
SimonSapin committed Dec 13, 2019
commit 672d971d580fbde74586d2b8b8105b4cc2940ab0
@@ -276,7 +276,7 @@ impl BlockLevelBox {
style,
BlockLevelKind::SameFormattingContextBlock(contents),
tree_rank,
float_context
float_context,
))
},
BlockLevelBox::Independent(contents) => match contents.as_replaced() {
@@ -292,7 +292,7 @@ impl BlockLevelBox {
&contents.style,
BlockLevelKind::EstablishesAnIndependentFormattingContext(non_replaced),
tree_rank,
float_context
float_context,
)),
},
BlockLevelBox::OutOfFlowAbsolutelyPositionedBox(box_) => {
@@ -398,75 +398,70 @@ fn layout_in_flow_non_replaced_block_level<'a>(
"Mixed writing modes are not supported yet"
);

let this_start_margin_can_collapse_with_children = CollapsibleWithParentStartMargin(
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(_));
let mut block_margins_collapsed_with_children = CollapsedBlockMargins::from_margin(&margin);

positioning_context.for_maybe_position_relative(layout_context, style, |positioning_context| {
This conversation was marked as resolved by nox

This comment has been minimized.

Copy link
@nox

nox Dec 13, 2019

Member

I understand the logic but I'm not sure I like how big this closure is and how it drifts everything even more to the right. Do you think it could be its own function, living in the module next to this one?

let mut flow_layout = match block_level_kind {
BlockLevelKind::SameFormattingContextBlock(contents) => contents.layout(
layout_context,
positioning_context,
&containing_block_for_children,
tree_rank,
float_context,
this_start_margin_can_collapse_with_children,
),
let fragments;
let mut content_block_size;
match block_level_kind {
BlockLevelKind::SameFormattingContextBlock(contents) => {
let this_start_margin_can_collapse_with_children = pb.block_start == Length::zero();
let this_end_margin_can_collapse_with_children = pb.block_end == Length::zero() &&
block_size == LengthOrAuto::Auto &&
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) => {
let independent_layout = non_replaced.layout(
layout_context,
positioning_context,
&containing_block_for_children,
tree_rank,
);
FlowLayout {
fragments: independent_layout.fragments,
content_block_size: independent_layout.content_block_size,
collapsible_margins_in_children: CollapsedBlockMargins::zero(),
}
}
fragments = independent_layout.fragments;
content_block_size = independent_layout.content_block_size;
},
};
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 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 {
start_corner: Vec2 {
@@ -480,7 +475,7 @@ fn layout_in_flow_non_replaced_block_level<'a>(
};
BoxFragment {
style: style.clone(),
children: flow_layout.fragments,
children: fragments,
content_rect,
padding,
border,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.