| Index: third_party/WebKit/Source/core/layout/ng/ng_layout_opportunity_iterator.cc
|
| diff --git a/third_party/WebKit/Source/core/layout/ng/ng_layout_opportunity_iterator.cc b/third_party/WebKit/Source/core/layout/ng/ng_layout_opportunity_iterator.cc
|
| index 5eb1a7c78a601292445a6b44c4be74221492257c..cdbc00325fa0b76f7ada8346b374d4ccd9da3f24 100644
|
| --- a/third_party/WebKit/Source/core/layout/ng/ng_layout_opportunity_iterator.cc
|
| +++ b/third_party/WebKit/Source/core/layout/ng/ng_layout_opportunity_iterator.cc
|
| @@ -150,6 +150,10 @@ NGLayoutOpportunity GetTopSpace(const NGLayoutOpportunity& parent_opportunity,
|
| void InsertExclusion(NGLayoutOpportunityTreeNode* node,
|
| const NGLogicalRect* exclusion,
|
| NGLayoutOpportunities& opportunities) {
|
| + // Base case: size of the exclusion is empty.
|
| + if (exclusion->size.IsEmpty())
|
| + return;
|
| +
|
| // Base case: there is no node.
|
| if (!node)
|
| return;
|
| @@ -210,13 +214,39 @@ bool CompareNGLayoutOpportunitesByStartPoint(const NGLayoutOpportunity& lhs,
|
| return rhs.size.inline_size < lhs.size.inline_size;
|
| }
|
|
|
| +void RunPreconditionChecks(const NGConstraintSpace& space,
|
| + const NGLogicalOffset& origin_point,
|
| + const NGLogicalOffset& leader_point) {
|
| + DCHECK_GE(origin_point, space.Offset())
|
| + << "Origin point" << origin_point
|
| + << " should lay below the constraint space's offset " << space.Offset();
|
| +
|
| + DCHECK_GE(leader_point, space.Offset())
|
| + << "Leader point" << leader_point
|
| + << " should lay below the constraint space's offset " << space.Offset();
|
| +}
|
| +
|
| +NGLogicalRect ToLeaderExclusion(const NGLogicalOffset& origin_point,
|
| + const NGLogicalOffset& leader_point) {
|
| + NGLogicalRect leader_exclusion;
|
| + leader_exclusion.offset.inline_offset = origin_point.inline_offset;
|
| + leader_exclusion.offset.block_offset = origin_point.block_offset;
|
| + leader_exclusion.size.inline_size =
|
| + leader_point.inline_offset - origin_point.inline_offset;
|
| + leader_exclusion.size.block_size =
|
| + leader_point.block_offset - origin_point.block_offset;
|
| + return leader_exclusion;
|
| +}
|
| +
|
| } // namespace
|
|
|
| NGLayoutOpportunityIterator::NGLayoutOpportunityIterator(
|
| NGConstraintSpace* space,
|
| - const NGLogicalOffset origin_point,
|
| - const NGLogicalOffset leader_point)
|
| - : constraint_space_(space), leader_point_(leader_point) {
|
| + const NGLogicalOffset& origin_point,
|
| + const NGLogicalOffset& leader_point)
|
| + : constraint_space_(space) {
|
| + RunPreconditionChecks(*space, origin_point, leader_point);
|
| +
|
| // TODO(chrome-layout-team): Combine exclusions that shadow each other.
|
| auto& exclusions = constraint_space_->PhysicalSpace()->Exclusions();
|
| DCHECK(std::is_sorted(exclusions.begin(), exclusions.end(),
|
| @@ -227,6 +257,11 @@ NGLayoutOpportunityIterator::NGLayoutOpportunityIterator(
|
| CreateLayoutOpportunityFromConstraintSpace(*space, origin_point);
|
| opportunity_tree_root_ = new NGLayoutOpportunityTreeNode(initial_opportunity);
|
|
|
| + const NGLogicalRect leader_exclusion =
|
| + ToLeaderExclusion(origin_point, leader_point);
|
| + InsertExclusion(MutableOpportunityTreeRoot(), &leader_exclusion,
|
| + opportunities_);
|
| +
|
| for (const auto& exclusion : exclusions) {
|
| InsertExclusion(MutableOpportunityTreeRoot(), exclusion.get(),
|
| opportunities_);
|
|
|