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