Commit e057ba08 authored by Morten Stenshorne's avatar Morten Stenshorne Committed by Commit Bot

[LayoutNG] Untangle block-offset relativeness for BreakBeforeChildIfNeeded().

BreakBeforeChildIfNeeded() needs to make the block-offset relative to
the fragmentainer, so passing an offset that's relative to the BFC gives
less work than passing one relative to the containing block.

This is just cleanup - no behavior changes.

Change-Id: I49fa3415e37191e285c2d4844465862d46ebc58f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2023887Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735756}
parent 51e7f3b3
......@@ -1231,13 +1231,6 @@ NGLayoutResult::EStatus NGBlockLayoutAlgorithm::HandleNewFormattingContext(
/* abort_if_cleared */ false, &child_bfc_offset);
}
const auto& physical_fragment = layout_result->PhysicalFragment();
NGFragment fragment(ConstraintSpace().GetWritingMode(), physical_fragment);
LogicalOffset logical_offset = LogicalFromBfcOffsets(
child_bfc_offset, ContainerBfcOffset(), fragment.InlineSize(),
container_builder_.Size().inline_size, ConstraintSpace().Direction());
if (ConstraintSpace().HasBlockFragmentation()) {
bool has_container_separation =
has_processed_first_child_ || child_margin_got_separated ||
......@@ -1245,7 +1238,7 @@ NGLayoutResult::EStatus NGBlockLayoutAlgorithm::HandleNewFormattingContext(
layout_result->IsPushedByFloats();
NGBreakStatus break_status = BreakBeforeChildIfNeeded(
child, *layout_result, previous_inflow_position,
logical_offset.block_offset, has_container_separation);
child_bfc_offset.block_offset, has_container_separation);
if (break_status == NGBreakStatus::kBrokeBefore)
return NGLayoutResult::kSuccess;
if (break_status == NGBreakStatus::kNeedsEarlierBreak)
......@@ -1255,6 +1248,13 @@ NGLayoutResult::EStatus NGBlockLayoutAlgorithm::HandleNewFormattingContext(
container_builder_.SetPreviousBreakAfter(break_after);
}
const auto& physical_fragment = layout_result->PhysicalFragment();
NGFragment fragment(ConstraintSpace().GetWritingMode(), physical_fragment);
LogicalOffset logical_offset = LogicalFromBfcOffsets(
child_bfc_offset, ContainerBfcOffset(), fragment.InlineSize(),
container_builder_.Size().inline_size, ConstraintSpace().Direction());
if (!PositionOrPropagateListMarker(*layout_result, &logical_offset,
previous_inflow_position))
return NGLayoutResult::kBfcBlockOffsetResolved;
......@@ -1732,7 +1732,8 @@ NGLayoutResult::EStatus NGBlockLayoutAlgorithm::FinishInflow(
LogicalOffset logical_offset = CalculateLogicalOffset(
fragment, layout_result->BfcLineOffset(), child_bfc_block_offset);
if (ConstraintSpace().HasBlockFragmentation()) {
if (ConstraintSpace().HasBlockFragmentation() &&
container_builder_.BfcBlockOffset() && child_bfc_block_offset) {
// Floats only cause container separation for the outermost block child that
// gets pushed down (the container and the child may have adjoining
// block-start margins).
......@@ -1741,7 +1742,7 @@ NGLayoutResult::EStatus NGBlockLayoutAlgorithm::FinishInflow(
!container_builder_.IsPushedByFloats());
NGBreakStatus break_status = BreakBeforeChildIfNeeded(
child, *layout_result, previous_inflow_position,
logical_offset.block_offset, has_container_separation);
*child_bfc_block_offset, has_container_separation);
if (break_status == NGBreakStatus::kBrokeBefore)
return NGLayoutResult::kSuccess;
if (break_status == NGBreakStatus::kNeedsEarlierBreak)
......@@ -2080,14 +2081,13 @@ NGBreakStatus NGBlockLayoutAlgorithm::BreakBeforeChildIfNeeded(
NGLayoutInputNode child,
const NGLayoutResult& layout_result,
NGPreviousInflowPosition* previous_inflow_position,
LayoutUnit block_offset,
LayoutUnit bfc_block_offset,
bool has_container_separation) {
DCHECK(ConstraintSpace().HasBlockFragmentation());
// If the BFC offset is unknown, there's nowhere to break, since there's no
// non-empty child content yet (as that would have resolved the BFC offset).
if (!container_builder_.BfcBlockOffset())
return NGBreakStatus::kContinue;
DCHECK(container_builder_.BfcBlockOffset());
// If we already know where to insert the break, we already know that it's not
// going to be here, since that's something we check before entering layout of
......@@ -2096,8 +2096,7 @@ NGBreakStatus NGBlockLayoutAlgorithm::BreakBeforeChildIfNeeded(
return NGBreakStatus::kContinue;
LayoutUnit fragmentainer_block_offset =
ConstraintSpace().FragmentainerOffsetAtBfc() +
*container_builder_.BfcBlockOffset() + block_offset;
ConstraintSpace().FragmentainerOffsetAtBfc() + bfc_block_offset;
if (has_container_separation) {
EBreakBetween break_between =
......
......@@ -232,7 +232,7 @@ class CORE_EXPORT NGBlockLayoutAlgorithm
NGBreakStatus BreakBeforeChildIfNeeded(NGLayoutInputNode child,
const NGLayoutResult&,
NGPreviousInflowPosition*,
LayoutUnit block_offset,
LayoutUnit bfc_block_offset,
bool has_container_separation);
// Look for a better breakpoint (than we already have) between lines (i.e. a
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment