Commit 8e664ba8 authored by Aleks Totic's avatar Aleks Totic Committed by Commit Bot

[LayoutNG] Introduce LayoutDescendantCandidates

Only behavioral change is keeping track of placed
elements. This will be important in future CL.

This CL is part 3/X of placing Legacy contained OOF Elements by NG.

Bug: 907911
Change-Id: I5fb2c1e777bee3310239d7673211c6c6e08b3200
Reviewed-on: https://chromium-review.googlesource.com/c/1474538Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Commit-Queue: Aleks Totic <atotic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#632824}
parent 351ad83b
......@@ -136,21 +136,11 @@ void NGOutOfFlowLayoutPart::Run(LayoutBox* only_layout) {
return;
}
HashSet<const LayoutObject*> placed_objects;
while (descendant_candidates.size() > 0) {
ComputeInlineContainingBlocks(descendant_candidates);
for (auto& candidate : descendant_candidates) {
if (IsContainingBlockForDescendant(candidate) &&
(!only_layout || candidate.node.GetLayoutBox() == only_layout)) {
NGLogicalOffset offset;
scoped_refptr<NGLayoutResult> result =
LayoutDescendant(candidate, &offset, only_layout);
container_builder_->AddChild(*result, offset);
if (candidate.node.GetLayoutBox() != only_layout)
candidate.node.UseOldOutOfFlowPositioning();
} else {
container_builder_->AddOutOfFlowDescendant(candidate);
}
}
LayoutDescendantCandidates(descendant_candidates, only_layout,
&placed_objects);
// Sweep any descendants that might have been added.
// This happens when an absolute container has a fixed child.
descendant_candidates.Shrink(0);
......@@ -326,10 +316,30 @@ void NGOutOfFlowLayoutPart::ComputeInlineContainingBlocks(
}
}
void NGOutOfFlowLayoutPart::LayoutDescendantCandidates(
const Vector<NGOutOfFlowPositionedDescendant> descendant_candidates,
const LayoutBox* only_layout,
HashSet<const LayoutObject*>* placed_objects) {
for (auto& candidate : descendant_candidates) {
if (IsContainingBlockForDescendant(candidate) &&
(!only_layout || candidate.node.GetLayoutBox() == only_layout)) {
NGLogicalOffset offset;
scoped_refptr<NGLayoutResult> result =
LayoutDescendant(candidate, only_layout, &offset);
container_builder_->AddChild(*result, offset);
placed_objects->insert(candidate.node.GetLayoutBox());
if (candidate.node.GetLayoutBox() != only_layout)
candidate.node.UseOldOutOfFlowPositioning();
} else {
container_builder_->AddOutOfFlowDescendant(candidate);
}
}
}
scoped_refptr<NGLayoutResult> NGOutOfFlowLayoutPart::LayoutDescendant(
const NGOutOfFlowPositionedDescendant& descendant,
NGLogicalOffset* offset,
LayoutBox* only_layout) {
const LayoutBox* only_layout,
NGLogicalOffset* offset) {
ContainingBlockInfo container_info = GetContainingBlockInfo(descendant);
const ComputedStyle& descendant_style = descendant.node.Style();
......
......@@ -12,6 +12,7 @@
#include "third_party/blink/renderer/core/layout/ng/ng_absolute_utils.h"
#include "third_party/blink/renderer/core/style/computed_style_base_constants.h"
#include "third_party/blink/renderer/platform/wtf/hash_map.h"
#include "third_party/blink/renderer/platform/wtf/hash_set.h"
namespace blink {
......@@ -94,10 +95,15 @@ class CORE_EXPORT NGOutOfFlowLayoutPart {
void ComputeInlineContainingBlocks(Vector<NGOutOfFlowPositionedDescendant>);
void LayoutDescendantCandidates(
const Vector<NGOutOfFlowPositionedDescendant> descendant_candidates,
const LayoutBox* only_layout,
HashSet<const LayoutObject*>* placed_objects);
scoped_refptr<NGLayoutResult> LayoutDescendant(
const NGOutOfFlowPositionedDescendant&,
NGLogicalOffset* offset,
LayoutBox* only_layout);
const LayoutBox* only_layout,
NGLogicalOffset* offset);
bool IsContainingBlockForDescendant(
const NGOutOfFlowPositionedDescendant& 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