| 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 f95d51d176ef7445381c363cce38b3fa787a9741..d2956dfc8a04bb1015035ab014ddcd9bc0dc9312 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
|
| @@ -28,7 +28,7 @@ void AppendNodeToString(const NGLayoutOpportunityTreeNode* node,
|
| for (unsigned i = 0; i < indent; i++)
|
| indent_builder.append("\t");
|
|
|
| - if (!node->exclusion)
|
| + if (node->IsLeafNode())
|
| return;
|
|
|
| string_builder->append(indent_builder.toString());
|
| @@ -160,6 +160,13 @@ NGLayoutOpportunityTreeNode* CreateRightNGLayoutOpportunityTreeNode(
|
| return nullptr;
|
| }
|
|
|
| +void SplitNGLayoutOpportunityTreeNode(const NGLogicalRect& rect,
|
| + NGLayoutOpportunityTreeNode* node) {
|
| + node->left = CreateLeftNGLayoutOpportunityTreeNode(node, rect);
|
| + node->right = CreateRightNGLayoutOpportunityTreeNode(node, rect);
|
| + node->bottom = CreateBottomNGLayoutOpportunityTreeNode(node, rect);
|
| +}
|
| +
|
| // Gets/Creates the "TOP" positioned constraint space by splitting
|
| // the parent node with the exclusion.
|
| //
|
| @@ -197,24 +204,29 @@ void InsertExclusion(NGLayoutOpportunityTreeNode* node,
|
| if (!exclusion->rect.IsContained(node->opportunity))
|
| return;
|
|
|
| - if (node->exclusion) {
|
| - InsertExclusion(node->left, exclusion, opportunities);
|
| - InsertExclusion(node->bottom, exclusion, opportunities);
|
| - InsertExclusion(node->right, exclusion, opportunities);
|
| + if (node->exclusions.isEmpty()) {
|
| + SplitNGLayoutOpportunityTreeNode(exclusion->rect, node);
|
| +
|
| + NGLayoutOpportunity top_layout_opp =
|
| + GetTopSpace(node->opportunity, exclusion->rect);
|
| + if (!top_layout_opp.IsEmpty())
|
| + opportunities.push_back(top_layout_opp);
|
| +
|
| + node->exclusions.push_back(exclusion);
|
| + node->combined_exclusion = WTF::makeUnique<NGExclusion>(*exclusion);
|
| return;
|
| }
|
|
|
| - // Split the current node.
|
| - node->left = CreateLeftNGLayoutOpportunityTreeNode(node, exclusion->rect);
|
| - node->right = CreateRightNGLayoutOpportunityTreeNode(node, exclusion->rect);
|
| - node->bottom = CreateBottomNGLayoutOpportunityTreeNode(node, exclusion->rect);
|
| -
|
| - NGLayoutOpportunity top_layout_opp =
|
| - GetTopSpace(node->opportunity, exclusion->rect);
|
| - if (!top_layout_opp.IsEmpty())
|
| - opportunities.push_back(top_layout_opp);
|
| + DCHECK(!node->exclusions.isEmpty());
|
|
|
| - node->exclusion = exclusion;
|
| + if (node->combined_exclusion->MaybeCombineWith(*exclusion)) {
|
| + SplitNGLayoutOpportunityTreeNode(node->combined_exclusion->rect, node);
|
| + node->exclusions.push_back(exclusion);
|
| + } else {
|
| + InsertExclusion(node->left, exclusion, opportunities);
|
| + InsertExclusion(node->bottom, exclusion, opportunities);
|
| + InsertExclusion(node->right, exclusion, opportunities);
|
| + }
|
| }
|
|
|
| // Compares exclusions by their top position.
|
|
|