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

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

Issue 2451553005: Add NGLogicalOrigin and NGLogicalLeader parameters to NGLayoutOpportunityIterator. (Closed)
Patch Set: do not redefine default LayoutOpportunities parameters Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/layout/ng/ng_layout_opportunity_iterator.h" 5 #include "core/layout/ng/ng_layout_opportunity_iterator.h"
6 6
7 #include "core/layout/ng/ng_physical_constraint_space.h" 7 #include "core/layout/ng/ng_physical_constraint_space.h"
8 #include "core/layout/ng/ng_units.h" 8 #include "core/layout/ng/ng_units.h"
9 #include "wtf/NonCopyingSort.h" 9 #include "wtf/NonCopyingSort.h"
10 10
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 } 198 }
199 199
200 // TOP and LEFT are the same -> Sort by width 200 // TOP and LEFT are the same -> Sort by width
201 return rhs.size.inline_size < lhs.size.inline_size; 201 return rhs.size.inline_size < lhs.size.inline_size;
202 } 202 }
203 203
204 } // namespace 204 } // namespace
205 205
206 NGLayoutOpportunityIterator::NGLayoutOpportunityIterator( 206 NGLayoutOpportunityIterator::NGLayoutOpportunityIterator(
207 NGConstraintSpace* space, 207 NGConstraintSpace* space,
208 unsigned clear, 208 const NGLogicalOrigin origin_point,
209 bool for_inline_or_bfc) 209 const NGLogicalLeader leader_point)
210 : constraint_space_(space) { 210 : constraint_space_(space),
211 origin_point_(origin_point),
212 leader_point_(leader_point) {
211 // TODO(chrome-layout-team): Combine exclusions that shadow each other. 213 // TODO(chrome-layout-team): Combine exclusions that shadow each other.
212 auto exclusions = constraint_space_->PhysicalSpace()->Exclusions(); 214 auto exclusions = constraint_space_->PhysicalSpace()->Exclusions();
213 DCHECK(std::is_sorted(exclusions.begin(), exclusions.end(), 215 DCHECK(std::is_sorted(exclusions.begin(), exclusions.end(),
214 &CompareNGExclusionsByTopAsc)) 216 &CompareNGExclusionsByTopAsc))
215 << "Exclusions are expected to be sorted by TOP"; 217 << "Exclusions are expected to be sorted by TOP";
216 218
217 opportunity_tree_root_ = new NGLayoutOpportunityTreeNode(NGLayoutOpportunity( 219 opportunity_tree_root_ = new NGLayoutOpportunityTreeNode(NGLayoutOpportunity(
218 space->Offset().inline_offset, space->Offset().block_offset, 220 space->Offset().inline_offset, space->Offset().block_offset,
219 space->Size().inline_size, space->Size().block_size)); 221 space->Size().inline_size, space->Size().block_size));
220 222
221 for (const auto exclusion : exclusions) { 223 for (const auto exclusion : exclusions) {
222 InsertExclusion(MutableOpportunityTreeRoot(), exclusion, opportunities_); 224 InsertExclusion(MutableOpportunityTreeRoot(), exclusion, opportunities_);
223 } 225 }
224 CollectAllOpportunities(OpportunityTreeRoot(), opportunities_); 226 CollectAllOpportunities(OpportunityTreeRoot(), opportunities_);
225 std::sort(opportunities_.begin(), opportunities_.end(), 227 std::sort(opportunities_.begin(), opportunities_.end(),
226 &CompareNGLayoutOpportunitesByStartPoint); 228 &CompareNGLayoutOpportunitesByStartPoint);
227 opportunity_iter_ = opportunities_.begin(); 229 opportunity_iter_ = opportunities_.begin();
228 } 230 }
229 231
230 const NGLayoutOpportunity NGLayoutOpportunityIterator::Next() { 232 const NGLayoutOpportunity NGLayoutOpportunityIterator::Next() {
231 if (opportunity_iter_ == opportunities_.end()) 233 if (opportunity_iter_ == opportunities_.end())
232 return NGLayoutOpportunity(); 234 return NGLayoutOpportunity();
233 auto* opportunity = opportunity_iter_; 235 auto* opportunity = opportunity_iter_;
234 opportunity_iter_++; 236 opportunity_iter_++;
235 return NGLayoutOpportunity(*opportunity); 237 return NGLayoutOpportunity(*opportunity);
236 } 238 }
237 239
238 } // namespace blink 240 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698