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_block_node.h" | 7 #include "core/layout/ng/ng_block_node.h" |
| 8 #include "core/layout/ng/ng_constraint_space.h" | 8 #include "core/layout/ng/ng_constraint_space.h" |
| 9 #include "core/layout/ng/ng_constraint_space_builder.h" | 9 #include "core/layout/ng/ng_constraint_space_builder.h" |
| 10 #include "core/layout/ng/ng_physical_fragment_base.h" | 10 #include "core/layout/ng/ng_physical_fragment_base.h" |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 772 kHorizontalTopBottom, TextDirection::Ltr, | 772 kHorizontalTopBottom, TextDirection::Ltr, |
| 773 NGLogicalSize(LayoutUnit(kParentSize), LayoutUnit(kParentSize))); | 773 NGLogicalSize(LayoutUnit(kParentSize), LayoutUnit(kParentSize))); |
| 774 frag = RunBlockLayoutAlgorithm(space, div1); | 774 frag = RunBlockLayoutAlgorithm(space, div1); |
| 775 space = ConstructConstraintSpace( | 775 space = ConstructConstraintSpace( |
| 776 kHorizontalTopBottom, TextDirection::Ltr, | 776 kHorizontalTopBottom, TextDirection::Ltr, |
| 777 NGLogicalSize(LayoutUnit(kParentSize), LayoutUnit(kParentSize))); | 777 NGLogicalSize(LayoutUnit(kParentSize), LayoutUnit(kParentSize))); |
| 778 child3 = frag->Children()[2]; | 778 child3 = frag->Children()[2]; |
| 779 EXPECT_EQ(kDiv1Size + kDiv2Size, child3->TopOffset()); | 779 EXPECT_EQ(kDiv1Size + kDiv2Size, child3->TopOffset()); |
| 780 } | 780 } |
| 781 | 781 |
| 782 // Verifies that we compute the right min and max-content size. | |
| 783 TEST_F(NGBlockLayoutAlgorithmTest, ComputeMinMaxContent) { | |
| 784 const int kWidth = 30; | |
| 785 const int kHeight1 = 20; | |
| 786 const int kHeight2 = 30; | |
| 787 const int kMarginTop = 5; | |
| 788 const int kMarginBottom = 20; | |
| 789 style_->setWidth(Length(kWidth, Fixed)); | |
|
ikilpatrick
2016/12/22 03:29:18
shouldn't this be fit-content or similar to trigge
cbiesinger
2016/12/22 15:22:32
Er, oops, I think I forgot to edit this after copy
| |
| 790 | |
| 791 RefPtr<ComputedStyle> first_style = ComputedStyle::create(); | |
| 792 first_style->setHeight(Length(kHeight1, Fixed)); | |
| 793 NGBlockNode* first_child = new NGBlockNode(first_style.get()); | |
| 794 | |
| 795 RefPtr<ComputedStyle> second_style = ComputedStyle::create(); | |
| 796 second_style->setHeight(Length(kHeight2, Fixed)); | |
| 797 second_style->setMarginTop(Length(kMarginTop, Fixed)); | |
| 798 second_style->setMarginBottom(Length(kMarginBottom, Fixed)); | |
| 799 NGBlockNode* second_child = new NGBlockNode(second_style.get()); | |
| 800 | |
| 801 first_child->SetNextSibling(second_child); | |
| 802 | |
| 803 auto* space = ConstructConstraintSpace( | |
| 804 kHorizontalTopBottom, TextDirection::Ltr, | |
| 805 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite)); | |
| 806 NGPhysicalFragment* frag = RunBlockLayoutAlgorithm(space, first_child); | |
| 807 | |
| 808 EXPECT_EQ(LayoutUnit(kWidth), frag->Width()); | |
| 809 EXPECT_EQ(LayoutUnit(kHeight1 + kHeight2 + kMarginTop), frag->Height()); | |
| 810 EXPECT_EQ(NGPhysicalFragmentBase::kFragmentBox, frag->Type()); | |
| 811 ASSERT_EQ(frag->Children().size(), 2UL); | |
| 812 | |
| 813 const NGPhysicalFragmentBase* child = frag->Children()[0]; | |
| 814 EXPECT_EQ(kHeight1, child->Height()); | |
| 815 EXPECT_EQ(0, child->TopOffset()); | |
| 816 | |
| 817 child = frag->Children()[1]; | |
| 818 EXPECT_EQ(kHeight2, child->Height()); | |
| 819 EXPECT_EQ(kHeight1 + kMarginTop, child->TopOffset()); | |
| 820 } | |
| 821 | |
| 782 } // namespace | 822 } // namespace |
| 783 } // namespace blink | 823 } // namespace blink |
| OLD | NEW |