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::kBorderStyleSolid); | 22 style_->SetBorderLeftStyle(EBorderStyle::kSolid); |
23 style_->SetBorderRightStyle(EBorderStyle::kBorderStyleSolid); | 23 style_->SetBorderRightStyle(EBorderStyle::kSolid); |
24 style_->SetBorderTopStyle(EBorderStyle::kBorderStyleSolid); | 24 style_->SetBorderTopStyle(EBorderStyle::kSolid); |
25 style_->SetBorderBottomStyle(EBorderStyle::kBorderStyleSolid); | 25 style_->SetBorderBottomStyle(EBorderStyle::kSolid); |
26 style_->SetBoxSizing(EBoxSizing::kBorderBox); | 26 style_->SetBoxSizing(EBoxSizing::kBorderBox); |
27 container_size_ = NGLogicalSize(LayoutUnit(200), LayoutUnit(300)); | 27 container_size_ = NGLogicalSize(LayoutUnit(200), LayoutUnit(300)); |
28 NGConstraintSpaceBuilder builder(kHorizontalTopBottom); | 28 NGConstraintSpaceBuilder builder(kHorizontalTopBottom); |
29 builder.SetAvailableSize(container_size_); | 29 builder.SetAvailableSize(container_size_); |
30 ltr_space_ = builder.SetTextDirection(TextDirection::kLtr) | 30 ltr_space_ = builder.SetTextDirection(TextDirection::kLtr) |
31 .ToConstraintSpace(kHorizontalTopBottom); | 31 .ToConstraintSpace(kHorizontalTopBottom); |
32 rtl_space_ = builder.SetTextDirection(TextDirection::kRtl) | 32 rtl_space_ = builder.SetTextDirection(TextDirection::kRtl) |
33 .ToConstraintSpace(kHorizontalTopBottom); | 33 .ToConstraintSpace(kHorizontalTopBottom); |
34 vertical_lr_space_ = builder.SetTextDirection(TextDirection::kLtr) | 34 vertical_lr_space_ = builder.SetTextDirection(TextDirection::kLtr) |
35 .ToConstraintSpace(kVerticalLeftRight); | 35 .ToConstraintSpace(kVerticalLeftRight); |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 // // Unspecified height becomes estimated, gets clamped to min. | 472 // // Unspecified height becomes estimated, gets clamped to min. |
473 SetVerticalStyle(NGAuto, NGAuto, NGAuto, NGAuto, NGAuto); | 473 SetVerticalStyle(NGAuto, NGAuto, NGAuto, NGAuto, NGAuto); |
474 auto_height = LayoutUnit(20); | 474 auto_height = LayoutUnit(20); |
475 ComputeFullAbsoluteWithChildBlockSize(*ltr_space_, *style_, static_position, | 475 ComputeFullAbsoluteWithChildBlockSize(*ltr_space_, *style_, static_position, |
476 auto_height, &p); | 476 auto_height, &p); |
477 EXPECT_EQ(min, p.size.width); | 477 EXPECT_EQ(min, p.size.width); |
478 } | 478 } |
479 | 479 |
480 } // namespace | 480 } // namespace |
481 } // namespace blink | 481 } // namespace blink |
OLD | NEW |