Commit 58ea6d68 authored by Ian Kilpatrick's avatar Ian Kilpatrick Committed by Commit Bot

[FlexNG] Add AddOutOfFlowChildCandidate which accepts "edge" parameters.

This (somewhat) refactors the AddOutOfFlowChildCandidate into two variants:
 1) For the inline-level OOF case.
 2) For the block-level OOF, added additional "edge" paramaeters.

There should be no behaviour change.

Bug: 845235
Change-Id: If3957078afca7cc0f9175198837a06f0f2badadb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1931676
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarAleks Totic <atotic@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721686}
parent 0fd4b411
...@@ -629,8 +629,8 @@ NGInlineLayoutStateStack::BoxData::CreateBoxFragment( ...@@ -629,8 +629,8 @@ NGInlineLayoutStateStack::BoxData::CreateBoxFragment(
// position to be relative to this fragment. // position to be relative to this fragment.
LogicalOffset static_offset = child.offset - offset; LogicalOffset static_offset = child.offset - offset;
box.AddOutOfFlowChildCandidate(oof_box, static_offset, box.AddOutOfFlowInlineChildCandidate(oof_box, static_offset,
child.container_direction); child.container_direction);
child.out_of_flow_positioned_box = nullptr; child.out_of_flow_positioned_box = nullptr;
continue; continue;
} }
......
...@@ -100,7 +100,7 @@ void NGLineBoxFragmentBuilder::AddChildren(ChildList& children) { ...@@ -100,7 +100,7 @@ void NGLineBoxFragmentBuilder::AddChildren(ChildList& children) {
AddChild(std::move(child.fragment), child.offset); AddChild(std::move(child.fragment), child.offset);
DCHECK(!child.fragment); DCHECK(!child.fragment);
} else if (child.out_of_flow_positioned_box) { } else if (child.out_of_flow_positioned_box) {
AddOutOfFlowChildCandidate( AddOutOfFlowInlineChildCandidate(
NGBlockNode(ToLayoutBox(child.out_of_flow_positioned_box)), NGBlockNode(ToLayoutBox(child.out_of_flow_positioned_box)),
child.offset, child.container_direction); child.offset, child.container_direction);
child.out_of_flow_positioned_box = nullptr; child.out_of_flow_positioned_box = nullptr;
...@@ -127,7 +127,7 @@ void NGLineBoxFragmentBuilder::PropagateChildrenData(ChildList& children) { ...@@ -127,7 +127,7 @@ void NGLineBoxFragmentBuilder::PropagateChildrenData(ChildList& children) {
continue; continue;
} }
if (child.out_of_flow_positioned_box) { if (child.out_of_flow_positioned_box) {
AddOutOfFlowChildCandidate( AddOutOfFlowInlineChildCandidate(
NGBlockNode(ToLayoutBox(child.out_of_flow_positioned_box)), NGBlockNode(ToLayoutBox(child.out_of_flow_positioned_box)),
child.offset, child.container_direction); child.offset, child.container_direction);
child.out_of_flow_positioned_box = nullptr; child.out_of_flow_positioned_box = nullptr;
......
...@@ -193,24 +193,28 @@ LogicalOffset NGContainerFragmentBuilder::GetChildOffset( ...@@ -193,24 +193,28 @@ LogicalOffset NGContainerFragmentBuilder::GetChildOffset(
void NGContainerFragmentBuilder::AddOutOfFlowChildCandidate( void NGContainerFragmentBuilder::AddOutOfFlowChildCandidate(
NGBlockNode child, NGBlockNode child,
const LogicalOffset& child_offset, const LogicalOffset& child_offset,
base::Optional<TextDirection> container_direction) { NGLogicalStaticPosition::InlineEdge inline_edge,
NGLogicalStaticPosition::BlockEdge block_edge) {
DCHECK(child); DCHECK(child);
DCHECK(layout_object_ && !layout_object_->IsLayoutInline() ||
container_direction) oof_positioned_candidates_.emplace_back(
<< "container_direction must only be set for inline-level OOF children."; child, NGLogicalStaticPosition{child_offset, inline_edge, block_edge});
}
void NGContainerFragmentBuilder::AddOutOfFlowInlineChildCandidate(
NGBlockNode child,
const LogicalOffset& child_offset,
TextDirection inline_container_direction) {
DCHECK(node_.IsInline() || layout_object_->IsLayoutInline());
// As all inline-level fragments are built in the line-logical coordinate // As all inline-level fragments are built in the line-logical coordinate
// system (Direction() is kLtr), we need to know the direction of the // system (Direction() is kLtr), we need to know the direction of the
// parent element to correctly determine an OOF childs static position. // parent element to correctly determine an OOF childs static position.
TextDirection direction = container_direction.value_or(TextDirection::kLtr); AddOutOfFlowChildCandidate(child, child_offset,
IsLtr(inline_container_direction)
oof_positioned_candidates_.emplace_back( ? NGLogicalStaticPosition::kInlineStart
child, : NGLogicalStaticPosition::kInlineEnd,
NGLogicalStaticPosition{ NGLogicalStaticPosition::kBlockStart);
child_offset,
IsLtr(direction) ? NGLogicalStaticPosition::InlineEdge::kInlineStart
: NGLogicalStaticPosition::InlineEdge::kInlineEnd,
NGLogicalStaticPosition::BlockEdge::kBlockStart});
} }
void NGContainerFragmentBuilder::AddOutOfFlowDescendant( void NGContainerFragmentBuilder::AddOutOfFlowDescendant(
......
...@@ -114,13 +114,20 @@ class CORE_EXPORT NGContainerFragmentBuilder : public NGFragmentBuilder { ...@@ -114,13 +114,20 @@ class CORE_EXPORT NGContainerFragmentBuilder : public NGFragmentBuilder {
// NGOutOfFlowLayoutPart(container_style, builder).Run(); // NGOutOfFlowLayoutPart(container_style, builder).Run();
// //
// See layout part for builder interaction. // See layout part for builder interaction.
// void AddOutOfFlowChildCandidate(NGBlockNode,
// @param direction: default candidate direction is builder's direction. const LogicalOffset& child_offset,
// Pass in direction if candidates direction does not match. NGLogicalStaticPosition::InlineEdge =
void AddOutOfFlowChildCandidate( NGLogicalStaticPosition::kInlineStart,
NGLogicalStaticPosition::BlockEdge =
NGLogicalStaticPosition::kBlockStart);
// This should only be used for inline-level OOF-positioned nodes.
// |inline_container_direction| is the current text direction for determining
// the correct static-position.
void AddOutOfFlowInlineChildCandidate(
NGBlockNode, NGBlockNode,
const LogicalOffset& child_offset, const LogicalOffset& child_offset,
base::Optional<TextDirection> container_direction = base::nullopt); TextDirection inline_container_direction);
void AddOutOfFlowDescendant( void AddOutOfFlowDescendant(
const NGLogicalOutOfFlowPositionedNode& descendant); const NGLogicalOutOfFlowPositionedNode& descendant);
......
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