summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.h')
-rw-r--r--chromium/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.h108
1 files changed, 58 insertions, 50 deletions
diff --git a/chromium/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.h b/chromium/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.h
index 6e979c6e022..dab8d19c237 100644
--- a/chromium/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.h
+++ b/chromium/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.h
@@ -12,6 +12,8 @@
#include "third_party/blink/renderer/core/layout/ng/ng_block_node.h"
#include "third_party/blink/renderer/core/layout/ng/ng_fragment_builder.h"
#include "third_party/blink/renderer/core/layout/ng/ng_layout_algorithm.h"
+#include "third_party/blink/renderer/core/layout/ng/ng_unpositioned_float.h"
+#include "third_party/blink/renderer/core/layout/ng/ng_unpositioned_float_vector.h"
namespace blink {
@@ -55,22 +57,25 @@ class CORE_EXPORT NGBlockLayoutAlgorithm
~NGBlockLayoutAlgorithm() override;
+ void SetBoxType(NGPhysicalFragment::NGBoxType type);
+
base::Optional<MinMaxSize> ComputeMinMaxSize(
const MinMaxSizeInput&) const override;
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 (container_builder_.BfcOffset())
- return container_builder_.BfcOffset()->block_offset;
- // Otherwise fall back to the BFC offset assigned by the parent algorithm.
+ // If we have resolved our BFC block offset, use that.
+ if (container_builder_.BfcBlockOffset())
+ return *container_builder_.BfcBlockOffset();
+ // 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 +
@@ -85,32 +90,32 @@ class CORE_EXPORT NGBlockLayoutAlgorithm
const NGLayoutInputNode child,
const NGInflowChildData& child_data,
const NGLogicalSize child_available_size,
- const base::Optional<NGBfcOffset> floats_bfc_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&,
NGLayoutInputNode,
const NGBreakToken* child_break_token,
bool force_clearance);
NGPreviousInflowPosition ComputeInflowPosition(
- const NGPreviousInflowPosition& previous_inflow_position,
+ const NGPreviousInflowPosition&,
const NGLayoutInputNode child,
- const NGInflowChildData& child_data,
- const base::Optional<NGBfcOffset>& child_bfc_offset,
- const NGLogicalOffset& logical_offset,
- const NGLayoutResult& layout_result,
- const NGFragment& fragment,
+ const NGInflowChildData&,
+ const base::Optional<LayoutUnit>& child_bfc_block_offset,
+ const NGLogicalOffset&,
+ const NGLayoutResult&,
+ 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:
// BFC Offset is known here because of the padding.
// <div style="padding: 1px">
// <div id="empty-div" style="margin: 1px"></div>
- NGBfcOffset PositionEmptyChildWithParentBfc(
+ LayoutUnit PositionEmptyChildWithParentBfc(
const NGLayoutInputNode& child,
const NGConstraintSpace& child_space,
const NGInflowChildData& child_data,
@@ -137,7 +142,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,
@@ -150,12 +155,12 @@ class CORE_EXPORT NGBlockLayoutAlgorithm
LayoutNewFormattingContext(NGLayoutInputNode child,
NGBreakToken* child_break_token,
const NGInflowChildData&,
- LayoutUnit child_origin_block_offset,
+ NGBfcOffset origin_offset,
bool abort_if_cleared);
// 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 +212,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);
@@ -248,10 +256,9 @@ class CORE_EXPORT NGBlockLayoutAlgorithm
// {@code known_fragment_offset} if the fragment knows it's offset
// @return Fragment's offset relative to the fragment's parent.
NGLogicalOffset CalculateLogicalOffset(
- NGLayoutInputNode child,
- const NGFragment&,
- const NGBoxStrut& child_margins,
- const base::Optional<NGBfcOffset>& known_fragment_offset);
+ const NGFragment& fragment,
+ LayoutUnit child_bfc_line_offset,
+ const base::Optional<LayoutUnit>& child_bfc_block_offset);
// Computes default content size for HTML and BODY elements in quirks mode.
// Returns NGSizeIndefinite in all other cases.
@@ -264,6 +271,7 @@ class CORE_EXPORT NGBlockLayoutAlgorithm
NGLogicalSize child_available_size_;
NGLogicalSize child_percentage_size_;
+ NGBoxStrut border_padding_;
NGBoxStrut border_scrollbar_padding_;
LayoutUnit intrinsic_block_size_;
@@ -281,18 +289,18 @@ 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;
std::unique_ptr<NGExclusionSpace> exclusion_space_;
- Vector<scoped_refptr<NGUnpositionedFloat>> unpositioned_floats_;
+ NGUnpositionedFloatVector unpositioned_floats_;
};
} // namespace blink