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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 break; | 307 break; |
308 } | 308 } |
309 | 309 |
310 content_size_ += border_and_padding_.block_end; | 310 content_size_ += border_and_padding_.block_end; |
311 | 311 |
312 // Recompute the block-axis size now that we know our content size. | 312 // Recompute the block-axis size now that we know our content size. |
313 block_size = | 313 block_size = |
314 ComputeBlockSizeForFragment(ConstraintSpace(), Style(), content_size_); | 314 ComputeBlockSizeForFragment(ConstraintSpace(), Style(), content_size_); |
315 builder_->SetBlockSize(block_size); | 315 builder_->SetBlockSize(block_size); |
316 | 316 |
317 // Out of flow setup. | |
318 out_of_flow_layout_ = new NGOutOfFlowLayoutPart(&Style(), builder_->Size()); | |
319 builder_->GetAndClearOutOfFlowDescendantCandidates( | |
320 &out_of_flow_candidates_, &out_of_flow_candidate_positions_); | |
321 out_of_flow_candidate_positions_index_ = 0; | |
322 current_child_ = nullptr; | 317 current_child_ = nullptr; |
323 | 318 |
324 while (!LayoutOutOfFlowChild()) | 319 // Layout our absolute and fixed positioned children. |
325 continue; | 320 NGOutOfFlowLayoutPart(Style(), builder_).Run(); |
326 | 321 |
327 builder_->SetInlineOverflow(max_inline_size_).SetBlockOverflow(content_size_); | 322 builder_->SetInlineOverflow(max_inline_size_).SetBlockOverflow(content_size_); |
328 | 323 |
329 if (ConstraintSpace().HasBlockFragmentation()) | 324 if (ConstraintSpace().HasBlockFragmentation()) |
330 FinalizeForFragmentation(); | 325 FinalizeForFragmentation(); |
331 | 326 |
332 *fragment_out = builder_->ToBoxFragment(); | 327 *fragment_out = builder_->ToBoxFragment(); |
333 return kNewFragment; | 328 return kNewFragment; |
334 } | 329 } |
335 | 330 |
(...skipping 10 matching lines...) Expand all Loading... |
346 &child_margins); | 341 &child_margins); |
347 fragment_offset = PositionFragment(*fragment, child_margins); | 342 fragment_offset = PositionFragment(*fragment, child_margins); |
348 } | 343 } |
349 if (fragmentainer_mapper_) | 344 if (fragmentainer_mapper_) |
350 fragmentainer_mapper_->ToVisualOffset(fragment_offset); | 345 fragmentainer_mapper_->ToVisualOffset(fragment_offset); |
351 else | 346 else |
352 fragment_offset.block_offset -= PreviousBreakOffset(); | 347 fragment_offset.block_offset -= PreviousBreakOffset(); |
353 builder_->AddChild(fragment, fragment_offset); | 348 builder_->AddChild(fragment, fragment_offset); |
354 } | 349 } |
355 | 350 |
356 bool NGBlockLayoutAlgorithm::LayoutOutOfFlowChild() { | |
357 if (out_of_flow_candidates_.isEmpty()) { | |
358 out_of_flow_layout_ = nullptr; | |
359 out_of_flow_candidate_positions_.clear(); | |
360 return true; | |
361 } | |
362 current_child_ = out_of_flow_candidates_.first(); | |
363 out_of_flow_candidates_.removeFirst(); | |
364 NGStaticPosition static_position = out_of_flow_candidate_positions_ | |
365 [out_of_flow_candidate_positions_index_++]; | |
366 | |
367 if (IsContainingBlockForAbsoluteChild(Style(), *current_child_->Style())) { | |
368 NGFragment* fragment; | |
369 NGLogicalOffset offset; | |
370 out_of_flow_layout_->Layout(*current_child_, static_position, &fragment, | |
371 &offset); | |
372 // TODO(atotic) Need to adjust size of overflow rect per spec. | |
373 builder_->AddChild(fragment, offset); | |
374 } else { | |
375 builder_->AddOutOfFlowDescendant(current_child_, static_position); | |
376 } | |
377 | |
378 return false; | |
379 } | |
380 | |
381 bool NGBlockLayoutAlgorithm::ProceedToNextUnfinishedSibling( | 351 bool NGBlockLayoutAlgorithm::ProceedToNextUnfinishedSibling( |
382 NGPhysicalFragment* child_fragment) { | 352 NGPhysicalFragment* child_fragment) { |
383 DCHECK(current_child_); | 353 DCHECK(current_child_); |
384 NGBlockNode* finished_child = current_child_; | 354 NGBlockNode* finished_child = current_child_; |
385 current_child_ = current_child_->NextSibling(); | 355 current_child_ = current_child_->NextSibling(); |
386 if (!ConstraintSpace().HasBlockFragmentation() && !fragmentainer_mapper_) | 356 if (!ConstraintSpace().HasBlockFragmentation() && !fragmentainer_mapper_) |
387 return true; | 357 return true; |
388 // If we're resuming layout after a fragmentainer break, we need to skip | 358 // If we're resuming layout after a fragmentainer break, we need to skip |
389 // siblings that we're done with. We may have been able to fully lay out some | 359 // siblings that we're done with. We may have been able to fully lay out some |
390 // node(s) preceding a node that we had to break inside (and therefore were | 360 // node(s) preceding a node that we had to break inside (and therefore were |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 | 642 |
673 DEFINE_TRACE(NGBlockLayoutAlgorithm) { | 643 DEFINE_TRACE(NGBlockLayoutAlgorithm) { |
674 NGLayoutAlgorithm::trace(visitor); | 644 NGLayoutAlgorithm::trace(visitor); |
675 visitor->trace(first_child_); | 645 visitor->trace(first_child_); |
676 visitor->trace(constraint_space_); | 646 visitor->trace(constraint_space_); |
677 visitor->trace(break_token_); | 647 visitor->trace(break_token_); |
678 visitor->trace(builder_); | 648 visitor->trace(builder_); |
679 visitor->trace(space_builder_); | 649 visitor->trace(space_builder_); |
680 visitor->trace(space_for_current_child_); | 650 visitor->trace(space_for_current_child_); |
681 visitor->trace(current_child_); | 651 visitor->trace(current_child_); |
682 visitor->trace(out_of_flow_layout_); | |
683 visitor->trace(out_of_flow_candidates_); | |
684 visitor->trace(fragmentainer_mapper_); | 652 visitor->trace(fragmentainer_mapper_); |
685 } | 653 } |
686 | 654 |
687 } // namespace blink | 655 } // namespace blink |
OLD | NEW |