Commit 7f8da7d0 authored by Morten Stenshorne's avatar Morten Stenshorne Committed by Commit Bot

[LayoutNG] Minor clean up in PositionWithParentBfc() & co.

Rename the method to PositionEmptyChildWithParentBfc(), and make it a
const method. Also get rid of unused and unimplemented
PositionWithBfcOffset(const NGBfcOffset&).

Also some fixes in comments and parameter names, and added some comments
on my own.

Moved a DCHECK(is_empty_block) to also hit when
PositionEmptyChildWithParentBfc(), just to be clear about the fact that
the block has to be empty at this point.

Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_layout_ng
Change-Id: I7d171aa40d3f3a5705f7a0126725a7905d37c504
Reviewed-on: https://chromium-review.googlesource.com/955645Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542197}
parent e301d424
...@@ -973,12 +973,18 @@ bool NGBlockLayoutAlgorithm::HandleInflow( ...@@ -973,12 +973,18 @@ bool NGBlockLayoutAlgorithm::HandleInflow(
if (!PositionWithBfcOffset(layout_result->BfcOffset().value(), if (!PositionWithBfcOffset(layout_result->BfcOffset().value(),
&child_bfc_offset)) &child_bfc_offset))
return false; return false;
} else if (container_builder_.BfcOffset()) { } else {
child_bfc_offset = // Layout wasn't able to determine the BFC offset of the child. This has to
PositionWithParentBfc(child, *child_space, child_data, *layout_result, // mean that the child is empty (block-size-wise).
&empty_block_affected_by_clearance);
} else
DCHECK(is_empty_block); DCHECK(is_empty_block);
if (container_builder_.BfcOffset()) {
// Since we know our own BFC offset, though, we can calculate that of the
// child as well.
child_bfc_offset = PositionEmptyChildWithParentBfc(
child, *child_space, child_data, *layout_result,
&empty_block_affected_by_clearance);
}
}
// We need to re-layout a child if it was affected by clearance in order to // We need to re-layout a child if it was affected by clearance in order to
// produce a new margin strut. For example: // produce a new margin strut. For example:
...@@ -1194,12 +1200,12 @@ bool NGBlockLayoutAlgorithm::PositionWithBfcOffset( ...@@ -1194,12 +1200,12 @@ bool NGBlockLayoutAlgorithm::PositionWithBfcOffset(
return true; return true;
} }
NGBfcOffset NGBlockLayoutAlgorithm::PositionWithParentBfc( NGBfcOffset NGBlockLayoutAlgorithm::PositionEmptyChildWithParentBfc(
const NGLayoutInputNode& child, const NGLayoutInputNode& child,
const NGConstraintSpace& space, const NGConstraintSpace& child_space,
const NGInflowChildData& child_data, const NGInflowChildData& child_data,
const NGLayoutResult& layout_result, const NGLayoutResult& layout_result,
bool* empty_block_affected_by_clearance) { bool* has_clearance) const {
DCHECK(IsEmptyBlock(child, layout_result)); DCHECK(IsEmptyBlock(child, layout_result));
// The child must be an in-flow zero-block-size fragment, use its end margin // The child must be an in-flow zero-block-size fragment, use its end margin
...@@ -1217,8 +1223,8 @@ NGBfcOffset NGBlockLayoutAlgorithm::PositionWithParentBfc( ...@@ -1217,8 +1223,8 @@ NGBfcOffset NGBlockLayoutAlgorithm::PositionWithParentBfc(
child_available_size_.inline_size); child_available_size_.inline_size);
} }
*empty_block_affected_by_clearance = *has_clearance =
AdjustToClearance(space.ClearanceOffset(), &child_bfc_offset); AdjustToClearance(child_space.ClearanceOffset(), &child_bfc_offset);
return child_bfc_offset; return child_bfc_offset;
} }
......
...@@ -82,23 +82,22 @@ class CORE_EXPORT NGBlockLayoutAlgorithm ...@@ -82,23 +82,22 @@ class CORE_EXPORT NGBlockLayoutAlgorithm
bool empty_block_affected_by_clearance); bool empty_block_affected_by_clearance);
// Positions the fragment that knows its BFC offset. // Positions the fragment that knows its BFC offset.
WTF::Optional<NGBfcOffset> PositionWithBfcOffset(
const NGBfcOffset& bfc_offset);
bool PositionWithBfcOffset(const NGBfcOffset& bfc_offset, bool PositionWithBfcOffset(const NGBfcOffset& bfc_offset,
WTF::Optional<NGBfcOffset>* child_bfc_offset); WTF::Optional<NGBfcOffset>* child_bfc_offset);
// Positions using the parent BFC offset. // Position an empty child using the parent BFC offset.
// Fragment doesn't know its offset but we can still calculate its BFC // The fragment doesn't know its offset, but we can still calculate its BFC
// position because the parent fragment's BFC is known. // position because the parent fragment's BFC is known.
// Example: // Example:
// BFC Offset is known here because of the padding. // BFC Offset is known here because of the padding.
// <div style="padding: 1px"> // <div style="padding: 1px">
// <div id="empty-div" style="margins: 1px"></div> // <div id="empty-div" style="margin: 1px"></div>
NGBfcOffset PositionWithParentBfc(const NGLayoutInputNode& child, NGBfcOffset PositionEmptyChildWithParentBfc(
const NGConstraintSpace&, const NGLayoutInputNode& child,
const NGInflowChildData& child_data, const NGConstraintSpace& child_space,
const NGLayoutResult&, const NGInflowChildData& child_data,
bool* empty_block_affected_by_clearance); const NGLayoutResult&,
bool* has_clearance) const;
void HandleOutOfFlowPositioned(const NGPreviousInflowPosition&, NGBlockNode); void HandleOutOfFlowPositioned(const NGPreviousInflowPosition&, NGBlockNode);
void HandleFloat(const NGPreviousInflowPosition&, void HandleFloat(const NGPreviousInflowPosition&,
......
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