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/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 // TODO(glebl): Handle the case when a legacy block has border/padding. |
|
ikilpatrick
2017/04/24 20:27:50
This should be fine right? As these should always
Gleb Lanbin
2017/04/24 21:15:33
yes, on a second thought, I think this TODO is not
| |
| 348 if (child->IsInline()) { | 348 bool is_legacy_block = |
| 349 child->IsBlock() && !ToNGBlockNode(child)->CanUseNewLayout(); | |
| 350 | |
| 351 // Should collapse margins if inline or legacy block | |
| 352 if (child->IsInline() || is_legacy_block) { | |
| 349 curr_bfc_offset_.block_offset += curr_margin_strut_.Sum(); | 353 curr_bfc_offset_.block_offset += curr_margin_strut_.Sum(); |
| 350 MaybeUpdateFragmentBfcOffset(ConstraintSpace(), curr_bfc_offset_, | 354 MaybeUpdateFragmentBfcOffset(ConstraintSpace(), curr_bfc_offset_, |
| 351 &container_builder_); | 355 &container_builder_); |
| 352 PositionPendingFloats(curr_bfc_offset_.block_offset, &container_builder_, | 356 PositionPendingFloats(curr_bfc_offset_.block_offset, &container_builder_, |
| 353 MutableConstraintSpace()); | 357 MutableConstraintSpace()); |
| 354 curr_margin_strut_ = {}; | 358 curr_margin_strut_ = {}; |
| 355 } | 359 } |
| 356 child_bfc_offset.block_offset = curr_bfc_offset_.block_offset; | 360 child_bfc_offset.block_offset = curr_bfc_offset_.block_offset; |
| 357 return child_bfc_offset; | 361 return child_bfc_offset; |
| 358 } | 362 } |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 582 if (is_new_bfc) { | 586 if (is_new_bfc) { |
| 583 space_available -= child_bfc_offset.block_offset; | 587 space_available -= child_bfc_offset.block_offset; |
| 584 } | 588 } |
| 585 } | 589 } |
| 586 space_builder_.SetFragmentainerSpaceAvailable(space_available); | 590 space_builder_.SetFragmentainerSpaceAvailable(space_available); |
| 587 | 591 |
| 588 return space_builder_.ToConstraintSpace( | 592 return space_builder_.ToConstraintSpace( |
| 589 FromPlatformWritingMode(child_style.GetWritingMode())); | 593 FromPlatformWritingMode(child_style.GetWritingMode())); |
| 590 } | 594 } |
| 591 } // namespace blink | 595 } // namespace blink |
| OLD | NEW |