| 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_fragment.h" | 8 #include "core/layout/ng/ng_fragment.h" |
| 9 #include "core/layout/ng/ng_fragment_builder.h" | 9 #include "core/layout/ng/ng_fragment_builder.h" |
| 10 #include "core/layout/ng/ng_physical_fragment.h" | 10 #include "core/layout/ng/ng_physical_fragment.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 bool fixed_inline = false, | 28 bool fixed_inline = false, |
| 29 bool fixed_block = false) { | 29 bool fixed_block = false) { |
| 30 NGConstraintSpace* derived_constraint_space = new NGConstraintSpace( | 30 NGConstraintSpace* derived_constraint_space = new NGConstraintSpace( |
| 31 HorizontalTopBottom, LeftToRight, | 31 HorizontalTopBottom, LeftToRight, |
| 32 NGLogicalSize(LayoutUnit(inline_size), LayoutUnit(block_size))); | 32 NGLogicalSize(LayoutUnit(inline_size), LayoutUnit(block_size))); |
| 33 derived_constraint_space->SetOverflowTriggersScrollbar(false, false); | 33 derived_constraint_space->SetOverflowTriggersScrollbar(false, false); |
| 34 derived_constraint_space->SetFixedSize(fixed_inline, fixed_block); | 34 derived_constraint_space->SetFixedSize(fixed_inline, fixed_block); |
| 35 return derived_constraint_space; | 35 return derived_constraint_space; |
| 36 } | 36 } |
| 37 | 37 |
| 38 LayoutUnit resolveInlineLength( | 38 LayoutUnit ResolveInlineLength( |
| 39 const Length& length, | 39 const Length& length, |
| 40 LengthResolveType type = LengthResolveType::ContentSize) { | 40 LengthResolveType type = LengthResolveType::ContentSize) { |
| 41 NGConstraintSpace* constraintSpace = ConstructConstraintSpace(200, 300); | 41 NGConstraintSpace* constraintSpace = ConstructConstraintSpace(200, 300); |
| 42 return ::blink::resolveInlineLength(*constraintSpace, *style_, length, | 42 return ::blink::ResolveInlineLength(*constraintSpace, *style_, length, |
| 43 type); | 43 type); |
| 44 } | 44 } |
| 45 | 45 |
| 46 LayoutUnit resolveBlockLength( | 46 LayoutUnit ResolveBlockLength( |
| 47 const Length& length, | 47 const Length& length, |
| 48 LengthResolveType type = LengthResolveType::ContentSize, | 48 LengthResolveType type = LengthResolveType::ContentSize, |
| 49 LayoutUnit contentSize = LayoutUnit()) { | 49 LayoutUnit contentSize = LayoutUnit()) { |
| 50 NGConstraintSpace* constraintSpace = ConstructConstraintSpace(200, 300); | 50 NGConstraintSpace* constraintSpace = ConstructConstraintSpace(200, 300); |
| 51 return ::blink::resolveBlockLength(*constraintSpace, *style_, length, | 51 return ::blink::ResolveBlockLength(*constraintSpace, *style_, length, |
| 52 contentSize, type); | 52 contentSize, type); |
| 53 } | 53 } |
| 54 | 54 |
| 55 LayoutUnit computeInlineSizeForFragment( | 55 LayoutUnit ComputeInlineSizeForFragment( |
| 56 const NGConstraintSpace* constraintSpace = | 56 const NGConstraintSpace* constraintSpace = |
| 57 ConstructConstraintSpace(200, 300)) { | 57 ConstructConstraintSpace(200, 300)) { |
| 58 return ::blink::computeInlineSizeForFragment(*constraintSpace, *style_); | 58 return ::blink::ComputeInlineSizeForFragment(*constraintSpace, *style_); |
| 59 } | 59 } |
| 60 | 60 |
| 61 LayoutUnit computeBlockSizeForFragment( | 61 LayoutUnit ComputeBlockSizeForFragment( |
| 62 const NGConstraintSpace* constraintSpace = ConstructConstraintSpace(200, | 62 const NGConstraintSpace* constraintSpace = ConstructConstraintSpace(200, |
| 63 300), | 63 300), |
| 64 LayoutUnit contentSize = LayoutUnit()) { | 64 LayoutUnit contentSize = LayoutUnit()) { |
| 65 return ::blink::computeBlockSizeForFragment(*constraintSpace, *style_, | 65 return ::blink::ComputeBlockSizeForFragment(*constraintSpace, *style_, |
| 66 contentSize); | 66 contentSize); |
| 67 } | 67 } |
| 68 | 68 |
| 69 RefPtr<ComputedStyle> style_; | 69 RefPtr<ComputedStyle> style_; |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 TEST_F(NGLengthUtilsTest, testResolveInlineLength) { | 72 TEST_F(NGLengthUtilsTest, testResolveInlineLength) { |
| 73 EXPECT_EQ(LayoutUnit(60), resolveInlineLength(Length(30, Percent))); | 73 EXPECT_EQ(LayoutUnit(60), ResolveInlineLength(Length(30, Percent))); |
| 74 EXPECT_EQ(LayoutUnit(150), resolveInlineLength(Length(150, Fixed))); | 74 EXPECT_EQ(LayoutUnit(150), ResolveInlineLength(Length(150, Fixed))); |
| 75 EXPECT_EQ(LayoutUnit(0), | 75 EXPECT_EQ(LayoutUnit(0), |
| 76 resolveInlineLength(Length(Auto), LengthResolveType::MinSize)); | 76 ResolveInlineLength(Length(Auto), LengthResolveType::MinSize)); |
| 77 EXPECT_EQ(LayoutUnit(200), resolveInlineLength(Length(Auto))); | 77 EXPECT_EQ(LayoutUnit(200), ResolveInlineLength(Length(Auto))); |
| 78 EXPECT_EQ(LayoutUnit(200), resolveInlineLength(Length(FillAvailable))); | 78 EXPECT_EQ(LayoutUnit(200), ResolveInlineLength(Length(FillAvailable))); |
| 79 | 79 |
| 80 EXPECT_EQ(LayoutUnit(200), | 80 EXPECT_EQ(LayoutUnit(200), |
| 81 resolveInlineLength(Length(Auto), LengthResolveType::MaxSize)); | 81 ResolveInlineLength(Length(Auto), LengthResolveType::MaxSize)); |
| 82 EXPECT_EQ(LayoutUnit(200), resolveInlineLength(Length(FillAvailable), | 82 EXPECT_EQ(LayoutUnit(200), ResolveInlineLength(Length(FillAvailable), |
| 83 LengthResolveType::MaxSize)); | 83 LengthResolveType::MaxSize)); |
| 84 } | 84 } |
| 85 | 85 |
| 86 TEST_F(NGLengthUtilsTest, testResolveBlockLength) { | 86 TEST_F(NGLengthUtilsTest, testResolveBlockLength) { |
| 87 EXPECT_EQ(LayoutUnit(90), resolveBlockLength(Length(30, Percent))); | 87 EXPECT_EQ(LayoutUnit(90), ResolveBlockLength(Length(30, Percent))); |
| 88 EXPECT_EQ(LayoutUnit(150), resolveBlockLength(Length(150, Fixed))); | 88 EXPECT_EQ(LayoutUnit(150), ResolveBlockLength(Length(150, Fixed))); |
| 89 EXPECT_EQ(LayoutUnit(0), resolveBlockLength(Length(Auto))); | 89 EXPECT_EQ(LayoutUnit(0), ResolveBlockLength(Length(Auto))); |
| 90 EXPECT_EQ(LayoutUnit(300), resolveBlockLength(Length(FillAvailable))); | 90 EXPECT_EQ(LayoutUnit(300), ResolveBlockLength(Length(FillAvailable))); |
| 91 | 91 |
| 92 EXPECT_EQ(LayoutUnit(0), | 92 EXPECT_EQ(LayoutUnit(0), |
| 93 resolveBlockLength(Length(Auto), LengthResolveType::ContentSize)); | 93 ResolveBlockLength(Length(Auto), LengthResolveType::ContentSize)); |
| 94 EXPECT_EQ(LayoutUnit(300), | 94 EXPECT_EQ(LayoutUnit(300), |
| 95 resolveBlockLength(Length(FillAvailable), | 95 ResolveBlockLength(Length(FillAvailable), |
| 96 LengthResolveType::ContentSize)); | 96 LengthResolveType::ContentSize)); |
| 97 } | 97 } |
| 98 | 98 |
| 99 TEST_F(NGLengthUtilsTest, testComputeInlineSizeForFragment) { | 99 TEST_F(NGLengthUtilsTest, testComputeInlineSizeForFragment) { |
| 100 style_->setLogicalWidth(Length(30, Percent)); | 100 style_->setLogicalWidth(Length(30, Percent)); |
| 101 EXPECT_EQ(LayoutUnit(60), computeInlineSizeForFragment()); | 101 EXPECT_EQ(LayoutUnit(60), ComputeInlineSizeForFragment()); |
| 102 | 102 |
| 103 style_->setLogicalWidth(Length(150, Fixed)); | 103 style_->setLogicalWidth(Length(150, Fixed)); |
| 104 EXPECT_EQ(LayoutUnit(150), computeInlineSizeForFragment()); | 104 EXPECT_EQ(LayoutUnit(150), ComputeInlineSizeForFragment()); |
| 105 | 105 |
| 106 style_->setLogicalWidth(Length(Auto)); | 106 style_->setLogicalWidth(Length(Auto)); |
| 107 EXPECT_EQ(LayoutUnit(200), computeInlineSizeForFragment()); | 107 EXPECT_EQ(LayoutUnit(200), ComputeInlineSizeForFragment()); |
| 108 | 108 |
| 109 style_->setLogicalWidth(Length(FillAvailable)); | 109 style_->setLogicalWidth(Length(FillAvailable)); |
| 110 EXPECT_EQ(LayoutUnit(200), computeInlineSizeForFragment()); | 110 EXPECT_EQ(LayoutUnit(200), ComputeInlineSizeForFragment()); |
| 111 | 111 |
| 112 style_->setLogicalWidth(Length(CalculationValue::create( | 112 style_->setLogicalWidth(Length(CalculationValue::create( |
| 113 PixelsAndPercent(100, -10), ValueRangeNonNegative))); | 113 PixelsAndPercent(100, -10), ValueRangeNonNegative))); |
| 114 EXPECT_EQ(LayoutUnit(80), computeInlineSizeForFragment()); | 114 EXPECT_EQ(LayoutUnit(80), ComputeInlineSizeForFragment()); |
| 115 | 115 |
| 116 NGConstraintSpace* constraintSpace = | 116 NGConstraintSpace* constraintSpace = |
| 117 ConstructConstraintSpace(120, 120, true, true); | 117 ConstructConstraintSpace(120, 120, true, true); |
| 118 style_->setLogicalWidth(Length(150, Fixed)); | 118 style_->setLogicalWidth(Length(150, Fixed)); |
| 119 EXPECT_EQ(LayoutUnit(120), computeInlineSizeForFragment(constraintSpace)); | 119 EXPECT_EQ(LayoutUnit(120), ComputeInlineSizeForFragment(constraintSpace)); |
| 120 | 120 |
| 121 style_->setLogicalWidth(Length(200, Fixed)); | 121 style_->setLogicalWidth(Length(200, Fixed)); |
| 122 style_->setMaxWidth(Length(80, Percent)); | 122 style_->setMaxWidth(Length(80, Percent)); |
| 123 EXPECT_EQ(LayoutUnit(160), computeInlineSizeForFragment()); | 123 EXPECT_EQ(LayoutUnit(160), ComputeInlineSizeForFragment()); |
| 124 | 124 |
| 125 style_->setLogicalWidth(Length(100, Fixed)); | 125 style_->setLogicalWidth(Length(100, Fixed)); |
| 126 style_->setMinWidth(Length(80, Percent)); | 126 style_->setMinWidth(Length(80, Percent)); |
| 127 EXPECT_EQ(LayoutUnit(160), computeInlineSizeForFragment()); | 127 EXPECT_EQ(LayoutUnit(160), ComputeInlineSizeForFragment()); |
| 128 | 128 |
| 129 style_ = ComputedStyle::create(); | 129 style_ = ComputedStyle::create(); |
| 130 style_->setMarginRight(Length(20, Fixed)); | 130 style_->setMarginRight(Length(20, Fixed)); |
| 131 EXPECT_EQ(LayoutUnit(180), computeInlineSizeForFragment()); | 131 EXPECT_EQ(LayoutUnit(180), ComputeInlineSizeForFragment()); |
| 132 | 132 |
| 133 style_->setLogicalWidth(Length(100, Fixed)); | 133 style_->setLogicalWidth(Length(100, Fixed)); |
| 134 style_->setPaddingLeft(Length(50, Fixed)); | 134 style_->setPaddingLeft(Length(50, Fixed)); |
| 135 EXPECT_EQ(LayoutUnit(150), computeInlineSizeForFragment()); | 135 EXPECT_EQ(LayoutUnit(150), ComputeInlineSizeForFragment()); |
| 136 | 136 |
| 137 style_->setBoxSizing(BoxSizingBorderBox); | 137 style_->setBoxSizing(BoxSizingBorderBox); |
| 138 EXPECT_EQ(LayoutUnit(100), computeInlineSizeForFragment()); | 138 EXPECT_EQ(LayoutUnit(100), ComputeInlineSizeForFragment()); |
| 139 | 139 |
| 140 // Content size should never be below zero, even with box-sizing: border-box | 140 // Content size should never be below zero, even with box-sizing: border-box |
| 141 // and a large padding... | 141 // and a large padding... |
| 142 style_->setPaddingLeft(Length(400, Fixed)); | 142 style_->setPaddingLeft(Length(400, Fixed)); |
| 143 EXPECT_EQ(LayoutUnit(400), computeInlineSizeForFragment()); | 143 EXPECT_EQ(LayoutUnit(400), ComputeInlineSizeForFragment()); |
| 144 | 144 |
| 145 // ...and the same goes for fill-available with a large padding. | 145 // ...and the same goes for fill-available with a large padding. |
| 146 style_->setLogicalWidth(Length(FillAvailable)); | 146 style_->setLogicalWidth(Length(FillAvailable)); |
| 147 EXPECT_EQ(LayoutUnit(400), computeInlineSizeForFragment()); | 147 EXPECT_EQ(LayoutUnit(400), ComputeInlineSizeForFragment()); |
| 148 | 148 |
| 149 // TODO(layout-ng): test {min,max}-content on max-width. | 149 // TODO(layout-ng): test {min,max}-content on max-width. |
| 150 } | 150 } |
| 151 | 151 |
| 152 TEST_F(NGLengthUtilsTest, testComputeBlockSizeForFragment) { | 152 TEST_F(NGLengthUtilsTest, testComputeBlockSizeForFragment) { |
| 153 style_->setLogicalHeight(Length(30, Percent)); | 153 style_->setLogicalHeight(Length(30, Percent)); |
| 154 EXPECT_EQ(LayoutUnit(90), computeBlockSizeForFragment()); | 154 EXPECT_EQ(LayoutUnit(90), ComputeBlockSizeForFragment()); |
| 155 | 155 |
| 156 style_->setLogicalHeight(Length(150, Fixed)); | 156 style_->setLogicalHeight(Length(150, Fixed)); |
| 157 EXPECT_EQ(LayoutUnit(150), computeBlockSizeForFragment()); | 157 EXPECT_EQ(LayoutUnit(150), ComputeBlockSizeForFragment()); |
| 158 | 158 |
| 159 style_->setLogicalHeight(Length(Auto)); | 159 style_->setLogicalHeight(Length(Auto)); |
| 160 EXPECT_EQ(LayoutUnit(0), computeBlockSizeForFragment()); | 160 EXPECT_EQ(LayoutUnit(0), ComputeBlockSizeForFragment()); |
| 161 | 161 |
| 162 style_->setLogicalHeight(Length(Auto)); | 162 style_->setLogicalHeight(Length(Auto)); |
| 163 EXPECT_EQ(LayoutUnit(120), | 163 EXPECT_EQ(LayoutUnit(120), |
| 164 computeBlockSizeForFragment(ConstructConstraintSpace(200, 300), | 164 ComputeBlockSizeForFragment(ConstructConstraintSpace(200, 300), |
| 165 LayoutUnit(120))); | 165 LayoutUnit(120))); |
| 166 | 166 |
| 167 style_->setLogicalHeight(Length(FillAvailable)); | 167 style_->setLogicalHeight(Length(FillAvailable)); |
| 168 EXPECT_EQ(LayoutUnit(300), computeBlockSizeForFragment()); | 168 EXPECT_EQ(LayoutUnit(300), ComputeBlockSizeForFragment()); |
| 169 | 169 |
| 170 style_->setLogicalHeight(Length(CalculationValue::create( | 170 style_->setLogicalHeight(Length(CalculationValue::create( |
| 171 PixelsAndPercent(100, -10), ValueRangeNonNegative))); | 171 PixelsAndPercent(100, -10), ValueRangeNonNegative))); |
| 172 EXPECT_EQ(LayoutUnit(70), computeBlockSizeForFragment()); | 172 EXPECT_EQ(LayoutUnit(70), ComputeBlockSizeForFragment()); |
| 173 | 173 |
| 174 NGConstraintSpace* constraintSpace = | 174 NGConstraintSpace* constraintSpace = |
| 175 ConstructConstraintSpace(200, 200, true, true); | 175 ConstructConstraintSpace(200, 200, true, true); |
| 176 style_->setLogicalHeight(Length(150, Fixed)); | 176 style_->setLogicalHeight(Length(150, Fixed)); |
| 177 EXPECT_EQ(LayoutUnit(200), computeBlockSizeForFragment(constraintSpace)); | 177 EXPECT_EQ(LayoutUnit(200), ComputeBlockSizeForFragment(constraintSpace)); |
| 178 | 178 |
| 179 style_->setLogicalHeight(Length(300, Fixed)); | 179 style_->setLogicalHeight(Length(300, Fixed)); |
| 180 style_->setMaxHeight(Length(80, Percent)); | 180 style_->setMaxHeight(Length(80, Percent)); |
| 181 EXPECT_EQ(LayoutUnit(240), computeBlockSizeForFragment()); | 181 EXPECT_EQ(LayoutUnit(240), ComputeBlockSizeForFragment()); |
| 182 | 182 |
| 183 style_->setLogicalHeight(Length(100, Fixed)); | 183 style_->setLogicalHeight(Length(100, Fixed)); |
| 184 style_->setMinHeight(Length(80, Percent)); | 184 style_->setMinHeight(Length(80, Percent)); |
| 185 EXPECT_EQ(LayoutUnit(240), computeBlockSizeForFragment()); | 185 EXPECT_EQ(LayoutUnit(240), ComputeBlockSizeForFragment()); |
| 186 | 186 |
| 187 style_ = ComputedStyle::create(); | 187 style_ = ComputedStyle::create(); |
| 188 style_->setMarginTop(Length(20, Fixed)); | 188 style_->setMarginTop(Length(20, Fixed)); |
| 189 style_->setLogicalHeight(Length(FillAvailable)); | 189 style_->setLogicalHeight(Length(FillAvailable)); |
| 190 EXPECT_EQ(LayoutUnit(280), computeBlockSizeForFragment()); | 190 EXPECT_EQ(LayoutUnit(280), ComputeBlockSizeForFragment()); |
| 191 | 191 |
| 192 style_->setLogicalHeight(Length(100, Fixed)); | 192 style_->setLogicalHeight(Length(100, Fixed)); |
| 193 style_->setPaddingBottom(Length(50, Fixed)); | 193 style_->setPaddingBottom(Length(50, Fixed)); |
| 194 EXPECT_EQ(LayoutUnit(150), computeBlockSizeForFragment()); | 194 EXPECT_EQ(LayoutUnit(150), ComputeBlockSizeForFragment()); |
| 195 | 195 |
| 196 style_->setBoxSizing(BoxSizingBorderBox); | 196 style_->setBoxSizing(BoxSizingBorderBox); |
| 197 EXPECT_EQ(LayoutUnit(100), computeBlockSizeForFragment()); | 197 EXPECT_EQ(LayoutUnit(100), ComputeBlockSizeForFragment()); |
| 198 | 198 |
| 199 // Content size should never be below zero, even with box-sizing: border-box | 199 // Content size should never be below zero, even with box-sizing: border-box |
| 200 // and a large padding... | 200 // and a large padding... |
| 201 style_->setPaddingBottom(Length(400, Fixed)); | 201 style_->setPaddingBottom(Length(400, Fixed)); |
| 202 EXPECT_EQ(LayoutUnit(400), computeBlockSizeForFragment()); | 202 EXPECT_EQ(LayoutUnit(400), ComputeBlockSizeForFragment()); |
| 203 | 203 |
| 204 // ...and the same goes for fill-available with a large padding. | 204 // ...and the same goes for fill-available with a large padding. |
| 205 style_->setLogicalHeight(Length(FillAvailable)); | 205 style_->setLogicalHeight(Length(FillAvailable)); |
| 206 EXPECT_EQ(LayoutUnit(400), computeBlockSizeForFragment()); | 206 EXPECT_EQ(LayoutUnit(400), ComputeBlockSizeForFragment()); |
| 207 | 207 |
| 208 // TODO(layout-ng): test {min,max}-content on max-height. | 208 // TODO(layout-ng): test {min,max}-content on max-height. |
| 209 } | 209 } |
| 210 | 210 |
| 211 TEST_F(NGLengthUtilsTest, testIndefinitePercentages) { | 211 TEST_F(NGLengthUtilsTest, testIndefinitePercentages) { |
| 212 style_->setMinHeight(Length(20, Fixed)); | 212 style_->setMinHeight(Length(20, Fixed)); |
| 213 style_->setHeight(Length(20, Percent)); | 213 style_->setHeight(Length(20, Percent)); |
| 214 | 214 |
| 215 EXPECT_EQ(NGSizeIndefinite, | 215 EXPECT_EQ(NGSizeIndefinite, |
| 216 computeBlockSizeForFragment(ConstructConstraintSpace(200, -1), | 216 ComputeBlockSizeForFragment(ConstructConstraintSpace(200, -1), |
| 217 LayoutUnit(-1))); | 217 LayoutUnit(-1))); |
| 218 EXPECT_EQ(LayoutUnit(20), | 218 EXPECT_EQ(LayoutUnit(20), |
| 219 computeBlockSizeForFragment(ConstructConstraintSpace(200, -1), | 219 ComputeBlockSizeForFragment(ConstructConstraintSpace(200, -1), |
| 220 LayoutUnit(10))); | 220 LayoutUnit(10))); |
| 221 EXPECT_EQ(LayoutUnit(120), | 221 EXPECT_EQ(LayoutUnit(120), |
| 222 computeBlockSizeForFragment(ConstructConstraintSpace(200, -1), | 222 ComputeBlockSizeForFragment(ConstructConstraintSpace(200, -1), |
| 223 LayoutUnit(120))); | 223 LayoutUnit(120))); |
| 224 } | 224 } |
| 225 | 225 |
| 226 TEST_F(NGLengthUtilsTest, testMargins) { | 226 TEST_F(NGLengthUtilsTest, testMargins) { |
| 227 style_->setMarginTop(Length(10, Percent)); | 227 style_->setMarginTop(Length(10, Percent)); |
| 228 style_->setMarginRight(Length(52, Fixed)); | 228 style_->setMarginRight(Length(52, Fixed)); |
| 229 style_->setMarginBottom(Length(Auto)); | 229 style_->setMarginBottom(Length(Auto)); |
| 230 style_->setMarginLeft(Length(11, Percent)); | 230 style_->setMarginLeft(Length(11, Percent)); |
| 231 | 231 |
| 232 NGConstraintSpace* constraintSpace(ConstructConstraintSpace(200, 300)); | 232 NGConstraintSpace* constraintSpace(ConstructConstraintSpace(200, 300)); |
| 233 | 233 |
| 234 NGBoxStrut margins = computeMargins(*constraintSpace, *style_, | 234 NGBoxStrut margins = ComputeMargins(*constraintSpace, *style_, |
| 235 HorizontalTopBottom, LeftToRight); | 235 HorizontalTopBottom, LeftToRight); |
| 236 | 236 |
| 237 EXPECT_EQ(LayoutUnit(20), margins.block_start); | 237 EXPECT_EQ(LayoutUnit(20), margins.block_start); |
| 238 EXPECT_EQ(LayoutUnit(52), margins.inline_end); | 238 EXPECT_EQ(LayoutUnit(52), margins.inline_end); |
| 239 EXPECT_EQ(LayoutUnit(), margins.block_end); | 239 EXPECT_EQ(LayoutUnit(), margins.block_end); |
| 240 EXPECT_EQ(LayoutUnit(22), margins.inline_start); | 240 EXPECT_EQ(LayoutUnit(22), margins.inline_start); |
| 241 } | 241 } |
| 242 | 242 |
| 243 TEST_F(NGLengthUtilsTest, testBorders) { | 243 TEST_F(NGLengthUtilsTest, testBorders) { |
| 244 style_->setBorderTopWidth(1); | 244 style_->setBorderTopWidth(1); |
| 245 style_->setBorderRightWidth(2); | 245 style_->setBorderRightWidth(2); |
| 246 style_->setBorderBottomWidth(3); | 246 style_->setBorderBottomWidth(3); |
| 247 style_->setBorderLeftWidth(4); | 247 style_->setBorderLeftWidth(4); |
| 248 style_->setBorderTopStyle(BorderStyleSolid); | 248 style_->setBorderTopStyle(BorderStyleSolid); |
| 249 style_->setBorderRightStyle(BorderStyleSolid); | 249 style_->setBorderRightStyle(BorderStyleSolid); |
| 250 style_->setBorderBottomStyle(BorderStyleSolid); | 250 style_->setBorderBottomStyle(BorderStyleSolid); |
| 251 style_->setBorderLeftStyle(BorderStyleSolid); | 251 style_->setBorderLeftStyle(BorderStyleSolid); |
| 252 style_->setWritingMode(LeftToRightWritingMode); | 252 style_->setWritingMode(LeftToRightWritingMode); |
| 253 | 253 |
| 254 NGBoxStrut borders = computeBorders(*style_); | 254 NGBoxStrut borders = ComputeBorders(*style_); |
| 255 | 255 |
| 256 EXPECT_EQ(LayoutUnit(4), borders.block_start); | 256 EXPECT_EQ(LayoutUnit(4), borders.block_start); |
| 257 EXPECT_EQ(LayoutUnit(3), borders.inline_end); | 257 EXPECT_EQ(LayoutUnit(3), borders.inline_end); |
| 258 EXPECT_EQ(LayoutUnit(2), borders.block_end); | 258 EXPECT_EQ(LayoutUnit(2), borders.block_end); |
| 259 EXPECT_EQ(LayoutUnit(1), borders.inline_start); | 259 EXPECT_EQ(LayoutUnit(1), borders.inline_start); |
| 260 } | 260 } |
| 261 | 261 |
| 262 TEST_F(NGLengthUtilsTest, testPadding) { | 262 TEST_F(NGLengthUtilsTest, testPadding) { |
| 263 style_->setPaddingTop(Length(10, Percent)); | 263 style_->setPaddingTop(Length(10, Percent)); |
| 264 style_->setPaddingRight(Length(52, Fixed)); | 264 style_->setPaddingRight(Length(52, Fixed)); |
| 265 style_->setPaddingBottom(Length(Auto)); | 265 style_->setPaddingBottom(Length(Auto)); |
| 266 style_->setPaddingLeft(Length(11, Percent)); | 266 style_->setPaddingLeft(Length(11, Percent)); |
| 267 style_->setWritingMode(RightToLeftWritingMode); | 267 style_->setWritingMode(RightToLeftWritingMode); |
| 268 | 268 |
| 269 NGConstraintSpace* constraintSpace(ConstructConstraintSpace(200, 300)); | 269 NGConstraintSpace* constraintSpace(ConstructConstraintSpace(200, 300)); |
| 270 | 270 |
| 271 NGBoxStrut padding = computePadding(*constraintSpace, *style_); | 271 NGBoxStrut padding = ComputePadding(*constraintSpace, *style_); |
| 272 | 272 |
| 273 EXPECT_EQ(LayoutUnit(52), padding.block_start); | 273 EXPECT_EQ(LayoutUnit(52), padding.block_start); |
| 274 EXPECT_EQ(LayoutUnit(), padding.inline_end); | 274 EXPECT_EQ(LayoutUnit(), padding.inline_end); |
| 275 EXPECT_EQ(LayoutUnit(22), padding.block_end); | 275 EXPECT_EQ(LayoutUnit(22), padding.block_end); |
| 276 EXPECT_EQ(LayoutUnit(20), padding.inline_start); | 276 EXPECT_EQ(LayoutUnit(20), padding.inline_start); |
| 277 } | 277 } |
| 278 | 278 |
| 279 TEST_F(NGLengthUtilsTest, testAutoMargins) { | 279 TEST_F(NGLengthUtilsTest, testAutoMargins) { |
| 280 style_->setMarginRight(Length(Auto)); | 280 style_->setMarginRight(Length(Auto)); |
| 281 style_->setMarginLeft(Length(Auto)); | 281 style_->setMarginLeft(Length(Auto)); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 style_->setMarginRight(Length(5000, Fixed)); | 315 style_->setMarginRight(Length(5000, Fixed)); |
| 316 margins = NGBoxStrut(); | 316 margins = NGBoxStrut(); |
| 317 margins.inline_end = LayoutUnit(5000); | 317 margins.inline_end = LayoutUnit(5000); |
| 318 ApplyAutoMargins(*constraint_space, *style_, *fragment, margins); | 318 ApplyAutoMargins(*constraint_space, *style_, *fragment, margins); |
| 319 EXPECT_EQ(LayoutUnit(0), margins.inline_start); | 319 EXPECT_EQ(LayoutUnit(0), margins.inline_start); |
| 320 EXPECT_EQ(LayoutUnit(5000), margins.inline_end); | 320 EXPECT_EQ(LayoutUnit(5000), margins.inline_end); |
| 321 } | 321 } |
| 322 | 322 |
| 323 } // namespace | 323 } // namespace |
| 324 } // namespace blink | 324 } // namespace blink |
| OLD | NEW |