Commit 7cf15f28 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[LayoutNG] Make NGBlockNode::CopyFragmentDataToLayoutBoxForInlineChildren private

This patch changes
  NGBlockNode::CopyFragmentDataToLayoutBoxForInlineChildren
to a private member function from an anonymous function, so
that the planned changes to the function is easier to review.

No changes other than moving within the same .cc file.

TBR=eae@chromium.org

Bug: 636993
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: I8af2cd1872e9f6c66156368c508ea4f209fc3255
Reviewed-on: https://chromium-review.googlesource.com/1179491
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583997}
parent 223e6a75
......@@ -127,45 +127,6 @@ void UpdateLegacyMultiColumnFlowThread(
flow_thread->ClearNeedsLayout();
}
// For inline children, NG painters handles fragments directly, but there are
// some cases where we need to copy data to the LayoutObject tree. This function
// handles such cases.
void CopyFragmentDataToLayoutBoxForInlineChildren(
const NGPhysicalContainerFragment& container,
LayoutUnit initial_container_width,
bool initial_container_is_flipped,
NGPhysicalOffset offset = {}) {
for (const auto& child : container.Children()) {
if (child->IsContainer()) {
NGPhysicalOffset child_offset = offset + child->Offset();
// Replaced elements and inline blocks need Location() set relative to
// their block container.
LayoutObject* layout_object = child->GetLayoutObject();
if (layout_object && layout_object->IsBox()) {
LayoutBox& layout_box = ToLayoutBox(*layout_object);
NGPhysicalOffset maybe_flipped_offset = child_offset;
if (initial_container_is_flipped) {
maybe_flipped_offset.left = initial_container_width -
child->Size().width -
maybe_flipped_offset.left;
}
layout_box.SetLocation(maybe_flipped_offset.ToLayoutPoint());
}
// The Location() of inline LayoutObject is relative to the
// LayoutBlockFlow. If |child| establishes a new block formatting context,
// it also creates another inline formatting context. Do not copy to its
// descendants in this case.
if (!child->IsBlockFormattingContextRoot()) {
CopyFragmentDataToLayoutBoxForInlineChildren(
ToNGPhysicalContainerFragment(*child), initial_container_width,
initial_container_is_flipped, child_offset);
}
}
}
}
NGConstraintSpaceBuilder CreateConstraintSpaceBuilderForMinMax(
NGBlockNode node) {
return NGConstraintSpaceBuilder(node.Style().GetWritingMode(),
......@@ -628,6 +589,45 @@ void NGBlockNode::CopyChildFragmentPosition(
}
}
// For inline children, NG painters handles fragments directly, but there are
// some cases where we need to copy data to the LayoutObject tree. This function
// handles such cases.
void NGBlockNode::CopyFragmentDataToLayoutBoxForInlineChildren(
const NGPhysicalContainerFragment& container,
LayoutUnit initial_container_width,
bool initial_container_is_flipped,
NGPhysicalOffset offset) {
for (const auto& child : container.Children()) {
if (child->IsContainer()) {
NGPhysicalOffset child_offset = offset + child->Offset();
// Replaced elements and inline blocks need Location() set relative to
// their block container.
LayoutObject* layout_object = child->GetLayoutObject();
if (layout_object && layout_object->IsBox()) {
LayoutBox& layout_box = ToLayoutBox(*layout_object);
NGPhysicalOffset maybe_flipped_offset = child_offset;
if (initial_container_is_flipped) {
maybe_flipped_offset.left = initial_container_width -
child->Size().width -
maybe_flipped_offset.left;
}
layout_box.SetLocation(maybe_flipped_offset.ToLayoutPoint());
}
// The Location() of inline LayoutObject is relative to the
// LayoutBlockFlow. If |child| establishes a new block formatting context,
// it also creates another inline formatting context. Do not copy to its
// descendants in this case.
if (!child->IsBlockFormattingContextRoot()) {
CopyFragmentDataToLayoutBoxForInlineChildren(
ToNGPhysicalContainerFragment(*child), initial_container_width,
initial_container_is_flipped, child_offset);
}
}
}
}
bool NGBlockNode::IsInlineLevel() const {
return GetLayoutBox()->IsInline();
}
......
......@@ -18,6 +18,7 @@ class NGConstraintSpace;
class NGFragmentBuilder;
class NGLayoutResult;
class NGPhysicalBoxFragment;
class NGPhysicalContainerFragment;
class NGPhysicalFragment;
struct MinMaxSize;
struct NGBaselineRequest;
......@@ -100,6 +101,11 @@ class CORE_EXPORT NGBlockNode final : public NGLayoutInputNode {
// data to the layout box.
void CopyFragmentDataToLayoutBox(const NGConstraintSpace&,
const NGLayoutResult&);
void CopyFragmentDataToLayoutBoxForInlineChildren(
const NGPhysicalContainerFragment& container,
LayoutUnit initial_container_width,
bool initial_container_is_flipped,
NGPhysicalOffset offset = {});
void PlaceChildrenInLayoutBox(const NGConstraintSpace&,
const NGPhysicalBoxFragment&,
const NGPhysicalOffset& offset_from_start);
......
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