Commit b453c812 authored by Ian Kilpatrick's avatar Ian Kilpatrick Committed by Commit Bot

[LayoutNG] Update BFC (block) offset resolving documentation.

This was pretty mechanical, but everything I think still makes sense.
Effectively everything that references "resolving a BFC offset" now
turns into "resolving a BFC block offset".

There should be no behaviour change.

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: I1215520ab21eae6fb45b4ab53be08a0fdde232ac
Bug: 635619
Reviewed-on: https://chromium-review.googlesource.com/1155266Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579816}
parent a6ff60aa
......@@ -618,7 +618,7 @@ scoped_refptr<NGLayoutResult> NGInlineLayoutAlgorithm::Layout() {
// We're just going to collapse through this one, so whatever went in on one
// side will go out on the other side. The position of the adjoining floats
// will be affected by any subsequent block, until the BFC offset is
// will be affected by any subsequent block, until the BFC block offset is
// resolved.
container_builder_.AddAdjoiningFloatTypes(
ConstraintSpace().AdjoiningFloatTypes());
......@@ -635,8 +635,8 @@ scoped_refptr<NGLayoutResult> NGInlineLayoutAlgorithm::Layout() {
container_builder_.SetBfcBlockOffset(
ConstraintSpace().BfcOffset().block_offset);
// The BFC offset was determined before entering this algorithm. This means
// that there should be no adjoining floats.
// The BFC block offset was determined before entering this algorithm. This
// means that there should be no adjoining floats.
DCHECK(!ConstraintSpace().AdjoiningFloatTypes());
}
......
......@@ -801,8 +801,8 @@ void NGLineBreaker::HandleAtomicInline(const NGInlineItem& item) {
// Performs layout and positions a float.
//
// If there is a known available_width (e.g. something has resolved the
// container BFC offset) it will attempt to position the float on the current
// line.
// container BFC block offset) it will attempt to position the float on the
// current line.
// Additionally updates the available_width for the line as the float has
// (probably) consumed space.
//
......
......@@ -60,17 +60,18 @@ class CORE_EXPORT NGBlockLayoutAlgorithm
scoped_refptr<NGLayoutResult> Layout() override;
private:
// Return the BFC offset of this block.
// Return the BFC block offset of this block.
LayoutUnit BfcBlockOffset() const {
// If we have resolved our BFC offset, use that.
// If we have resolved our BFC block offset, use that.
if (container_builder_.BfcBlockOffset())
return *container_builder_.BfcBlockOffset();
// Otherwise fall back to the BFC offset assigned by the parent algorithm.
// Otherwise fall back to the BFC block offset assigned by the parent
// algorithm.
return ConstraintSpace().BfcOffset().block_offset;
}
// Return the BFC offset of the next block-start border edge (for some child)
// we'd get if we commit pending margins.
// Return the BFC block offset of the next block-start border edge (for some
// child) we'd get if we commit pending margins.
LayoutUnit NextBorderEdge(
const NGPreviousInflowPosition& previous_inflow_position) const {
return BfcBlockOffset() + previous_inflow_position.logical_block_offset +
......@@ -87,7 +88,7 @@ class CORE_EXPORT NGBlockLayoutAlgorithm
const NGLogicalSize child_available_size,
const base::Optional<LayoutUnit> floats_bfc_block_offset = base::nullopt);
// @return Estimated BFC offset for the "to be layout" child.
// @return Estimated BFC block offset for the "to be layout" child.
NGInflowChildData ComputeChildData(const NGPreviousInflowPosition&,
NGLayoutInputNode,
const NGBreakToken* child_break_token,
......@@ -103,7 +104,7 @@ class CORE_EXPORT NGBlockLayoutAlgorithm
const NGFragment&,
bool empty_block_affected_by_clearance);
// Position an empty child using the parent BFC offset.
// Position an empty child using the parent BFC block offset.
// The fragment doesn't know its offset, but we can still calculate its BFC
// position because the parent fragment's BFC is known.
// Example:
......@@ -137,7 +138,7 @@ class CORE_EXPORT NGBlockLayoutAlgorithm
// below #float ignoring its vertical margin.
//
// Returns false if we need to abort layout, because a previously unknown BFC
// offset has now been resolved.
// block offset has now been resolved.
bool HandleNewFormattingContext(
NGLayoutInputNode child,
NGBreakToken* child_break_token,
......@@ -155,7 +156,7 @@ class CORE_EXPORT NGBlockLayoutAlgorithm
// Handle an in-flow child.
// Returns false if we need to abort layout, because a previously unknown BFC
// offset has now been resolved. (Same as HandleNewFormattingContext).
// block offset has now been resolved. (Same as HandleNewFormattingContext).
bool HandleInflow(NGLayoutInputNode child,
NGBreakToken* child_break_token,
NGPreviousInflowPosition*,
......@@ -207,29 +208,32 @@ class CORE_EXPORT NGBlockLayoutAlgorithm
const NGPhysicalLineBoxFragment&,
LayoutUnit line_box_block_offset) const;
// If still unresolved, resolve the fragment's BFC offset.
// If still unresolved, resolve the fragment's BFC block offset.
//
// This includes applying clearance, so the bfc_block_offset passed won't be
// the final BFC offset, if it wasn't large enough to get past all relevant
// floats. The updated BFC offset can be read out with ContainerBfcOffset().
// the final BFC block offset, if it wasn't large enough to get past all
// relevant floats. The updated BFC block offset can be read out with
// ContainerBfcBlockOffset().
//
// In addition to resolving our BFC offset, this will also position pending
// floats, and update our in-flow layout state. Returns false if resolving the
// BFC offset resulted in needing to abort layout. It will always return true
// otherwise. If the BFC offset was already resolved, this method does nothing
// (and returns true).
bool ResolveBfcOffset(NGPreviousInflowPosition*, LayoutUnit bfc_block_offset);
// A very common way to resolve the BFC offset is to simply commit the pending
// margin, so here's a convenience overload for that.
bool ResolveBfcOffset(NGPreviousInflowPosition* previous_inflow_position) {
return ResolveBfcOffset(previous_inflow_position,
NextBorderEdge(*previous_inflow_position));
// In addition to resolving our BFC block offset, this will also position
// pending floats, and update our in-flow layout state. Returns false if
// resolving the BFC block offset resulted in needing to abort layout. It
// will always return true otherwise. If the BFC block offset was already
// resolved, this method does nothing (and returns true).
bool ResolveBfcBlockOffset(NGPreviousInflowPosition*,
LayoutUnit bfc_block_offset);
// A very common way to resolve the BFC block offset is to simply commit the
// pending margin, so here's a convenience overload for that.
bool ResolveBfcBlockOffset(
NGPreviousInflowPosition* previous_inflow_position) {
return ResolveBfcBlockOffset(previous_inflow_position,
NextBorderEdge(*previous_inflow_position));
}
// Return true if the BFC offset has changed and this means that we need to
// abort layout.
bool NeedsAbortOnBfcOffsetChange() const;
// Return true if the BFC block offset has changed and this means that we
// need to abort layout.
bool NeedsAbortOnBfcBlockOffsetChange() const;
// Positions pending floats starting from {@origin_block_offset}.
void PositionPendingFloats(LayoutUnit origin_block_offset);
......@@ -280,13 +284,13 @@ class CORE_EXPORT NGBlockLayoutAlgorithm
// Set if we're resuming layout of a node that has already produced fragments.
bool is_resuming_;
// Set when we're to abort if the BFC offset gets resolved or updated.
// Sometimes we walk past elements (i.e. floats) that depend on the BFC offset
// being known (in order to position and lay themselves out properly). When
// this happens, and we finally manage to resolve (or update) the BFC offset
// at some subsequent element, we need to check if this flag is set, and abort
// layout if it is.
bool abort_when_bfc_offset_updated_ = false;
// Set when we're to abort if the BFC block offset gets resolved or updated.
// Sometimes we walk past elements (i.e. floats) that depend on the BFC block
// offset being known (in order to position and lay themselves out properly).
// When this happens, and we finally manage to resolve (or update) the BFC
// block offset at some subsequent element, we need to check if this flag is
// set, and abort layout if it is.
bool abort_when_bfc_block_offset_updated_ = false;
bool has_processed_first_child_ = false;
......
......@@ -53,7 +53,7 @@ CORE_EXPORT const Vector<NGPositionedFloat> PositionFloats(
NGExclusionSpace* exclusion_space);
// Add a pending float to the list. It will be committed (positioned) once we
// have resolved the BFC offset.
// have resolved the BFC block offset.
void AddUnpositionedFloat(
Vector<scoped_refptr<NGUnpositionedFloat>>* unpositioned_floats,
NGContainerFragmentBuilder* fragment_builder,
......
......@@ -31,7 +31,7 @@ class CORE_EXPORT NGLayoutResult : public RefCounted<NGLayoutResult> {
public:
enum NGLayoutResultStatus {
kSuccess = 0,
kBfcOffsetResolved = 1,
kBfcBlockOffsetResolved = 1,
// When adding new values, make sure the bit size of |status_| is large
// enough to store.
};
......@@ -101,8 +101,8 @@ class CORE_EXPORT NGLayoutResult : public RefCounted<NGLayoutResult> {
bool IsPushedByFloats() const { return is_pushed_by_floats_; }
// Return the types (none, left, right, both) of preceding adjoining
// floats. These are floats that are added while the in-flow BFC offset is
// still unknown. The floats may or may not be unpositioned (pending). That
// floats. These are floats that are added while the in-flow BFC block offset
// is still unknown. The floats may or may not be unpositioned (pending). That
// depends on which layout pass we're in. Adjoining floats should be treated
// differently when calculating clearance on a block with adjoining
// block-start margin (in such cases we will know up front that the block will
......
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