Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/ng/ng_length_utils_test.cc |
| diff --git a/third_party/WebKit/Source/core/layout/ng/ng_length_utils_test.cc b/third_party/WebKit/Source/core/layout/ng/ng_length_utils_test.cc |
| index 73e221b6d9702528b2c79711f05540920566f150..104e5f0f6fb21d727647374e6fcee28ee394c3b3 100644 |
| --- a/third_party/WebKit/Source/core/layout/ng/ng_length_utils_test.cc |
| +++ b/third_party/WebKit/Source/core/layout/ng/ng_length_utils_test.cc |
| @@ -5,6 +5,7 @@ |
| #include "core/layout/ng/ng_length_utils.h" |
| #include "core/layout/ng/ng_constraint_space.h" |
| +#include "core/layout/ng/ng_derived_constraint_space.h" |
| #include "core/layout/ng/ng_margin_strut.h" |
| #include "core/style/ComputedStyle.h" |
| #include "platform/CalculationValue.h" |
| @@ -20,41 +21,43 @@ class NGLengthUtilsTest : public ::testing::Test { |
| protected: |
| void SetUp() override { style_ = ComputedStyle::create(); } |
| - static NGConstraintSpace constructConstraintSpace(int inline_size, |
| - int block_size) { |
| - NGLogicalSize container_size; |
| - container_size.inline_size = LayoutUnit(inline_size); |
| - container_size.block_size = LayoutUnit(block_size); |
| - return NGConstraintSpace(container_size); |
| + static NGConstraintSpace* constructConstraintSpace(int inline_size, |
|
cbiesinger
2016/08/25 22:22:16
Maybe rename to ConstructConstraintSpace while you
ikilpatrick
2016/08/25 23:14:29
Done.
|
| + int block_size, |
| + bool fixed_inline = false, |
| + bool fixed_block = false) { |
| + return new NGDerivedConstraintSpace( |
| + HorizontalTopBottom, |
| + NGLogicalSize(LayoutUnit(inline_size), LayoutUnit(block_size)), false, |
| + false, fixed_inline, fixed_block, FragmentNone); |
| } |
| LayoutUnit resolveInlineLength( |
| const Length& length, |
| LengthResolveType type = LengthResolveType::ContentSize) { |
| - NGConstraintSpace constraintSpace = constructConstraintSpace(200, 300); |
| - return ::blink::resolveInlineLength(constraintSpace, length, type); |
| + NGConstraintSpace* constraintSpace = constructConstraintSpace(200, 300); |
| + return ::blink::resolveInlineLength(*constraintSpace, length, type); |
| } |
| LayoutUnit resolveBlockLength( |
| const Length& length, |
| LengthResolveType type = LengthResolveType::ContentSize, |
| LayoutUnit contentSize = LayoutUnit()) { |
| - NGConstraintSpace constraintSpace = constructConstraintSpace(200, 300); |
| - return ::blink::resolveBlockLength(constraintSpace, length, contentSize, |
| + NGConstraintSpace* constraintSpace = constructConstraintSpace(200, 300); |
| + return ::blink::resolveBlockLength(*constraintSpace, length, contentSize, |
| type); |
| } |
| LayoutUnit computeInlineSizeForFragment( |
| - const NGConstraintSpace constraintSpace = constructConstraintSpace(200, |
| - 300)) { |
| - return ::blink::computeInlineSizeForFragment(constraintSpace, *style_); |
| + const NGConstraintSpace* constraintSpace = |
| + constructConstraintSpace(200, 300)) { |
| + return ::blink::computeInlineSizeForFragment(*constraintSpace, *style_); |
| } |
| LayoutUnit computeBlockSizeForFragment( |
| - const NGConstraintSpace constraintSpace = constructConstraintSpace(200, |
| - 300), |
| + const NGConstraintSpace* constraintSpace = constructConstraintSpace(200, |
| + 300), |
| LayoutUnit contentSize = LayoutUnit()) { |
| - return ::blink::computeBlockSizeForFragment(constraintSpace, *style_, |
| + return ::blink::computeBlockSizeForFragment(*constraintSpace, *style_, |
| contentSize); |
| } |
| @@ -105,8 +108,8 @@ TEST_F(NGLengthUtilsTest, testComputeInlineSizeForFragment) { |
| PixelsAndPercent(100, -10), ValueRangeNonNegative))); |
| EXPECT_EQ(LayoutUnit(80), computeInlineSizeForFragment()); |
| - NGConstraintSpace constraintSpace = constructConstraintSpace(120, 120); |
| - constraintSpace.setFixedSize(true, true); |
| + NGConstraintSpace* constraintSpace = |
| + constructConstraintSpace(120, 120, true, true); |
| style_->setLogicalWidth(Length(150, Fixed)); |
| EXPECT_EQ(LayoutUnit(120), computeInlineSizeForFragment(constraintSpace)); |
| @@ -143,8 +146,8 @@ TEST_F(NGLengthUtilsTest, testComputeBlockSizeForFragment) { |
| PixelsAndPercent(100, -10), ValueRangeNonNegative))); |
| EXPECT_EQ(LayoutUnit(70), computeBlockSizeForFragment()); |
| - NGConstraintSpace constraintSpace = constructConstraintSpace(200, 200); |
| - constraintSpace.setFixedSize(true, true); |
| + NGConstraintSpace* constraintSpace = |
| + constructConstraintSpace(200, 200, true, true); |
| style_->setLogicalHeight(Length(150, Fixed)); |
| EXPECT_EQ(LayoutUnit(200), computeBlockSizeForFragment(constraintSpace)); |
| @@ -180,9 +183,9 @@ TEST_F(NGLengthUtilsTest, testMargins) { |
| style_->setMarginBottom(Length(Auto)); |
| style_->setMarginLeft(Length(11, Percent)); |
| - NGConstraintSpace constraintSpace(constructConstraintSpace(200, 300)); |
| + NGConstraintSpace* constraintSpace(constructConstraintSpace(200, 300)); |
| - NGBoxMargins margins = computeMargins(constraintSpace, *style_); |
| + NGBoxMargins margins = computeMargins(*constraintSpace, *style_); |
| EXPECT_EQ(LayoutUnit(20), margins.block_start); |
| EXPECT_EQ(LayoutUnit(52), margins.inline_end); |