| 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_length_utils.h" | 5 #include "core/layout/ng/ng_length_utils.h" |
| 6 | 6 |
| 7 #include "core/layout/ng/ng_constraint_space.h" | 7 #include "core/layout/ng/ng_constraint_space.h" |
| 8 #include "core/layout/ng/ng_margin_strut.h" | 8 #include "core/layout/ng/ng_margin_strut.h" |
| 9 #include "core/style/ComputedStyle.h" | 9 #include "core/style/ComputedStyle.h" |
| 10 #include "platform/CalculationValue.h" | 10 #include "platform/CalculationValue.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 style_->setMaxHeight(Length(80, Percent)); | 152 style_->setMaxHeight(Length(80, Percent)); |
| 153 EXPECT_EQ(LayoutUnit(240), computeBlockSizeForFragment()); | 153 EXPECT_EQ(LayoutUnit(240), computeBlockSizeForFragment()); |
| 154 | 154 |
| 155 style_->setLogicalHeight(Length(100, Fixed)); | 155 style_->setLogicalHeight(Length(100, Fixed)); |
| 156 style_->setMinHeight(Length(80, Percent)); | 156 style_->setMinHeight(Length(80, Percent)); |
| 157 EXPECT_EQ(LayoutUnit(240), computeBlockSizeForFragment()); | 157 EXPECT_EQ(LayoutUnit(240), computeBlockSizeForFragment()); |
| 158 | 158 |
| 159 // TODO(layout-ng): test {min,max}-content on max-height. | 159 // TODO(layout-ng): test {min,max}-content on max-height. |
| 160 } | 160 } |
| 161 | 161 |
| 162 TEST_F(NGLengthUtilsTest, testIndefinitePercentages) { |
| 163 style_->setMinHeight(Length(20, Fixed)); |
| 164 style_->setHeight(Length(20, Percent)); |
| 165 |
| 166 EXPECT_EQ(NGSizeIndefinite, |
| 167 computeBlockSizeForFragment(constructConstraintSpace(200, -1), |
| 168 LayoutUnit(-1))); |
| 169 EXPECT_EQ(LayoutUnit(20), |
| 170 computeBlockSizeForFragment(constructConstraintSpace(200, -1), |
| 171 LayoutUnit(10))); |
| 172 EXPECT_EQ(LayoutUnit(120), |
| 173 computeBlockSizeForFragment(constructConstraintSpace(200, -1), |
| 174 LayoutUnit(120))); |
| 175 } |
| 176 |
| 162 TEST_F(NGLengthUtilsTest, testMargins) { | 177 TEST_F(NGLengthUtilsTest, testMargins) { |
| 163 style_->setMarginTop(Length(10, Percent)); | 178 style_->setMarginTop(Length(10, Percent)); |
| 164 style_->setMarginRight(Length(52, Fixed)); | 179 style_->setMarginRight(Length(52, Fixed)); |
| 165 style_->setMarginBottom(Length(Auto)); | 180 style_->setMarginBottom(Length(Auto)); |
| 166 style_->setMarginLeft(Length(11, Percent)); | 181 style_->setMarginLeft(Length(11, Percent)); |
| 167 | 182 |
| 168 NGConstraintSpace constraintSpace(constructConstraintSpace(200, 300)); | 183 NGConstraintSpace constraintSpace(constructConstraintSpace(200, 300)); |
| 169 | 184 |
| 170 NGBoxMargins margins = computeMargins(constraintSpace, *style_); | 185 NGBoxMargins margins = computeMargins(constraintSpace, *style_); |
| 171 | 186 |
| 172 EXPECT_EQ(LayoutUnit(20), margins.blockStart); | 187 EXPECT_EQ(LayoutUnit(20), margins.blockStart); |
| 173 EXPECT_EQ(LayoutUnit(52), margins.inlineEnd); | 188 EXPECT_EQ(LayoutUnit(52), margins.inlineEnd); |
| 174 EXPECT_EQ(LayoutUnit(), margins.blockEnd); | 189 EXPECT_EQ(LayoutUnit(), margins.blockEnd); |
| 175 EXPECT_EQ(LayoutUnit(22), margins.inlineStart); | 190 EXPECT_EQ(LayoutUnit(22), margins.inlineStart); |
| 176 } | 191 } |
| 177 | 192 |
| 178 } // namespace | 193 } // namespace |
| 179 } // namespace blink | 194 } // namespace blink |
| OLD | NEW |