| 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_block_break_token.h" | 8 #include "core/layout/ng/ng_block_break_token.h" |
| 8 #include "core/layout/ng/ng_box_fragment.h" | 9 #include "core/layout/ng/ng_box_fragment.h" |
| 9 #include "core/layout/ng/ng_column_mapper.h" | 10 #include "core/layout/ng/ng_column_mapper.h" |
| 10 #include "core/layout/ng/ng_constraint_space.h" | 11 #include "core/layout/ng/ng_constraint_space.h" |
| 11 #include "core/layout/ng/ng_constraint_space_builder.h" | 12 #include "core/layout/ng/ng_constraint_space_builder.h" |
| 12 #include "core/layout/ng/ng_fragment.h" | 13 #include "core/layout/ng/ng_fragment.h" |
| 13 #include "core/layout/ng/ng_fragment_builder.h" | 14 #include "core/layout/ng/ng_fragment_builder.h" |
| 14 #include "core/layout/ng/ng_layout_opportunity_iterator.h" | 15 #include "core/layout/ng/ng_layout_opportunity_iterator.h" |
| 15 #include "core/layout/ng/ng_length_utils.h" | 16 #include "core/layout/ng/ng_length_utils.h" |
| 16 #include "core/layout/ng/ng_out_of_flow_layout_part.h" | 17 #include "core/layout/ng/ng_out_of_flow_layout_part.h" |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 fragment_offset = PositionFragment(*fragment, child_margins); | 392 fragment_offset = PositionFragment(*fragment, child_margins); |
| 392 } | 393 } |
| 393 if (fragmentainer_mapper_) | 394 if (fragmentainer_mapper_) |
| 394 fragmentainer_mapper_->ToVisualOffset(fragment_offset); | 395 fragmentainer_mapper_->ToVisualOffset(fragment_offset); |
| 395 else | 396 else |
| 396 fragment_offset.block_offset -= PreviousBreakOffset(); | 397 fragment_offset.block_offset -= PreviousBreakOffset(); |
| 397 builder_->AddChild(fragment, fragment_offset); | 398 builder_->AddChild(fragment, fragment_offset); |
| 398 } | 399 } |
| 399 | 400 |
| 400 bool NGBlockLayoutAlgorithm::LayoutOutOfFlowChild() { | 401 bool NGBlockLayoutAlgorithm::LayoutOutOfFlowChild() { |
| 401 if (!current_child_) { | 402 if (out_of_flow_candidates_.isEmpty()) { |
| 402 if (out_of_flow_candidates_.isEmpty()) { | 403 out_of_flow_layout_ = nullptr; |
| 403 out_of_flow_layout_ = nullptr; | 404 out_of_flow_candidate_positions_.clear(); |
| 404 out_of_flow_candidate_positions_.clear(); | 405 return true; |
| 405 return true; | 406 } |
| 406 } | 407 current_child_ = out_of_flow_candidates_.first(); |
| 407 current_child_ = out_of_flow_candidates_.first(); | 408 out_of_flow_candidates_.removeFirst(); |
| 408 out_of_flow_candidates_.removeFirst(); | 409 NGStaticPosition static_position = out_of_flow_candidate_positions_ |
| 409 NGStaticPosition position = out_of_flow_candidate_positions_ | 410 [out_of_flow_candidate_positions_index_++]; |
| 410 [out_of_flow_candidate_positions_index_++]; | |
| 411 | 411 |
| 412 if (!out_of_flow_layout_->StartLayout(current_child_, position)) { | 412 if (IsContainingBlockForAbsoluteChild(Style(), *current_child_->Style())) { |
| 413 builder_->AddOutOfFlowDescendant(current_child_, position); | 413 NGFragment* fragment; |
| 414 current_child_ = nullptr; | 414 NGLogicalOffset offset; |
| 415 return false; | 415 out_of_flow_layout_->Layout(*current_child_, static_position, &fragment, |
| 416 } | 416 &offset); |
| 417 } | |
| 418 NGFragment* fragment; | |
| 419 NGLogicalOffset offset; | |
| 420 if (out_of_flow_layout_->Layout(&fragment, &offset) == kNewFragment) { | |
| 421 // TODO(atotic) Need to adjust size of overflow rect per spec. | 417 // TODO(atotic) Need to adjust size of overflow rect per spec. |
| 422 builder_->AddChild(fragment, offset); | 418 builder_->AddChild(fragment, offset); |
| 423 current_child_ = nullptr; | 419 } else { |
| 420 builder_->AddOutOfFlowDescendant(current_child_, static_position); |
| 424 } | 421 } |
| 422 |
| 425 return false; | 423 return false; |
| 426 } | 424 } |
| 427 | 425 |
| 428 bool NGBlockLayoutAlgorithm::ProceedToNextUnfinishedSibling( | 426 bool NGBlockLayoutAlgorithm::ProceedToNextUnfinishedSibling( |
| 429 NGPhysicalFragment* child_fragment) { | 427 NGPhysicalFragment* child_fragment) { |
| 430 DCHECK(current_child_); | 428 DCHECK(current_child_); |
| 431 NGBlockNode* finished_child = current_child_; | 429 NGBlockNode* finished_child = current_child_; |
| 432 current_child_ = current_child_->NextSibling(); | 430 current_child_ = current_child_->NextSibling(); |
| 433 if (!ConstraintSpace().HasBlockFragmentation() && !fragmentainer_mapper_) | 431 if (!ConstraintSpace().HasBlockFragmentation() && !fragmentainer_mapper_) |
| 434 return true; | 432 return true; |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 visitor->trace(space_builder_); | 724 visitor->trace(space_builder_); |
| 727 visitor->trace(space_for_current_child_); | 725 visitor->trace(space_for_current_child_); |
| 728 visitor->trace(current_child_); | 726 visitor->trace(current_child_); |
| 729 visitor->trace(current_minmax_child_); | 727 visitor->trace(current_minmax_child_); |
| 730 visitor->trace(out_of_flow_layout_); | 728 visitor->trace(out_of_flow_layout_); |
| 731 visitor->trace(out_of_flow_candidates_); | 729 visitor->trace(out_of_flow_candidates_); |
| 732 visitor->trace(fragmentainer_mapper_); | 730 visitor->trace(fragmentainer_mapper_); |
| 733 } | 731 } |
| 734 | 732 |
| 735 } // namespace blink | 733 } // namespace blink |
| OLD | NEW |