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

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

Issue 2812983002: Change NGLayoutOpportunityIterator API to work with list of exclusions (Closed)
Patch Set: git rebase-update Created 3 years, 8 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_layout_opportunity_iterator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 bb84c83ebd471fb27ba20cfa6a8e4aef7a12f183..de080810494de8392a4903e15392854912c574c2 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
@@ -53,8 +53,8 @@ void CollectAllOpportunities(const NGLayoutOpportunityTreeNode* node,
CollectAllOpportunities(node->right.get(), opportunities);
}
-// Creates layout opportunity from the provided space and the origin point.
-NGLayoutOpportunity CreateLayoutOpportunityFromConstraintSpace(
+// Creates layout opportunity from the provided size and the origin point.
+NGLayoutOpportunity CreateInitialOpportunity(
const NGLogicalSize& size,
const NGLogicalOffset& origin_point) {
NGLayoutOpportunity opportunity;
@@ -257,46 +257,23 @@ bool CompareNGLayoutOpportunitesByStartPoint(const NGLayoutOpportunity& lhs,
// TOP and LEFT are the same -> Sort by width
return rhs.size.inline_size < lhs.size.inline_size;
}
-
-NGExclusion ToLeaderExclusion(const NGLogicalOffset& origin_point,
- const NGLogicalOffset& leader_point) {
- LayoutUnit inline_size =
- leader_point.inline_offset - origin_point.inline_offset;
- LayoutUnit block_size = leader_point.block_offset - origin_point.block_offset;
-
- NGExclusion leader_exclusion;
- leader_exclusion.rect.offset = origin_point;
- leader_exclusion.rect.size = {inline_size, block_size};
- return leader_exclusion;
-}
-
} // namespace
NGLayoutOpportunityIterator::NGLayoutOpportunityIterator(
- const NGConstraintSpace* space,
+ const NGExclusions* exclusions,
const NGLogicalSize& available_size,
- const WTF::Optional<NGLogicalOffset>& opt_offset,
- const WTF::Optional<NGLogicalOffset>& opt_leader_point)
- : constraint_space_(space),
- offset_(opt_offset ? opt_offset.value() : space->BfcOffset()) {
- // TODO(chrome-layout-team): Combine exclusions that shadow each other.
- auto& exclusions = constraint_space_->Exclusions();
+ const NGLogicalOffset& offset)
+ : offset_(offset) {
+ DCHECK(exclusions);
DCHECK(std::is_sorted(exclusions->storage.begin(), exclusions->storage.end(),
&CompareNGExclusionsByTopAsc))
<< "Exclusions are expected to be sorted by TOP";
NGLayoutOpportunity initial_opportunity =
- CreateLayoutOpportunityFromConstraintSpace(available_size, Offset());
+ CreateInitialOpportunity(available_size, Offset());
opportunity_tree_root_.reset(
new NGLayoutOpportunityTreeNode(initial_opportunity));
- if (opt_leader_point) {
- const NGExclusion leader_exclusion =
- ToLeaderExclusion(Offset(), opt_leader_point.value());
- InsertExclusion(MutableOpportunityTreeRoot(), &leader_exclusion,
- opportunities_);
- }
-
for (const auto& exclusion : exclusions->storage) {
InsertExclusion(MutableOpportunityTreeRoot(), exclusion.get(),
opportunities_);
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_layout_opportunity_iterator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698