Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Unified Diff: third_party/WebKit/Source/core/layout/ng/ng_layout_opportunity_iterator.cc

Issue 2733133002: Combine 2 exclusions in Layout Opportunity Tree if they shadow each other (Closed)
Patch Set: delete unreachable return statement Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 fc9720fe63a90ea86631def28b28eb7430dc7c32..a5b6498e99f3253eccd53ee7332665f7561fbf9b 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
@@ -27,7 +27,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());
@@ -159,6 +159,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.
//
@@ -196,24 +203,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.

Powered by Google App Engine
This is Rietveld 408576698