Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(723)

Side by Side Diff: third_party/WebKit/Source/core/layout/ng/ng_constraint_space_builder_test.cc

Issue 2724133003: [LayoutNG] Switch NGConstraintSpace to being RefCounted. (Closed)
Patch Set: moar. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_constraint_space_builder.h" 5 #include "core/layout/ng/ng_constraint_space_builder.h"
6 #include "core/layout/ng/ng_units.h" 6 #include "core/layout/ng/ng_units.h"
7 7
8 #include "core/layout/LayoutTestHelper.h" 8 #include "core/layout/LayoutTestHelper.h"
9 9
10 namespace blink { 10 namespace blink {
(...skipping 15 matching lines...) Expand all
26 NGConstraintSpaceBuilder horizontal_builder(kHorizontalTopBottom); 26 NGConstraintSpaceBuilder horizontal_builder(kHorizontalTopBottom);
27 NGLogicalSize fixed_size{LayoutUnit(100), LayoutUnit(200)}; 27 NGLogicalSize fixed_size{LayoutUnit(100), LayoutUnit(200)};
28 NGLogicalSize indefinite_size{NGSizeIndefinite, NGSizeIndefinite}; 28 NGLogicalSize indefinite_size{NGSizeIndefinite, NGSizeIndefinite};
29 NGPhysicalSize icb_size{NGSizeIndefinite, LayoutUnit(51)}; 29 NGPhysicalSize icb_size{NGSizeIndefinite, LayoutUnit(51)};
30 30
31 horizontal_builder.SetInitialContainingBlockSize(icb_size); 31 horizontal_builder.SetInitialContainingBlockSize(icb_size);
32 horizontal_builder.SetAvailableSize(fixed_size); 32 horizontal_builder.SetAvailableSize(fixed_size);
33 horizontal_builder.SetPercentageResolutionSize(fixed_size); 33 horizontal_builder.SetPercentageResolutionSize(fixed_size);
34 34
35 NGConstraintSpaceBuilder vertical_builder( 35 NGConstraintSpaceBuilder vertical_builder(
36 horizontal_builder.ToConstraintSpace(kHorizontalTopBottom)); 36 horizontal_builder.ToConstraintSpace(kHorizontalTopBottom).get());
37 37
38 vertical_builder.SetAvailableSize(indefinite_size); 38 vertical_builder.SetAvailableSize(indefinite_size);
39 vertical_builder.SetPercentageResolutionSize(indefinite_size); 39 vertical_builder.SetPercentageResolutionSize(indefinite_size);
40 NGConstraintSpace* space = 40 RefPtr<NGConstraintSpace> space =
41 vertical_builder.ToConstraintSpace(kVerticalLeftRight); 41 vertical_builder.ToConstraintSpace(kVerticalLeftRight);
42 42
43 EXPECT_EQ(space->AvailableSize().inline_size, icb_size.height); 43 EXPECT_EQ(space->AvailableSize().inline_size, icb_size.height);
44 EXPECT_EQ(space->PercentageResolutionSize().inline_size, icb_size.height); 44 EXPECT_EQ(space->PercentageResolutionSize().inline_size, icb_size.height);
45 }; 45 };
46 46
47 // Asserts that indefinite inline length becomes initial containing 47 // Asserts that indefinite inline length becomes initial containing
48 // block height for vertical-lr inside horizontal document. 48 // block height for vertical-lr inside horizontal document.
49 TEST(NGConstraintSpaceBuilderTest, AvailableSizeFromVerticalICB) { 49 TEST(NGConstraintSpaceBuilderTest, AvailableSizeFromVerticalICB) {
50 NGConstraintSpaceBuilder horizontal_builder(kVerticalLeftRight); 50 NGConstraintSpaceBuilder horizontal_builder(kVerticalLeftRight);
51 NGLogicalSize fixed_size{LayoutUnit(100), LayoutUnit(200)}; 51 NGLogicalSize fixed_size{LayoutUnit(100), LayoutUnit(200)};
52 NGLogicalSize indefinite_size{NGSizeIndefinite, NGSizeIndefinite}; 52 NGLogicalSize indefinite_size{NGSizeIndefinite, NGSizeIndefinite};
53 NGPhysicalSize icb_size{LayoutUnit(51), NGSizeIndefinite}; 53 NGPhysicalSize icb_size{LayoutUnit(51), NGSizeIndefinite};
54 54
55 horizontal_builder.SetInitialContainingBlockSize(icb_size); 55 horizontal_builder.SetInitialContainingBlockSize(icb_size);
56 horizontal_builder.SetAvailableSize(fixed_size); 56 horizontal_builder.SetAvailableSize(fixed_size);
57 horizontal_builder.SetPercentageResolutionSize(fixed_size); 57 horizontal_builder.SetPercentageResolutionSize(fixed_size);
58 58
59 NGConstraintSpaceBuilder vertical_builder( 59 NGConstraintSpaceBuilder vertical_builder(
60 horizontal_builder.ToConstraintSpace(kVerticalLeftRight)); 60 horizontal_builder.ToConstraintSpace(kVerticalLeftRight).get());
61 61
62 vertical_builder.SetAvailableSize(indefinite_size); 62 vertical_builder.SetAvailableSize(indefinite_size);
63 vertical_builder.SetPercentageResolutionSize(indefinite_size); 63 vertical_builder.SetPercentageResolutionSize(indefinite_size);
64 NGConstraintSpace* space = 64 RefPtr<NGConstraintSpace> space =
65 vertical_builder.ToConstraintSpace(kHorizontalTopBottom); 65 vertical_builder.ToConstraintSpace(kHorizontalTopBottom);
66 66
67 EXPECT_EQ(space->AvailableSize().inline_size, icb_size.width); 67 EXPECT_EQ(space->AvailableSize().inline_size, icb_size.width);
68 EXPECT_EQ(space->PercentageResolutionSize().inline_size, icb_size.width); 68 EXPECT_EQ(space->PercentageResolutionSize().inline_size, icb_size.width);
69 }; 69 };
70 70
71 } // namespace 71 } // namespace
72 72
73 } // namespace blink 73 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698