Commit 13c12e7a authored by Benjamin Beaudry's avatar Benjamin Beaudry Committed by Commit Bot

[LayoutNG] Store the containing block offset

This change adds the containing block offset inside
NGPhysicalOutOfFlowPositionedNode and NGLogicalOutOfFlowPositionedNode.
This is part of the work for handling layout of positioned elements at
the fragmentainer level rather than at the containing block level.

A follow-up change will make use of this offset to compute where the
layout of an OOF positioned node should start in a multicolumn context.

Bug: 1079031
Change-Id: I2e3370a4ec0a4011203d0c3e916a64584aceaa2e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2321405
Commit-Queue: Benjamin Beaudry <benjamin.beaudry@microsoft.com>
Reviewed-by: default avatarAlison Maher <almaher@microsoft.com>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#793618}
parent 9024cf9a
...@@ -73,12 +73,17 @@ void NGContainerFragmentBuilder::PropagateChildData( ...@@ -73,12 +73,17 @@ void NGContainerFragmentBuilder::PropagateChildData(
if (!containing_block_fragment) if (!containing_block_fragment)
containing_block_fragment = fragment; containing_block_fragment = fragment;
LogicalOffset containing_block_offset =
descendant.containing_block_offset.ConvertToLogical(
GetWritingMode(), Direction(), child.Size(), PhysicalSize());
containing_block_offset += child_offset;
NGLogicalStaticPosition static_position = NGLogicalStaticPosition static_position =
descendant.static_position.ConvertToLogical( descendant.static_position.ConvertToLogical(
GetWritingMode(), Direction(), PhysicalSize()); GetWritingMode(), Direction(), PhysicalSize());
oof_positioned_fragmentainer_descendants_.emplace_back( oof_positioned_fragmentainer_descendants_.emplace_back(
descendant.node, static_position, descendant.inline_container, descendant.node, static_position, descendant.inline_container,
/* needs_block_offset_adjustment */ false, /* needs_block_offset_adjustment */ false, containing_block_offset,
containing_block_fragment); containing_block_fragment);
} }
} }
......
...@@ -37,17 +37,20 @@ struct CORE_EXPORT NGPhysicalOutOfFlowPositionedNode { ...@@ -37,17 +37,20 @@ struct CORE_EXPORT NGPhysicalOutOfFlowPositionedNode {
NGPhysicalStaticPosition static_position; NGPhysicalStaticPosition static_position;
// Continuation root of the optional inline container. // Continuation root of the optional inline container.
const LayoutInline* inline_container; const LayoutInline* inline_container;
PhysicalOffset containing_block_offset;
scoped_refptr<const NGPhysicalContainerFragment> containing_block_fragment; scoped_refptr<const NGPhysicalContainerFragment> containing_block_fragment;
NGPhysicalOutOfFlowPositionedNode( NGPhysicalOutOfFlowPositionedNode(
NGBlockNode node, NGBlockNode node,
NGPhysicalStaticPosition static_position, NGPhysicalStaticPosition static_position,
const LayoutInline* inline_container = nullptr, const LayoutInline* inline_container = nullptr,
PhysicalOffset containing_block_offset = PhysicalOffset(),
scoped_refptr<const NGPhysicalContainerFragment> scoped_refptr<const NGPhysicalContainerFragment>
containing_block_fragment = nullptr) containing_block_fragment = nullptr)
: node(node), : node(node),
static_position(static_position), static_position(static_position),
inline_container(inline_container), inline_container(inline_container),
containing_block_offset(containing_block_offset),
containing_block_fragment(std::move(containing_block_fragment)) { containing_block_fragment(std::move(containing_block_fragment)) {
DCHECK(!inline_container || DCHECK(!inline_container ||
inline_container == inline_container->ContinuationRoot()); inline_container == inline_container->ContinuationRoot());
...@@ -66,6 +69,7 @@ struct NGLogicalOutOfFlowPositionedNode { ...@@ -66,6 +69,7 @@ struct NGLogicalOutOfFlowPositionedNode {
// Continuation root of the optional inline container. // Continuation root of the optional inline container.
const LayoutInline* inline_container; const LayoutInline* inline_container;
bool needs_block_offset_adjustment; bool needs_block_offset_adjustment;
LogicalOffset containing_block_offset;
scoped_refptr<const NGPhysicalContainerFragment> containing_block_fragment; scoped_refptr<const NGPhysicalContainerFragment> containing_block_fragment;
NGLogicalOutOfFlowPositionedNode( NGLogicalOutOfFlowPositionedNode(
...@@ -73,12 +77,14 @@ struct NGLogicalOutOfFlowPositionedNode { ...@@ -73,12 +77,14 @@ struct NGLogicalOutOfFlowPositionedNode {
NGLogicalStaticPosition static_position, NGLogicalStaticPosition static_position,
const LayoutInline* inline_container = nullptr, const LayoutInline* inline_container = nullptr,
bool needs_block_offset_adjustment = false, bool needs_block_offset_adjustment = false,
LogicalOffset containing_block_offset = LogicalOffset(),
scoped_refptr<const NGPhysicalContainerFragment> scoped_refptr<const NGPhysicalContainerFragment>
containing_block_fragment = nullptr) containing_block_fragment = nullptr)
: node(node), : node(node),
static_position(static_position), static_position(static_position),
inline_container(inline_container), inline_container(inline_container),
needs_block_offset_adjustment(needs_block_offset_adjustment), needs_block_offset_adjustment(needs_block_offset_adjustment),
containing_block_offset(containing_block_offset),
containing_block_fragment(std::move(containing_block_fragment)) { containing_block_fragment(std::move(containing_block_fragment)) {
DCHECK(!inline_container || DCHECK(!inline_container ||
inline_container == inline_container->ContinuationRoot()); inline_container == inline_container->ContinuationRoot());
......
...@@ -163,7 +163,13 @@ NGPhysicalBoxFragment::RareData::RareData(NGBoxFragmentBuilder* builder, ...@@ -163,7 +163,13 @@ NGPhysicalBoxFragment::RareData::RareData(NGBoxFragmentBuilder* builder,
descendant.node, descendant.node,
descendant.static_position.ConvertToPhysical( descendant.static_position.ConvertToPhysical(
builder->Style().GetWritingMode(), builder->Direction(), size), builder->Style().GetWritingMode(), builder->Direction(), size),
descendant.inline_container, descendant.containing_block_fragment); descendant.inline_container,
descendant.containing_block_offset.ConvertToPhysical(
builder->Style().GetWritingDirection(), size,
descendant.containing_block_fragment
? descendant.containing_block_fragment->Size()
: PhysicalSize()),
descendant.containing_block_fragment);
} }
} }
......
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