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" |
11 #include "core/layout/ng/ng_units.h" | 11 #include "core/layout/ng/ng_units.h" |
12 #include "core/style/ComputedStyle.h" | 12 #include "core/style/ComputedStyle.h" |
13 #include "platform/CalculationValue.h" | 13 #include "platform/CalculationValue.h" |
14 #include "platform/LayoutUnit.h" | 14 #include "platform/LayoutUnit.h" |
15 #include "platform/Length.h" | 15 #include "platform/Length.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "wtf/RefPtr.h" | 17 #include "wtf/RefPtr.h" |
18 | 18 |
19 namespace blink { | 19 namespace blink { |
20 namespace { | 20 namespace { |
21 | 21 |
22 class NGLengthUtilsTest : public ::testing::Test { | 22 class NGLengthUtilsTest : public ::testing::Test { |
23 protected: | 23 protected: |
24 void SetUp() override { style_ = ComputedStyle::create(); } | 24 void SetUp() override { style_ = ComputedStyle::create(); } |
25 | 25 |
26 static NGConstraintSpace* ConstructConstraintSpace(int inline_size, | 26 static NGConstraintSpace* ConstructConstraintSpace(int inline_size, |
27 int block_size, | 27 int block_size, |
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 return new NGConstraintSpace( |
31 HorizontalTopBottom, LeftToRight, | 31 HorizontalTopBottom, LeftToRight, |
32 NGLogicalSize(LayoutUnit(inline_size), LayoutUnit(block_size))); | 32 new NGPhysicalConstraintSpace( |
33 derived_constraint_space->SetOverflowTriggersScrollbar(false, false); | 33 NGPhysicalSize(LayoutUnit(inline_size), LayoutUnit(block_size)), |
34 derived_constraint_space->SetFixedSize(fixed_inline, fixed_block); | 34 fixed_inline, fixed_block, false, false, FragmentNone, FragmentNone, |
35 return derived_constraint_space; | 35 false)); |
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 |
(...skipping 269 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 |