| 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_block_layout_algorithm.h" | 5 #include "core/layout/ng/ng_block_layout_algorithm.h" |
| 6 | 6 |
| 7 #include "core/layout/ng/ng_absolute_utils.h" | 7 #include "core/layout/ng/ng_absolute_utils.h" |
| 8 #include "core/layout/ng/ng_block_break_token.h" | 8 #include "core/layout/ng/ng_block_break_token.h" |
| 9 #include "core/layout/ng/ng_box_fragment.h" | 9 #include "core/layout/ng/ng_box_fragment.h" |
| 10 #include "core/layout/ng/ng_column_mapper.h" | 10 #include "core/layout/ng/ng_column_mapper.h" |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 ComputeMinAndMaxContentContribution(*node->Style(), child_minmax); | 212 ComputeMinAndMaxContentContribution(*node->Style(), child_minmax); |
| 213 | 213 |
| 214 sizes->min_content = std::max(sizes->min_content, child_sizes.min_content); | 214 sizes->min_content = std::max(sizes->min_content, child_sizes.min_content); |
| 215 sizes->max_content = std::max(sizes->max_content, child_sizes.max_content); | 215 sizes->max_content = std::max(sizes->max_content, child_sizes.max_content); |
| 216 } | 216 } |
| 217 | 217 |
| 218 sizes->max_content = std::max(sizes->min_content, sizes->max_content); | 218 sizes->max_content = std::max(sizes->min_content, sizes->max_content); |
| 219 return true; | 219 return true; |
| 220 } | 220 } |
| 221 | 221 |
| 222 NGLayoutStatus NGBlockLayoutAlgorithm::Layout( | 222 NGPhysicalFragment* NGBlockLayoutAlgorithm::Layout() { |
| 223 NGPhysicalFragment* child_fragment, | |
| 224 NGPhysicalFragment** fragment_out, | |
| 225 NGLayoutAlgorithm** algorithm_out) { | |
| 226 WTF::Optional<MinAndMaxContentSizes> sizes; | 223 WTF::Optional<MinAndMaxContentSizes> sizes; |
| 227 if (NeedMinAndMaxContentSizes(ConstraintSpace(), Style())) { | 224 if (NeedMinAndMaxContentSizes(ConstraintSpace(), Style())) { |
| 228 // TODO(ikilpatrick): Change ComputeMinAndMaxContentSizes to return | 225 // TODO(ikilpatrick): Change ComputeMinAndMaxContentSizes to return |
| 229 // MinAndMaxContentSizes. | 226 // MinAndMaxContentSizes. |
| 230 sizes = MinAndMaxContentSizes(); | 227 sizes = MinAndMaxContentSizes(); |
| 231 ComputeMinAndMaxContentSizes(&*sizes); | 228 ComputeMinAndMaxContentSizes(&*sizes); |
| 232 } | 229 } |
| 233 | 230 |
| 234 border_and_padding_ = | 231 border_and_padding_ = |
| 235 ComputeBorders(Style()) + ComputePadding(ConstraintSpace(), Style()); | 232 ComputeBorders(Style()) + ComputePadding(ConstraintSpace(), Style()); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 builder_->AddOutOfFlowChildCandidate(current_child_, | 281 builder_->AddOutOfFlowChildCandidate(current_child_, |
| 285 GetChildSpaceOffset()); | 282 GetChildSpaceOffset()); |
| 286 current_child_ = current_child_->NextSibling(); | 283 current_child_ = current_child_->NextSibling(); |
| 287 continue; | 284 continue; |
| 288 } | 285 } |
| 289 | 286 |
| 290 DCHECK(!ConstraintSpace().HasBlockFragmentation() || | 287 DCHECK(!ConstraintSpace().HasBlockFragmentation() || |
| 291 SpaceAvailableForCurrentChild() > LayoutUnit()); | 288 SpaceAvailableForCurrentChild() > LayoutUnit()); |
| 292 space_for_current_child_ = CreateConstraintSpaceForCurrentChild(); | 289 space_for_current_child_ = CreateConstraintSpaceForCurrentChild(); |
| 293 | 290 |
| 294 NGFragment* fragment; | 291 NGPhysicalFragment* child_fragment = |
| 295 current_child_->LayoutSync(space_for_current_child_, &fragment); | 292 current_child_->Layout(space_for_current_child_); |
| 296 NGPhysicalFragment* child_fragment = fragment->PhysicalFragment(); | |
| 297 | |
| 298 // TODO(layout_ng): Seems like a giant hack to call this here. | |
| 299 current_child_->UpdateLayoutBox(toNGPhysicalBoxFragment(child_fragment), | |
| 300 space_for_current_child_); | |
| 301 | 293 |
| 302 FinishCurrentChildLayout(new NGBoxFragment( | 294 FinishCurrentChildLayout(new NGBoxFragment( |
| 303 ConstraintSpace().WritingMode(), ConstraintSpace().Direction(), | 295 ConstraintSpace().WritingMode(), ConstraintSpace().Direction(), |
| 304 toNGPhysicalBoxFragment(child_fragment))); | 296 toNGPhysicalBoxFragment(child_fragment))); |
| 305 | 297 |
| 306 if (!ProceedToNextUnfinishedSibling(child_fragment)) | 298 if (!ProceedToNextUnfinishedSibling(child_fragment)) |
| 307 break; | 299 break; |
| 308 } | 300 } |
| 309 | 301 |
| 310 content_size_ += border_and_padding_.block_end; | 302 content_size_ += border_and_padding_.block_end; |
| 311 | 303 |
| 312 // Recompute the block-axis size now that we know our content size. | 304 // Recompute the block-axis size now that we know our content size. |
| 313 block_size = | 305 block_size = |
| 314 ComputeBlockSizeForFragment(ConstraintSpace(), Style(), content_size_); | 306 ComputeBlockSizeForFragment(ConstraintSpace(), Style(), content_size_); |
| 315 builder_->SetBlockSize(block_size); | 307 builder_->SetBlockSize(block_size); |
| 316 | 308 |
| 317 HeapLinkedHashSet<WeakMember<NGBlockNode>> positioned_out_of_flow_children = | 309 HeapLinkedHashSet<WeakMember<NGBlockNode>> positioned_out_of_flow_children = |
| 318 LayoutOutOfFlowChildren(); | 310 LayoutOutOfFlowChildren(); |
| 319 | 311 |
| 320 builder_->SetInlineOverflow(max_inline_size_).SetBlockOverflow(content_size_); | 312 builder_->SetInlineOverflow(max_inline_size_).SetBlockOverflow(content_size_); |
| 321 | 313 |
| 322 if (ConstraintSpace().HasBlockFragmentation()) | 314 if (ConstraintSpace().HasBlockFragmentation()) |
| 323 FinalizeForFragmentation(); | 315 FinalizeForFragmentation(); |
| 324 | 316 |
| 325 *fragment_out = builder_->ToBoxFragment(); | 317 NGPhysicalFragment* fragment = builder_->ToBoxFragment(); |
| 326 | 318 |
| 327 for (auto& node : positioned_out_of_flow_children) | 319 for (auto& node : positioned_out_of_flow_children) |
| 328 node->PositionUpdated(); | 320 node->PositionUpdated(); |
| 329 | 321 |
| 330 return kNewFragment; | 322 return fragment; |
| 331 } | 323 } |
| 332 | 324 |
| 333 void NGBlockLayoutAlgorithm::FinishCurrentChildLayout(NGFragment* fragment) { | 325 void NGBlockLayoutAlgorithm::FinishCurrentChildLayout(NGFragment* fragment) { |
| 334 NGBoxStrut child_margins = ComputeMargins( | 326 NGBoxStrut child_margins = ComputeMargins( |
| 335 *space_for_current_child_, CurrentChildStyle(), | 327 *space_for_current_child_, CurrentChildStyle(), |
| 336 constraint_space_->WritingMode(), constraint_space_->Direction()); | 328 constraint_space_->WritingMode(), constraint_space_->Direction()); |
| 337 | 329 |
| 338 NGLogicalOffset fragment_offset; | 330 NGLogicalOffset fragment_offset; |
| 339 if (CurrentChildStyle().isFloating()) { | 331 if (CurrentChildStyle().isFloating()) { |
| 340 fragment_offset = PositionFloatFragment(*fragment, child_margins); | 332 fragment_offset = PositionFloatFragment(*fragment, child_margins); |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 visitor->trace(constraint_space_); | 670 visitor->trace(constraint_space_); |
| 679 visitor->trace(break_token_); | 671 visitor->trace(break_token_); |
| 680 visitor->trace(builder_); | 672 visitor->trace(builder_); |
| 681 visitor->trace(space_builder_); | 673 visitor->trace(space_builder_); |
| 682 visitor->trace(space_for_current_child_); | 674 visitor->trace(space_for_current_child_); |
| 683 visitor->trace(current_child_); | 675 visitor->trace(current_child_); |
| 684 visitor->trace(fragmentainer_mapper_); | 676 visitor->trace(fragmentainer_mapper_); |
| 685 } | 677 } |
| 686 | 678 |
| 687 } // namespace blink | 679 } // namespace blink |
| OLD | NEW |