Index: third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc |
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc b/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc |
index e8e441e9c6df3f30ba2eec8463317d67eb9afdec..adcdce50ef26fc89338b861d222ee6f582d3e788 100644 |
--- a/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc |
+++ b/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc |
@@ -42,14 +42,22 @@ bool NGBlockLayoutAlgorithm::Layout(const NGConstraintSpace* constraint_space, |
LayoutUnit inline_size = |
computeInlineSizeForFragment(*constraint_space, *style_); |
+ LayoutUnit adjusted_inline_size = |
+ inline_size - border_and_padding_.InlineSum(); |
// TODO(layout-ng): For quirks mode, should we pass blockSize instead of |
// -1? |
LayoutUnit block_size = computeBlockSizeForFragment( |
- *constraint_space, *style_, LayoutUnit(-1)); |
+ *constraint_space, *style_, NGSizeIndefinite); |
+ LayoutUnit adjusted_block_size(block_size); |
+ // Our calculated block-axis size may be indefinite at this point. |
+ // If so, just leave the size as NGSizeIndefinite instead of subtracting |
+ // borders and padding. |
+ if (adjusted_block_size != NGSizeIndefinite) |
+ adjusted_block_size -= border_and_padding_.BlockSum(); |
constraint_space_for_children_ = new NGConstraintSpace( |
- *constraint_space, NGLogicalOffset(), |
- NGLogicalSize(inline_size - border_and_padding_.InlineSum(), |
- block_size - border_and_padding_.BlockSum())); |
+ FromPlatformWritingMode(style_->getWritingMode()), |
+ FromPlatformDirection(style_->direction()), *constraint_space, |
+ NGLogicalSize(adjusted_inline_size, adjusted_block_size)); |
content_size_ = border_and_padding_.block_start; |
builder_ = new NGFragmentBuilder(NGPhysicalFragmentBase::FragmentBox); |