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_box_fragment.h" | 8 #include "core/layout/ng/ng_box_fragment.h" |
8 #include "core/layout/ng/ng_break_token.h" | 9 #include "core/layout/ng/ng_break_token.h" |
9 #include "core/layout/ng/ng_constraint_space.h" | 10 #include "core/layout/ng/ng_constraint_space.h" |
10 #include "core/layout/ng/ng_constraint_space_builder.h" | 11 #include "core/layout/ng/ng_constraint_space_builder.h" |
11 #include "core/layout/ng/ng_fragment.h" | 12 #include "core/layout/ng/ng_fragment.h" |
12 #include "core/layout/ng/ng_fragment_builder.h" | 13 #include "core/layout/ng/ng_fragment_builder.h" |
13 #include "core/layout/ng/ng_layout_opportunity_iterator.h" | 14 #include "core/layout/ng/ng_layout_opportunity_iterator.h" |
14 #include "core/layout/ng/ng_length_utils.h" | 15 #include "core/layout/ng/ng_length_utils.h" |
15 #include "core/layout/ng/ng_out_of_flow_layout_part.h" | 16 #include "core/layout/ng/ng_out_of_flow_layout_part.h" |
16 #include "core/layout/ng/ng_units.h" | 17 #include "core/layout/ng/ng_units.h" |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
367 fragment_offset = PositionFloatFragment(*fragment, child_margins); | 368 fragment_offset = PositionFloatFragment(*fragment, child_margins); |
368 } else { | 369 } else { |
369 ApplyAutoMargins(*space_for_current_child_, CurrentChildStyle(), *fragment, | 370 ApplyAutoMargins(*space_for_current_child_, CurrentChildStyle(), *fragment, |
370 &child_margins); | 371 &child_margins); |
371 fragment_offset = PositionFragment(*fragment, child_margins); | 372 fragment_offset = PositionFragment(*fragment, child_margins); |
372 } | 373 } |
373 builder_->AddChild(fragment, fragment_offset); | 374 builder_->AddChild(fragment, fragment_offset); |
374 } | 375 } |
375 | 376 |
376 bool NGBlockLayoutAlgorithm::LayoutOutOfFlowChild() { | 377 bool NGBlockLayoutAlgorithm::LayoutOutOfFlowChild() { |
377 if (!current_child_) { | 378 if (out_of_flow_candidates_.isEmpty()) { |
378 if (out_of_flow_candidates_.isEmpty()) { | 379 out_of_flow_layout_ = nullptr; |
379 out_of_flow_layout_ = nullptr; | 380 out_of_flow_candidate_positions_.clear(); |
380 out_of_flow_candidate_positions_.clear(); | 381 return true; |
381 return true; | 382 } |
382 } | 383 current_child_ = out_of_flow_candidates_.first(); |
383 current_child_ = out_of_flow_candidates_.first(); | 384 out_of_flow_candidates_.removeFirst(); |
384 out_of_flow_candidates_.removeFirst(); | 385 NGStaticPosition static_position = out_of_flow_candidate_positions_ |
385 NGStaticPosition position = out_of_flow_candidate_positions_ | 386 [out_of_flow_candidate_positions_index_++]; |
atotic
2017/01/18 20:02:16
out_of_flow_candidate_positions_index_ should be a
ikilpatrick
2017/01/18 21:32:19
I'll fix this in a follow up so not to make this p
| |
386 [out_of_flow_candidate_positions_index_++]; | |
387 | 387 |
388 if (!out_of_flow_layout_->StartLayout(current_child_, position)) { | 388 if (IsContainerForAbsoluteChild(Style(), *current_child_->Style())) { |
389 builder_->AddOutOfFlowDescendant(current_child_, position); | 389 NGFragment* fragment; |
390 current_child_ = nullptr; | 390 NGLogicalOffset offset; |
391 return false; | 391 out_of_flow_layout_->Layout(*current_child_, static_position, &fragment, |
392 } | 392 &offset); |
393 } | |
394 NGFragment* fragment; | |
395 NGLogicalOffset offset; | |
396 if (out_of_flow_layout_->Layout(&fragment, &offset) == kNewFragment) { | |
397 // TODO(atotic) Need to adjust size of overflow rect per spec. | 393 // TODO(atotic) Need to adjust size of overflow rect per spec. |
398 builder_->AddChild(fragment, offset); | 394 builder_->AddChild(fragment, offset); |
399 current_child_ = nullptr; | 395 } else { |
396 builder_->AddOutOfFlowDescendant(current_child_, static_position); | |
400 } | 397 } |
398 | |
401 return false; | 399 return false; |
402 } | 400 } |
403 | 401 |
404 NGBoxStrut NGBlockLayoutAlgorithm::CollapseMargins( | 402 NGBoxStrut NGBlockLayoutAlgorithm::CollapseMargins( |
405 const NGBoxStrut& margins, | 403 const NGBoxStrut& margins, |
406 const NGBoxFragment& fragment) { | 404 const NGBoxFragment& fragment) { |
407 bool is_zero_height_box = !fragment.BlockSize() && margins.IsEmpty() && | 405 bool is_zero_height_box = !fragment.BlockSize() && margins.IsEmpty() && |
408 fragment.MarginStrut().IsEmpty(); | 406 fragment.MarginStrut().IsEmpty(); |
409 // Create the current child's margin strut from its children's margin strut or | 407 // Create the current child's margin strut from its children's margin strut or |
410 // use margin strut from the the last non-empty child. | 408 // use margin strut from the the last non-empty child. |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
559 visitor->trace(builder_); | 557 visitor->trace(builder_); |
560 visitor->trace(space_builder_); | 558 visitor->trace(space_builder_); |
561 visitor->trace(space_for_current_child_); | 559 visitor->trace(space_for_current_child_); |
562 visitor->trace(current_child_); | 560 visitor->trace(current_child_); |
563 visitor->trace(current_minmax_child_); | 561 visitor->trace(current_minmax_child_); |
564 visitor->trace(out_of_flow_layout_); | 562 visitor->trace(out_of_flow_layout_); |
565 visitor->trace(out_of_flow_candidates_); | 563 visitor->trace(out_of_flow_candidates_); |
566 } | 564 } |
567 | 565 |
568 } // namespace blink | 566 } // namespace blink |
OLD | NEW |