| OLD | NEW |
| 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_units.h" | 7 #include "core/layout/ng/ng_units.h" |
| 8 #include "wtf/NonCopyingSort.h" | 8 #include "wtf/NonCopyingSort.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 : constraint_space_(space) { | 238 : constraint_space_(space) { |
| 239 // TODO(chrome-layout-team): Combine exclusions that shadow each other. | 239 // TODO(chrome-layout-team): Combine exclusions that shadow each other. |
| 240 auto& exclusions = constraint_space_->Exclusions(); | 240 auto& exclusions = constraint_space_->Exclusions(); |
| 241 DCHECK(std::is_sorted(exclusions->storage.begin(), exclusions->storage.end(), | 241 DCHECK(std::is_sorted(exclusions->storage.begin(), exclusions->storage.end(), |
| 242 &CompareNGExclusionsByTopAsc)) | 242 &CompareNGExclusionsByTopAsc)) |
| 243 << "Exclusions are expected to be sorted by TOP"; | 243 << "Exclusions are expected to be sorted by TOP"; |
| 244 | 244 |
| 245 NGLogicalOffset origin_point = | 245 NGLogicalOffset origin_point = |
| 246 opt_origin_point ? opt_origin_point.value() : NGLogicalOffset(); | 246 opt_origin_point ? opt_origin_point.value() : NGLogicalOffset(); |
| 247 NGLayoutOpportunity initial_opportunity = | 247 NGLayoutOpportunity initial_opportunity = |
| 248 CreateLayoutOpportunityFromConstraintSpace(*space, origin_point); | 248 CreateLayoutOpportunityFromConstraintSpace(*constraint_space_, |
| 249 origin_point); |
| 249 opportunity_tree_root_ = new NGLayoutOpportunityTreeNode(initial_opportunity); | 250 opportunity_tree_root_ = new NGLayoutOpportunityTreeNode(initial_opportunity); |
| 250 | 251 |
| 251 if (opt_leader_point) { | 252 if (opt_leader_point) { |
| 252 const NGExclusion leader_exclusion = | 253 const NGExclusion leader_exclusion = |
| 253 ToLeaderExclusion(origin_point, opt_leader_point.value()); | 254 ToLeaderExclusion(origin_point, opt_leader_point.value()); |
| 254 InsertExclusion(MutableOpportunityTreeRoot(), &leader_exclusion, | 255 InsertExclusion(MutableOpportunityTreeRoot(), &leader_exclusion, |
| 255 opportunities_); | 256 opportunities_); |
| 256 } | 257 } |
| 257 | 258 |
| 258 for (const auto& exclusion : exclusions->storage) { | 259 for (const auto& exclusion : exclusions->storage) { |
| 259 InsertExclusion(MutableOpportunityTreeRoot(), exclusion.get(), | 260 InsertExclusion(MutableOpportunityTreeRoot(), exclusion.get(), |
| 260 opportunities_); | 261 opportunities_); |
| 261 } | 262 } |
| 262 CollectAllOpportunities(OpportunityTreeRoot(), opportunities_); | 263 CollectAllOpportunities(OpportunityTreeRoot(), opportunities_); |
| 263 std::sort(opportunities_.begin(), opportunities_.end(), | 264 std::sort(opportunities_.begin(), opportunities_.end(), |
| 264 &CompareNGLayoutOpportunitesByStartPoint); | 265 &CompareNGLayoutOpportunitesByStartPoint); |
| 265 | 266 |
| 266 opportunity_iter_ = opportunities_.begin(); | 267 opportunity_iter_ = opportunities_.begin(); |
| 267 } | 268 } |
| 268 | 269 |
| 269 const NGLayoutOpportunity NGLayoutOpportunityIterator::Next() { | 270 const NGLayoutOpportunity NGLayoutOpportunityIterator::Next() { |
| 270 if (opportunity_iter_ == opportunities_.end()) | 271 if (opportunity_iter_ == opportunities_.end()) |
| 271 return NGLayoutOpportunity(); | 272 return NGLayoutOpportunity(); |
| 272 auto* opportunity = opportunity_iter_; | 273 auto* opportunity = opportunity_iter_; |
| 273 opportunity_iter_++; | 274 opportunity_iter_++; |
| 274 return NGLayoutOpportunity(*opportunity); | 275 return NGLayoutOpportunity(*opportunity); |
| 275 } | 276 } |
| 276 | 277 |
| 277 } // namespace blink | 278 } // namespace blink |
| OLD | NEW |