Commit 3a6221f7 authored by Aleks Totic's avatar Aleks Totic Committed by Commit Bot

[LayoutNG] Position descendants in inline containing block.

Part 4 of 4 of inline containing block for OOF descendants
https://chromium-review.googlesource.com/c/chromium/src/+/777707

Geometry of computing the containing block coordinates is complex.

In the old code, all containing block geometry was stored as members of
NGOutOfFlowLayoutPart.

With inline containing blocks, each inline-cb can have a different geometry.
Code was refactored so that cb geometry is configurable per descendant.

Bug: 740993
Change-Id: I3dd392472081ac6b09dd6a2540d142ba9966f3a6
Reviewed-on: https://chromium-review.googlesource.com/818333
Commit-Queue: Aleks Totic <atotic@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523635}
parent 5165b8fb
......@@ -463,9 +463,12 @@ void NGBlockNode::CopyChildFragmentPosition(
// We should only be positioning children which are relative to ourselves.
// The flow thread, however, is invisible to LayoutNG, so we need to make
// an exception there.
DCHECK(box_ == layout_box->ContainingBlock() ||
(layout_box->ContainingBlock()->IsLayoutFlowThread() &&
box_ == layout_box->ContainingBlock()->ContainingBlock()));
DCHECK(
box_ == layout_box->ContainingBlock() ||
(layout_box->ContainingBlock()->IsLayoutFlowThread() &&
box_ == layout_box->ContainingBlock()->ContainingBlock()) ||
(layout_box->ContainingBlock()->IsInline() && // anonymous wrapper case
box_->Parent() == layout_box->ContainingBlock()));
// LegacyLayout flips vertical-rl horizontal coordinates before paint.
// NGLayout flips X location for LegacyLayout compatibility.
......
......@@ -37,15 +37,45 @@ class CORE_EXPORT NGOutOfFlowLayoutPart {
void Run(bool update_legacy = true);
private:
// Information needed to position descendant within a containing block.
// Geometry expressed here is complicated:
// There are two types of containing blocks:
// 1) Default containing block (DCB)
// Containing block passed in NGOutOfFlowLayoutPart constructor.
// It is the block element inside which this algorighm runs.
// All OOF descendants not in inline containing block are placed in DCB.
// 2) Inline containing block
// OOF descendants might be positioned wrt inline containing block.
// Inline containing block is positioned wrt default containing block.
struct ContainingBlockInfo {
STACK_ALLOCATED();
// Containing block style.
const ComputedStyle* style;
// Logical in containing block coordinates.
NGLogicalSize content_size;
// Content offset wrt border box.
NGLogicalOffset content_offset;
// Physical content offset wrt border box.
NGPhysicalOffset content_physical_offset;
// Logical offset wrt default containing block.
NGLogicalOffset default_container_offset;
};
ContainingBlockInfo GetContainingBlockInfo(
const NGOutOfFlowPositionedDescendant&) const;
void ComputeInlineContainingBlocks(Vector<NGOutOfFlowPositionedDescendant>);
scoped_refptr<NGLayoutResult> LayoutDescendant(
NGBlockNode descendant,
NGStaticPosition static_position,
const NGOutOfFlowPositionedDescendant&,
NGLogicalOffset* offset);
bool IsContainingBlockForDescendant(const ComputedStyle& descendant_style);
bool IsContainingBlockForDescendant(
const NGOutOfFlowPositionedDescendant& descendant);
scoped_refptr<NGLayoutResult> GenerateFragment(
NGBlockNode node,
const ContainingBlockInfo&,
const Optional<LayoutUnit>& block_estimate,
const NGAbsolutePhysicalPosition node_position);
......@@ -54,10 +84,12 @@ class CORE_EXPORT NGOutOfFlowLayoutPart {
bool contains_absolute_;
bool contains_fixed_;
ContainingBlockInfo default_containing_block_;
NGLogicalOffset content_offset_;
NGPhysicalOffset content_physical_offset_;
NGLogicalSize container_size_;
NGPhysicalSize icb_size_;
HashMap<const LayoutObject*, ContainingBlockInfo> containing_blocks_map_;
};
} // namespace blink
......
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