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

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

Issue 2525033002: Deprecate NGPhysicalConstraintSpace (Closed)
Patch Set: update TestExpectations Created 4 years 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"
8 #include "core/layout/ng/ng_units.h" 7 #include "core/layout/ng/ng_units.h"
9 #include "wtf/NonCopyingSort.h" 8 #include "wtf/NonCopyingSort.h"
10 9
11 namespace blink { 10 namespace blink {
12 namespace { 11 namespace {
13 12
14 // Collects all opportunities from leaves of Layout Opportunity spatial tree. 13 // Collects all opportunities from leaves of Layout Opportunity spatial tree.
15 void CollectAllOpportunities(const NGLayoutOpportunityTreeNode* node, 14 void CollectAllOpportunities(const NGLayoutOpportunityTreeNode* node,
16 NGLayoutOpportunities& opportunities) { 15 NGLayoutOpportunities& opportunities) {
17 if (!node) 16 if (!node)
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 } // namespace 247 } // namespace
249 248
250 NGLayoutOpportunityIterator::NGLayoutOpportunityIterator( 249 NGLayoutOpportunityIterator::NGLayoutOpportunityIterator(
251 NGConstraintSpace* space, 250 NGConstraintSpace* space,
252 const WTF::Optional<NGLogicalOffset>& opt_origin_point, 251 const WTF::Optional<NGLogicalOffset>& opt_origin_point,
253 const WTF::Optional<NGLogicalOffset>& opt_leader_point) 252 const WTF::Optional<NGLogicalOffset>& opt_leader_point)
254 : constraint_space_(space) { 253 : constraint_space_(space) {
255 RunPreconditionChecks(*space, opt_origin_point, opt_leader_point); 254 RunPreconditionChecks(*space, opt_origin_point, opt_leader_point);
256 255
257 // TODO(chrome-layout-team): Combine exclusions that shadow each other. 256 // TODO(chrome-layout-team): Combine exclusions that shadow each other.
258 auto& exclusions = constraint_space_->PhysicalSpace()->Exclusions(); 257 auto& exclusions = constraint_space_->Exclusions();
259 DCHECK(std::is_sorted(exclusions.begin(), exclusions.end(), 258 DCHECK(std::is_sorted(exclusions->storage.begin(), exclusions->storage.end(),
260 &CompareNGExclusionsByTopAsc)) 259 &CompareNGExclusionsByTopAsc))
261 << "Exclusions are expected to be sorted by TOP"; 260 << "Exclusions are expected to be sorted by TOP";
262 261
263 NGLogicalOffset origin_point = 262 NGLogicalOffset origin_point =
264 opt_origin_point ? opt_origin_point.value() : NGLogicalOffset(); 263 opt_origin_point ? opt_origin_point.value() : NGLogicalOffset();
265 NGLayoutOpportunity initial_opportunity = 264 NGLayoutOpportunity initial_opportunity =
266 CreateLayoutOpportunityFromConstraintSpace(*space, origin_point); 265 CreateLayoutOpportunityFromConstraintSpace(*space, origin_point);
267 opportunity_tree_root_ = new NGLayoutOpportunityTreeNode(initial_opportunity); 266 opportunity_tree_root_ = new NGLayoutOpportunityTreeNode(initial_opportunity);
268 267
269 if (opt_leader_point) { 268 if (opt_leader_point) {
270 const NGExclusion leader_exclusion = 269 const NGExclusion leader_exclusion =
271 ToLeaderExclusion(origin_point, opt_leader_point.value()); 270 ToLeaderExclusion(origin_point, opt_leader_point.value());
272 InsertExclusion(MutableOpportunityTreeRoot(), &leader_exclusion, 271 InsertExclusion(MutableOpportunityTreeRoot(), &leader_exclusion,
273 opportunities_); 272 opportunities_);
274 } 273 }
275 274
276 for (const auto& exclusion : exclusions) { 275 for (const auto& exclusion : exclusions->storage) {
277 InsertExclusion(MutableOpportunityTreeRoot(), exclusion.get(), 276 InsertExclusion(MutableOpportunityTreeRoot(), exclusion.get(),
278 opportunities_); 277 opportunities_);
279 } 278 }
280 CollectAllOpportunities(OpportunityTreeRoot(), opportunities_); 279 CollectAllOpportunities(OpportunityTreeRoot(), opportunities_);
281 std::sort(opportunities_.begin(), opportunities_.end(), 280 std::sort(opportunities_.begin(), opportunities_.end(),
282 &CompareNGLayoutOpportunitesByStartPoint); 281 &CompareNGLayoutOpportunitesByStartPoint);
283 282
284 opportunity_iter_ = opportunities_.begin(); 283 opportunity_iter_ = opportunities_.begin();
285 } 284 }
286 285
287 const NGLayoutOpportunity NGLayoutOpportunityIterator::Next() { 286 const NGLayoutOpportunity NGLayoutOpportunityIterator::Next() {
288 if (opportunity_iter_ == opportunities_.end()) 287 if (opportunity_iter_ == opportunities_.end())
289 return NGLayoutOpportunity(); 288 return NGLayoutOpportunity();
290 auto* opportunity = opportunity_iter_; 289 auto* opportunity = opportunity_iter_;
291 opportunity_iter_++; 290 opportunity_iter_++;
292 return NGLayoutOpportunity(*opportunity); 291 return NGLayoutOpportunity(*opportunity);
293 } 292 }
294 293
295 } // namespace blink 294 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698