| 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_absolute_utils.h" | 5 #include "core/layout/ng/ng_absolute_utils.h" |
| 6 | 6 |
| 7 #include "core/layout/ng/ng_constraint_space_builder.h" | 7 #include "core/layout/ng/ng_constraint_space_builder.h" |
| 8 #include "core/layout/ng/ng_length_utils.h" | 8 #include "core/layout/ng/ng_length_utils.h" |
| 9 #include "core/style/ComputedStyle.h" | 9 #include "core/style/ComputedStyle.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 #define NGAuto LayoutUnit(-1) | 15 #define NGAuto LayoutUnit(-1) |
| 16 | 16 |
| 17 class NGAbsoluteUtilsTest : public ::testing::Test { | 17 class NGAbsoluteUtilsTest : public ::testing::Test { |
| 18 protected: | 18 protected: |
| 19 void SetUp() override { | 19 void SetUp() override { |
| 20 style_ = ComputedStyle::create(); | 20 style_ = ComputedStyle::create(); |
| 21 // If not set, border widths will always be 0. | 21 // If not set, border widths will always be 0. |
| 22 style_->setBorderLeftStyle(EBorderStyle::BorderStyleSolid); | 22 style_->setBorderLeftStyle(EBorderStyle::BorderStyleSolid); |
| 23 style_->setBorderRightStyle(EBorderStyle::BorderStyleSolid); | 23 style_->setBorderRightStyle(EBorderStyle::BorderStyleSolid); |
| 24 style_->setBorderTopStyle(EBorderStyle::BorderStyleSolid); | 24 style_->setBorderTopStyle(EBorderStyle::BorderStyleSolid); |
| 25 style_->setBorderBottomStyle(EBorderStyle::BorderStyleSolid); | 25 style_->setBorderBottomStyle(EBorderStyle::BorderStyleSolid); |
| 26 style_->setBoxSizing(EBoxSizing::BoxSizingBorderBox); | 26 style_->setBoxSizing(EBoxSizing::BoxSizingBorderBox); |
| 27 container_size_ = NGLogicalSize(LayoutUnit(200), LayoutUnit(300)); | 27 container_size_ = NGLogicalSize(LayoutUnit(200), LayoutUnit(300)); |
| 28 NGConstraintSpaceBuilder builder(HorizontalTopBottom); | 28 NGConstraintSpaceBuilder builder(kHorizontalTopBottom); |
| 29 ltr_space_ = new NGConstraintSpace( | 29 ltr_space_ = new NGConstraintSpace( |
| 30 HorizontalTopBottom, LTR, | 30 kHorizontalTopBottom, LTR, |
| 31 builder.SetAvailableSize(container_size_).ToConstraintSpace()); | 31 builder.SetAvailableSize(container_size_).ToConstraintSpace()); |
| 32 rtl_space_ = new NGConstraintSpace( | 32 rtl_space_ = new NGConstraintSpace( |
| 33 HorizontalTopBottom, RTL, | 33 kHorizontalTopBottom, RTL, |
| 34 builder.SetAvailableSize(container_size_).ToConstraintSpace()); | 34 builder.SetAvailableSize(container_size_).ToConstraintSpace()); |
| 35 vertical_lr_space_ = new NGConstraintSpace( | 35 vertical_lr_space_ = new NGConstraintSpace( |
| 36 VerticalLeftRight, LTR, | 36 kVerticalLeftRight, LTR, |
| 37 builder.SetAvailableSize(container_size_).ToConstraintSpace()); | 37 builder.SetAvailableSize(container_size_).ToConstraintSpace()); |
| 38 vertical_rl_space_ = new NGConstraintSpace( | 38 vertical_rl_space_ = new NGConstraintSpace( |
| 39 VerticalLeftRight, LTR, | 39 kVerticalLeftRight, LTR, |
| 40 builder.SetAvailableSize(container_size_).ToConstraintSpace()); | 40 builder.SetAvailableSize(container_size_).ToConstraintSpace()); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void SetHorizontalStyle(LayoutUnit left, | 43 void SetHorizontalStyle(LayoutUnit left, |
| 44 LayoutUnit margin_left, | 44 LayoutUnit margin_left, |
| 45 LayoutUnit width, | 45 LayoutUnit width, |
| 46 LayoutUnit margin_right, | 46 LayoutUnit margin_right, |
| 47 LayoutUnit right) { | 47 LayoutUnit right) { |
| 48 style_->setLeft(left == NGAuto ? Length(LengthType::Auto) | 48 style_->setLeft(left == NGAuto ? Length(LengthType::Auto) |
| 49 : Length(left.toInt(), LengthType::Fixed)); | 49 : Length(left.toInt(), LengthType::Fixed)); |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 // Rule 6: height is unknown. | 383 // Rule 6: height is unknown. |
| 384 SetVerticalStyle(top, margin_top, NGAuto, margin_bottom, bottom); | 384 SetVerticalStyle(top, margin_top, NGAuto, margin_bottom, bottom); |
| 385 EXPECT_EQ(AbsoluteNeedsChildBlockSize(*style_), false); | 385 EXPECT_EQ(AbsoluteNeedsChildBlockSize(*style_), false); |
| 386 auto_height.reset(); | 386 auto_height.reset(); |
| 387 ComputeFullAbsoluteWithChildBlockSize(*ltr_space_, *style_, auto_height, &p); | 387 ComputeFullAbsoluteWithChildBlockSize(*ltr_space_, *style_, auto_height, &p); |
| 388 EXPECT_EQ(height, p.size.height); | 388 EXPECT_EQ(height, p.size.height); |
| 389 } | 389 } |
| 390 | 390 |
| 391 } // namespace | 391 } // namespace |
| 392 } // namespace blink | 392 } // namespace blink |
| OLD | NEW |