| 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_constraint_space_builder.h" | 8 #include "core/layout/ng/ng_constraint_space_builder.h" |
| 9 #include "core/layout/ng/ng_fragment.h" | 9 #include "core/layout/ng/ng_fragment.h" |
| 10 #include "core/layout/ng/ng_fragment_builder.h" | 10 #include "core/layout/ng/ng_fragment_builder.h" |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 } | 266 } |
| 267 | 267 |
| 268 TEST_F(NGLengthUtilsTest, testMargins) { | 268 TEST_F(NGLengthUtilsTest, testMargins) { |
| 269 style_->setMarginTop(Length(10, Percent)); | 269 style_->setMarginTop(Length(10, Percent)); |
| 270 style_->setMarginRight(Length(52, Fixed)); | 270 style_->setMarginRight(Length(52, Fixed)); |
| 271 style_->setMarginBottom(Length(Auto)); | 271 style_->setMarginBottom(Length(Auto)); |
| 272 style_->setMarginLeft(Length(11, Percent)); | 272 style_->setMarginLeft(Length(11, Percent)); |
| 273 | 273 |
| 274 NGConstraintSpace* constraintSpace(ConstructConstraintSpace(200, 300)); | 274 NGConstraintSpace* constraintSpace(ConstructConstraintSpace(200, 300)); |
| 275 | 275 |
| 276 NGBoxStrut margins = | 276 NGBoxStrut margins = ComputeMargins(*constraintSpace, *style_, |
| 277 ComputeMargins(*constraintSpace, *style_, kHorizontalTopBottom, LTR); | 277 kHorizontalTopBottom, TextDirection::Ltr); |
| 278 | 278 |
| 279 EXPECT_EQ(LayoutUnit(20), margins.block_start); | 279 EXPECT_EQ(LayoutUnit(20), margins.block_start); |
| 280 EXPECT_EQ(LayoutUnit(52), margins.inline_end); | 280 EXPECT_EQ(LayoutUnit(52), margins.inline_end); |
| 281 EXPECT_EQ(LayoutUnit(), margins.block_end); | 281 EXPECT_EQ(LayoutUnit(), margins.block_end); |
| 282 EXPECT_EQ(LayoutUnit(22), margins.inline_start); | 282 EXPECT_EQ(LayoutUnit(22), margins.inline_start); |
| 283 } | 283 } |
| 284 | 284 |
| 285 TEST_F(NGLengthUtilsTest, testBorders) { | 285 TEST_F(NGLengthUtilsTest, testBorders) { |
| 286 style_->setBorderTopWidth(1); | 286 style_->setBorderTopWidth(1); |
| 287 style_->setBorderRightWidth(2); | 287 style_->setBorderRightWidth(2); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 318 EXPECT_EQ(LayoutUnit(20), padding.inline_start); | 318 EXPECT_EQ(LayoutUnit(20), padding.inline_start); |
| 319 } | 319 } |
| 320 | 320 |
| 321 TEST_F(NGLengthUtilsTest, testAutoMargins) { | 321 TEST_F(NGLengthUtilsTest, testAutoMargins) { |
| 322 style_->setMarginRight(Length(Auto)); | 322 style_->setMarginRight(Length(Auto)); |
| 323 style_->setMarginLeft(Length(Auto)); | 323 style_->setMarginLeft(Length(Auto)); |
| 324 | 324 |
| 325 NGFragmentBuilder builder(NGPhysicalFragmentBase::kFragmentBox); | 325 NGFragmentBuilder builder(NGPhysicalFragmentBase::kFragmentBox); |
| 326 builder.SetInlineSize(LayoutUnit(150)); | 326 builder.SetInlineSize(LayoutUnit(150)); |
| 327 NGPhysicalFragment* physical_fragment = builder.ToFragment(); | 327 NGPhysicalFragment* physical_fragment = builder.ToFragment(); |
| 328 NGFragment* fragment = | 328 NGFragment* fragment = new NGFragment(kHorizontalTopBottom, |
| 329 new NGFragment(kHorizontalTopBottom, LTR, physical_fragment); | 329 TextDirection::Ltr, physical_fragment); |
| 330 | 330 |
| 331 NGConstraintSpace* constraint_space(ConstructConstraintSpace(200, 300)); | 331 NGConstraintSpace* constraint_space(ConstructConstraintSpace(200, 300)); |
| 332 | 332 |
| 333 NGBoxStrut margins; | 333 NGBoxStrut margins; |
| 334 ApplyAutoMargins(*constraint_space, *style_, *fragment, &margins); | 334 ApplyAutoMargins(*constraint_space, *style_, *fragment, &margins); |
| 335 | 335 |
| 336 EXPECT_EQ(LayoutUnit(), margins.block_start); | 336 EXPECT_EQ(LayoutUnit(), margins.block_start); |
| 337 EXPECT_EQ(LayoutUnit(), margins.block_end); | 337 EXPECT_EQ(LayoutUnit(), margins.block_end); |
| 338 EXPECT_EQ(LayoutUnit(25), margins.inline_start); | 338 EXPECT_EQ(LayoutUnit(25), margins.inline_start); |
| 339 EXPECT_EQ(LayoutUnit(25), margins.inline_end); | 339 EXPECT_EQ(LayoutUnit(25), margins.inline_end); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 EXPECT_EQ(125, GetUsedColumnWidth(4, 100, 10, 530)); | 422 EXPECT_EQ(125, GetUsedColumnWidth(4, 100, 10, 530)); |
| 423 EXPECT_EQ(4, GetUsedColumnCount(4, 100, 10, 530)); | 423 EXPECT_EQ(4, GetUsedColumnCount(4, 100, 10, 530)); |
| 424 EXPECT_EQ(100, GetUsedColumnWidth(6, 100, 10, 540)); | 424 EXPECT_EQ(100, GetUsedColumnWidth(6, 100, 10, 540)); |
| 425 EXPECT_EQ(5, GetUsedColumnCount(6, 100, 10, 540)); | 425 EXPECT_EQ(5, GetUsedColumnCount(6, 100, 10, 540)); |
| 426 EXPECT_EQ(100, GetUsedColumnWidth(0, 100, 10, 540)); | 426 EXPECT_EQ(100, GetUsedColumnWidth(0, 100, 10, 540)); |
| 427 EXPECT_EQ(5, GetUsedColumnCount(0, 100, 10, 540)); | 427 EXPECT_EQ(5, GetUsedColumnCount(0, 100, 10, 540)); |
| 428 } | 428 } |
| 429 | 429 |
| 430 } // namespace | 430 } // namespace |
| 431 } // namespace blink | 431 } // namespace blink |
| OLD | NEW |