Chromium Code Reviews| 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_box_fragment.h" | 7 #include "core/layout/ng/ng_box_fragment.h" |
| 8 #include "core/layout/ng/ng_break_token.h" | 8 #include "core/layout/ng/ng_break_token.h" |
| 9 #include "core/layout/ng/ng_constraint_space.h" | 9 #include "core/layout/ng/ng_constraint_space.h" |
| 10 #include "core/layout/ng/ng_constraint_space_builder.h" | 10 #include "core/layout/ng/ng_constraint_space_builder.h" |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 367 fragment_offset = PositionFloatFragment(*fragment, child_margins); | 367 fragment_offset = PositionFloatFragment(*fragment, child_margins); |
| 368 } else { | 368 } else { |
| 369 ApplyAutoMargins(*space_for_current_child_, CurrentChildStyle(), *fragment, | 369 ApplyAutoMargins(*space_for_current_child_, CurrentChildStyle(), *fragment, |
| 370 &child_margins); | 370 &child_margins); |
| 371 fragment_offset = PositionFragment(*fragment, child_margins); | 371 fragment_offset = PositionFragment(*fragment, child_margins); |
| 372 } | 372 } |
| 373 builder_->AddChild(fragment, fragment_offset); | 373 builder_->AddChild(fragment, fragment_offset); |
| 374 } | 374 } |
| 375 | 375 |
| 376 bool NGBlockLayoutAlgorithm::LayoutOutOfFlowChild() { | 376 bool NGBlockLayoutAlgorithm::LayoutOutOfFlowChild() { |
| 377 if (!current_child_) { | 377 if (out_of_flow_candidates_.isEmpty()) { |
| 378 if (out_of_flow_candidates_.isEmpty()) { | 378 out_of_flow_layout_ = nullptr; |
| 379 out_of_flow_layout_ = nullptr; | 379 out_of_flow_candidate_positions_.clear(); |
| 380 out_of_flow_candidate_positions_.clear(); | 380 return true; |
| 381 return true; | 381 } |
| 382 } | 382 current_child_ = out_of_flow_candidates_.first(); |
| 383 current_child_ = out_of_flow_candidates_.first(); | 383 out_of_flow_candidates_.removeFirst(); |
| 384 out_of_flow_candidates_.removeFirst(); | 384 NGStaticPosition static_position = out_of_flow_candidate_positions_ |
| 385 NGStaticPosition position = out_of_flow_candidate_positions_ | 385 [out_of_flow_candidate_positions_index_++]; |
| 386 [out_of_flow_candidate_positions_index_++]; | |
| 387 | 386 |
| 388 if (!out_of_flow_layout_->StartLayout(current_child_, position)) { | 387 EPosition position = current_child_->Style()->position(); |
| 389 builder_->AddOutOfFlowDescendant(current_child_, position); | 388 bool contains_fixed = Style().canContainFixedPositionObjects(); |
| 390 current_child_ = nullptr; | 389 bool contains_absolute = |
| 391 return false; | 390 Style().canContainAbsolutePositionObjects() || contains_fixed; |
| 392 } | 391 |
| 393 } | 392 if ((contains_absolute && position == AbsolutePosition) || |
| 394 NGFragment* fragment; | 393 (contains_fixed && position == FixedPosition)) { |
| 395 NGLogicalOffset offset; | 394 NGFragment* fragment; |
| 396 if (out_of_flow_layout_->Layout(&fragment, &offset) == kNewFragment) { | 395 NGLogicalOffset offset; |
| 396 out_of_flow_layout_->Layout(*current_child_, static_position, &fragment, | |
| 397 &offset); | |
| 397 // TODO(atotic) Need to adjust size of overflow rect per spec. | 398 // TODO(atotic) Need to adjust size of overflow rect per spec. |
|
atotic
2017/01/18 18:48:49
I think the code to decide whether NGBlockNode can
ikilpatrick
2017/01/18 19:32:13
Right, I've pulled it into a static method inside
| |
| 398 builder_->AddChild(fragment, offset); | 399 builder_->AddChild(fragment, offset); |
| 399 current_child_ = nullptr; | 400 } else { |
| 401 builder_->AddOutOfFlowDescendant(current_child_, static_position); | |
| 400 } | 402 } |
| 403 | |
| 401 return false; | 404 return false; |
| 402 } | 405 } |
| 403 | 406 |
| 404 NGBoxStrut NGBlockLayoutAlgorithm::CollapseMargins( | 407 NGBoxStrut NGBlockLayoutAlgorithm::CollapseMargins( |
| 405 const NGBoxStrut& margins, | 408 const NGBoxStrut& margins, |
| 406 const NGBoxFragment& fragment) { | 409 const NGBoxFragment& fragment) { |
| 407 bool is_zero_height_box = !fragment.BlockSize() && margins.IsEmpty() && | 410 bool is_zero_height_box = !fragment.BlockSize() && margins.IsEmpty() && |
| 408 fragment.MarginStrut().IsEmpty(); | 411 fragment.MarginStrut().IsEmpty(); |
| 409 // Create the current child's margin strut from its children's margin strut or | 412 // 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. | 413 // 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_); | 562 visitor->trace(builder_); |
| 560 visitor->trace(space_builder_); | 563 visitor->trace(space_builder_); |
| 561 visitor->trace(space_for_current_child_); | 564 visitor->trace(space_for_current_child_); |
| 562 visitor->trace(current_child_); | 565 visitor->trace(current_child_); |
| 563 visitor->trace(current_minmax_child_); | 566 visitor->trace(current_minmax_child_); |
| 564 visitor->trace(out_of_flow_layout_); | 567 visitor->trace(out_of_flow_layout_); |
| 565 visitor->trace(out_of_flow_candidates_); | 568 visitor->trace(out_of_flow_candidates_); |
| 566 } | 569 } |
| 567 | 570 |
| 568 } // namespace blink | 571 } // namespace blink |
| OLD | NEW |