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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 // Bottom margins of an in-flow block box doesn't collapse with its last | 290 // Bottom margins of an in-flow block box doesn't collapse with its last |
291 // in-flow block-level child's bottom margin if the box has bottom | 291 // in-flow block-level child's bottom margin if the box has bottom |
292 // border/padding. | 292 // border/padding. |
293 if (border_scrollbar_padding_.block_end || | 293 if (border_scrollbar_padding_.block_end || |
294 ConstraintSpace().IsNewFormattingContext()) { | 294 ConstraintSpace().IsNewFormattingContext()) { |
295 content_size_ = | 295 content_size_ = |
296 std::max(content_size_, previous_inflow_position.logical_block_offset + | 296 std::max(content_size_, previous_inflow_position.logical_block_offset + |
297 end_margin_strut.Sum()); | 297 end_margin_strut.Sum()); |
298 end_margin_strut = NGMarginStrut(); | 298 end_margin_strut = NGMarginStrut(); |
299 } | 299 } |
| 300 |
| 301 // If the current layout is a new formatting context, we need to encapsulate |
| 302 // all of our floats. |
| 303 if (ConstraintSpace().IsNewFormattingContext()) { |
| 304 // We can use the BFC coordinates, as we are a new formatting context. |
| 305 DCHECK_EQ(container_builder_.BfcOffset().value(), NGLogicalOffset()); |
| 306 |
| 307 WTF::Optional<LayoutUnit> float_end_offset = |
| 308 GetClearanceOffset(ConstraintSpace().Exclusions(), EClear::kBoth); |
| 309 if (float_end_offset) |
| 310 content_size_ = std::max(content_size_, float_end_offset.value()); |
| 311 } |
| 312 |
300 content_size_ += border_scrollbar_padding_.block_end; | 313 content_size_ += border_scrollbar_padding_.block_end; |
301 | 314 |
302 // Recompute the block-axis size now that we know our content size. | 315 // Recompute the block-axis size now that we know our content size. |
303 size.block_size = | 316 size.block_size = |
304 ComputeBlockSizeForFragment(ConstraintSpace(), Style(), content_size_); | 317 ComputeBlockSizeForFragment(ConstraintSpace(), Style(), content_size_); |
305 container_builder_.SetBlockSize(size.block_size); | 318 container_builder_.SetBlockSize(size.block_size); |
306 | 319 |
307 // Layout our absolute and fixed positioned children. | 320 // Layout our absolute and fixed positioned children. |
308 NGOutOfFlowLayoutPart(ConstraintSpace(), Style(), &container_builder_).Run(); | 321 NGOutOfFlowLayoutPart(ConstraintSpace(), Style(), &container_builder_).Run(); |
309 | 322 |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 if (is_new_fc) { | 725 if (is_new_fc) { |
713 space_available -= child_data.bfc_offset_estimate.block_offset; | 726 space_available -= child_data.bfc_offset_estimate.block_offset; |
714 } | 727 } |
715 } | 728 } |
716 space_builder.SetFragmentainerSpaceAvailable(space_available); | 729 space_builder.SetFragmentainerSpaceAvailable(space_available); |
717 | 730 |
718 return space_builder.ToConstraintSpace( | 731 return space_builder.ToConstraintSpace( |
719 FromPlatformWritingMode(child_style.GetWritingMode())); | 732 FromPlatformWritingMode(child_style.GetWritingMode())); |
720 } | 733 } |
721 } // namespace blink | 734 } // namespace blink |
OLD | NEW |