| 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_column_mapper.h" | 9 #include "core/layout/ng/ng_column_mapper.h" |
| 10 #include "core/layout/ng/ng_constraint_space.h" | 10 #include "core/layout/ng/ng_constraint_space.h" |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 sizes->min_content = LayoutUnit(); | 275 sizes->min_content = LayoutUnit(); |
| 276 sizes->max_content = LayoutUnit(); | 276 sizes->max_content = LayoutUnit(); |
| 277 | 277 |
| 278 // Size-contained elements don't consider their contents for intrinsic sizing. | 278 // Size-contained elements don't consider their contents for intrinsic sizing. |
| 279 if (Style().containsSize()) | 279 if (Style().containsSize()) |
| 280 return true; | 280 return true; |
| 281 | 281 |
| 282 // TODO: handle floats & orthogonal children. | 282 // TODO: handle floats & orthogonal children. |
| 283 for (NGBlockNode* node = first_child_; node; node = node->NextSibling()) { | 283 for (NGBlockNode* node = first_child_; node; node = node->NextSibling()) { |
| 284 Optional<MinAndMaxContentSizes> child_minmax; | 284 Optional<MinAndMaxContentSizes> child_minmax; |
| 285 if (NeedMinAndMaxContentSizesForContentContribution(*node->Style())) { | 285 if (NeedMinAndMaxContentSizesForContentContribution(node->Style())) { |
| 286 child_minmax = node->ComputeMinAndMaxContentSizes(); | 286 child_minmax = node->ComputeMinAndMaxContentSizes(); |
| 287 } | 287 } |
| 288 | 288 |
| 289 MinAndMaxContentSizes child_sizes = | 289 MinAndMaxContentSizes child_sizes = |
| 290 ComputeMinAndMaxContentContribution(*node->Style(), child_minmax); | 290 ComputeMinAndMaxContentContribution(node->Style(), child_minmax); |
| 291 | 291 |
| 292 sizes->min_content = std::max(sizes->min_content, child_sizes.min_content); | 292 sizes->min_content = std::max(sizes->min_content, child_sizes.min_content); |
| 293 sizes->max_content = std::max(sizes->max_content, child_sizes.max_content); | 293 sizes->max_content = std::max(sizes->max_content, child_sizes.max_content); |
| 294 } | 294 } |
| 295 | 295 |
| 296 sizes->max_content = std::max(sizes->min_content, sizes->max_content); | 296 sizes->max_content = std::max(sizes->min_content, sizes->max_content); |
| 297 return true; | 297 return true; |
| 298 } | 298 } |
| 299 | 299 |
| 300 NGLogicalOffset NGBlockLayoutAlgorithm::CalculateRelativeOffset( | 300 NGLogicalOffset NGBlockLayoutAlgorithm::CalculateRelativeOffset( |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 // Do not collapse margins between parent and its child if there is | 373 // Do not collapse margins between parent and its child if there is |
| 374 // border/padding between them. | 374 // border/padding between them. |
| 375 if (border_and_padding_.block_start) { | 375 if (border_and_padding_.block_start) { |
| 376 curr_bfc_offset_.block_offset += curr_margin_strut_.Sum(); | 376 curr_bfc_offset_.block_offset += curr_margin_strut_.Sum(); |
| 377 builder_->SetBfcOffset(curr_bfc_offset_); | 377 builder_->SetBfcOffset(curr_bfc_offset_); |
| 378 curr_margin_strut_ = NGMarginStrut(); | 378 curr_margin_strut_ = NGMarginStrut(); |
| 379 } | 379 } |
| 380 curr_bfc_offset_.block_offset += content_size_; | 380 curr_bfc_offset_.block_offset += content_size_; |
| 381 | 381 |
| 382 while (current_child_) { | 382 while (current_child_) { |
| 383 EPosition position = current_child_->Style()->position(); | 383 EPosition position = current_child_->Style().position(); |
| 384 if (position == AbsolutePosition || position == FixedPosition) { | 384 if (position == AbsolutePosition || position == FixedPosition) { |
| 385 builder_->AddOutOfFlowChildCandidate(current_child_, | 385 builder_->AddOutOfFlowChildCandidate(current_child_, |
| 386 GetChildSpaceOffset()); | 386 GetChildSpaceOffset()); |
| 387 current_child_ = current_child_->NextSibling(); | 387 current_child_ = current_child_->NextSibling(); |
| 388 continue; | 388 continue; |
| 389 } | 389 } |
| 390 | 390 |
| 391 DCHECK(!ConstraintSpace().HasBlockFragmentation() || | 391 DCHECK(!ConstraintSpace().HasBlockFragmentation() || |
| 392 SpaceAvailableForCurrentChild() > LayoutUnit()); | 392 SpaceAvailableForCurrentChild() > LayoutUnit()); |
| 393 space_for_current_child_ = CreateConstraintSpaceForCurrentChild(); | 393 space_for_current_child_ = CreateConstraintSpaceForCurrentChild(); |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 visitor->trace(constraint_space_); | 725 visitor->trace(constraint_space_); |
| 726 visitor->trace(break_token_); | 726 visitor->trace(break_token_); |
| 727 visitor->trace(builder_); | 727 visitor->trace(builder_); |
| 728 visitor->trace(space_builder_); | 728 visitor->trace(space_builder_); |
| 729 visitor->trace(space_for_current_child_); | 729 visitor->trace(space_for_current_child_); |
| 730 visitor->trace(current_child_); | 730 visitor->trace(current_child_); |
| 731 visitor->trace(fragmentainer_mapper_); | 731 visitor->trace(fragmentainer_mapper_); |
| 732 } | 732 } |
| 733 | 733 |
| 734 } // namespace blink | 734 } // namespace blink |
| OLD | NEW |