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/inline/ng_inline_node.h" | 7 #include "core/layout/ng/inline/ng_inline_node.h" |
8 #include "core/layout/ng/ng_absolute_utils.h" | 8 #include "core/layout/ng/ng_absolute_utils.h" |
9 #include "core/layout/ng/ng_block_child_iterator.h" | 9 #include "core/layout/ng/ng_block_child_iterator.h" |
10 #include "core/layout/ng/ng_constraint_space.h" | 10 #include "core/layout/ng/ng_constraint_space.h" |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 // strut as they do not participate in margin collapsing. | 337 // strut as they do not participate in margin collapsing. |
338 if (is_inflow) { | 338 if (is_inflow) { |
339 child_bfc_offset.inline_offset += curr_child_margins_.inline_start; | 339 child_bfc_offset.inline_offset += curr_child_margins_.inline_start; |
340 // Append the current margin strut with child's block start margin. | 340 // Append the current margin strut with child's block start margin. |
341 // Non empty border/padding, and new FC use cases are handled inside of the | 341 // Non empty border/padding, and new FC use cases are handled inside of the |
342 // child's layout. | 342 // child's layout. |
343 if (!IsNewFormattingContextForBlockLevelChild(Style(), *child)) | 343 if (!IsNewFormattingContextForBlockLevelChild(Style(), *child)) |
344 curr_margin_strut_.Append(curr_child_margins_.block_start); | 344 curr_margin_strut_.Append(curr_child_margins_.block_start); |
345 } | 345 } |
346 | 346 |
347 // Should collapse margins if inline. | 347 bool is_legacy_block = |
348 if (child->IsInline()) { | 348 child->IsBlock() && !ToNGBlockNode(child)->CanUseNewLayout(); |
| 349 |
| 350 // Should collapse margins if inline or legacy block |
| 351 if (child->IsInline() || is_legacy_block) { |
349 curr_bfc_offset_.block_offset += curr_margin_strut_.Sum(); | 352 curr_bfc_offset_.block_offset += curr_margin_strut_.Sum(); |
350 MaybeUpdateFragmentBfcOffset(ConstraintSpace(), curr_bfc_offset_, | 353 MaybeUpdateFragmentBfcOffset(ConstraintSpace(), curr_bfc_offset_, |
351 &container_builder_); | 354 &container_builder_); |
352 PositionPendingFloats(curr_bfc_offset_.block_offset, &container_builder_, | 355 PositionPendingFloats(curr_bfc_offset_.block_offset, &container_builder_, |
353 MutableConstraintSpace()); | 356 MutableConstraintSpace()); |
354 curr_margin_strut_ = {}; | 357 curr_margin_strut_ = {}; |
355 } | 358 } |
356 child_bfc_offset.block_offset = curr_bfc_offset_.block_offset; | 359 child_bfc_offset.block_offset = curr_bfc_offset_.block_offset; |
357 return child_bfc_offset; | 360 return child_bfc_offset; |
358 } | 361 } |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 if (is_new_bfc) { | 585 if (is_new_bfc) { |
583 space_available -= child_bfc_offset.block_offset; | 586 space_available -= child_bfc_offset.block_offset; |
584 } | 587 } |
585 } | 588 } |
586 space_builder_.SetFragmentainerSpaceAvailable(space_available); | 589 space_builder_.SetFragmentainerSpaceAvailable(space_available); |
587 | 590 |
588 return space_builder_.ToConstraintSpace( | 591 return space_builder_.ToConstraintSpace( |
589 FromPlatformWritingMode(child_style.GetWritingMode())); | 592 FromPlatformWritingMode(child_style.GetWritingMode())); |
590 } | 593 } |
591 } // namespace blink | 594 } // namespace blink |
OLD | NEW |