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_constraint_space.h" | 5 #include "core/layout/ng/ng_constraint_space.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_layout_opportunity_iterator.h" | 9 #include "core/layout/ng/ng_layout_opportunity_iterator.h" |
9 #include "core/layout/ng/ng_physical_constraint_space.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 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 NGConstraintSpace* ConstructConstraintSpace(NGWritingMode writing_mode, | 16 NGConstraintSpace* ConstructConstraintSpace(NGWritingMode writing_mode, |
17 TextDirection direction, | 17 TextDirection direction, |
18 NGPhysicalSize size) { | 18 NGLogicalSize size) { |
19 return new NGConstraintSpace( | 19 return NGConstraintSpaceBuilder(writing_mode) |
20 writing_mode, direction, | 20 .SetTextDirection(direction) |
21 new NGPhysicalConstraintSpace( | 21 .SetAvailableSize(size) |
22 size, size, /* fixed_width */ true, /* fixed_height */ false, | 22 .SetPercentageResolutionSize(size) |
23 /* width_direction_triggers_scrollbar */ true, | 23 .SetIsFixedSizeInline(true) |
24 /* height_direction_triggers_scrollbar */ false, kFragmentNone, | 24 .SetIsInlineDirectionTriggersScrollbar(true) |
25 kFragmentColumn, /* is_new_fc */ false)); | 25 .SetFragmentationType(NGFragmentationType::kFragmentColumn) |
26 } | 26 .ToConstraintSpace(); |
27 | |
28 TEST(NGConstraintSpaceTest, WritingMode) { | |
29 NGPhysicalConstraintSpace* phy_space = new NGPhysicalConstraintSpace( | |
30 NGPhysicalSize(LayoutUnit(200), LayoutUnit(100)), | |
31 NGPhysicalSize(LayoutUnit(200), LayoutUnit(100)), /* fixed_width */ true, | |
32 /* fixed_height */ false, /* width_direction_triggers_scrollbar */ true, | |
33 /* height_direction_triggers_scrollbar */ false, kFragmentNone, | |
34 kFragmentColumn, /* is_new_fc */ false); | |
35 | |
36 NGConstraintSpace* horz_space = | |
37 new NGConstraintSpace(kHorizontalTopBottom, LTR, phy_space); | |
38 | |
39 NGConstraintSpace* vert_space = | |
40 new NGConstraintSpace(kVerticalRightLeft, LTR, phy_space); | |
41 | |
42 EXPECT_EQ(LayoutUnit(200), horz_space->AvailableSize().inline_size); | |
43 EXPECT_EQ(LayoutUnit(200), vert_space->AvailableSize().block_size); | |
44 | |
45 EXPECT_EQ(LayoutUnit(100), horz_space->AvailableSize().block_size); | |
46 EXPECT_EQ(LayoutUnit(100), vert_space->AvailableSize().inline_size); | |
47 | |
48 EXPECT_TRUE(horz_space->InlineTriggersScrollbar()); | |
49 EXPECT_TRUE(vert_space->BlockTriggersScrollbar()); | |
50 | |
51 EXPECT_FALSE(horz_space->BlockTriggersScrollbar()); | |
52 EXPECT_FALSE(vert_space->InlineTriggersScrollbar()); | |
53 | |
54 EXPECT_TRUE(horz_space->FixedInlineSize()); | |
55 EXPECT_TRUE(vert_space->FixedBlockSize()); | |
56 | |
57 EXPECT_FALSE(horz_space->FixedBlockSize()); | |
58 EXPECT_FALSE(vert_space->FixedInlineSize()); | |
59 | |
60 EXPECT_EQ(kFragmentColumn, horz_space->BlockFragmentationType()); | |
61 EXPECT_EQ(kFragmentNone, vert_space->BlockFragmentationType()); | |
62 } | 27 } |
63 | 28 |
64 static String OpportunityToString(const NGLayoutOpportunity& opportunity) { | 29 static String OpportunityToString(const NGLayoutOpportunity& opportunity) { |
65 return opportunity.IsEmpty() ? String("(empty)") : opportunity.ToString(); | 30 return opportunity.IsEmpty() ? String("(empty)") : opportunity.ToString(); |
66 } | 31 } |
67 | 32 |
68 TEST(NGConstraintSpaceTest, LayoutOpportunitiesNoExclusions) { | 33 TEST(NGConstraintSpaceTest, LayoutOpportunitiesNoExclusions) { |
69 NGPhysicalSize physical_size; | 34 NGLogicalSize size; |
70 physical_size.width = LayoutUnit(600); | 35 size.inline_size = LayoutUnit(600); |
71 physical_size.height = LayoutUnit(400); | 36 size.block_size = LayoutUnit(400); |
72 | 37 auto* space = ConstructConstraintSpace(kHorizontalTopBottom, LTR, size); |
73 auto* space = | |
74 ConstructConstraintSpace(kHorizontalTopBottom, LTR, physical_size); | |
75 auto* iterator = space->LayoutOpportunities(); | 38 auto* iterator = space->LayoutOpportunities(); |
76 | |
77 EXPECT_EQ("0,0 600x400", OpportunityToString(iterator->Next())); | 39 EXPECT_EQ("0,0 600x400", OpportunityToString(iterator->Next())); |
78 EXPECT_EQ("(empty)", OpportunityToString(iterator->Next())); | 40 EXPECT_EQ("(empty)", OpportunityToString(iterator->Next())); |
79 } | 41 } |
80 | 42 |
81 TEST(NGConstraintSpaceTest, LayoutOpportunitiesTopRightExclusion) { | 43 TEST(NGConstraintSpaceTest, LayoutOpportunitiesTopRightExclusion) { |
82 NGPhysicalSize physical_size; | 44 NGLogicalSize size; |
83 physical_size.width = LayoutUnit(600); | 45 size.inline_size = LayoutUnit(600); |
84 physical_size.height = LayoutUnit(400); | 46 size.block_size = LayoutUnit(400); |
85 | |
86 // Create a space with a 100x100 exclusion in the top right corner. | 47 // Create a space with a 100x100 exclusion in the top right corner. |
87 auto* space = | 48 auto* space = ConstructConstraintSpace(kHorizontalTopBottom, LTR, size); |
88 ConstructConstraintSpace(kHorizontalTopBottom, LTR, physical_size); | |
89 NGExclusion exclusion; | 49 NGExclusion exclusion; |
90 exclusion.rect.size = {/* inline_size */ LayoutUnit(100), | 50 exclusion.rect.size = {/* inline_size */ LayoutUnit(100), |
91 /* block_size */ LayoutUnit(100)}; | 51 /* block_size */ LayoutUnit(100)}; |
92 exclusion.rect.offset = {/* inline_offset */ LayoutUnit(500), | 52 exclusion.rect.offset = {/* inline_offset */ LayoutUnit(500), |
93 /* block_offset */ LayoutUnit(0)}; | 53 /* block_offset */ LayoutUnit(0)}; |
94 space->AddExclusion(exclusion); | 54 space->AddExclusion(exclusion); |
95 auto* iterator = space->LayoutOpportunities(); | 55 auto* iterator = space->LayoutOpportunities(); |
96 | |
97 // First opportunity should be to the left of the exclusion. | 56 // First opportunity should be to the left of the exclusion. |
98 EXPECT_EQ("0,0 500x400", OpportunityToString(iterator->Next())); | 57 EXPECT_EQ("0,0 500x400", OpportunityToString(iterator->Next())); |
99 | |
100 // Second opportunity should be below the exclusion. | 58 // Second opportunity should be below the exclusion. |
101 EXPECT_EQ("0,100 600x300", OpportunityToString(iterator->Next())); | 59 EXPECT_EQ("0,100 600x300", OpportunityToString(iterator->Next())); |
102 | |
103 // There should be no third opportunity. | 60 // There should be no third opportunity. |
104 EXPECT_EQ("(empty)", OpportunityToString(iterator->Next())); | 61 EXPECT_EQ("(empty)", OpportunityToString(iterator->Next())); |
105 } | 62 } |
106 | 63 |
107 TEST(NGConstraintSpaceTest, LayoutOpportunitiesTopLeftExclusion) { | 64 TEST(NGConstraintSpaceTest, LayoutOpportunitiesTopLeftExclusion) { |
108 NGPhysicalSize physical_size; | 65 NGLogicalSize size; |
109 physical_size.width = LayoutUnit(600); | 66 size.inline_size = LayoutUnit(600); |
110 physical_size.height = LayoutUnit(400); | 67 size.block_size = LayoutUnit(400); |
111 | |
112 // Create a space with a 100x100 exclusion in the top left corner. | 68 // Create a space with a 100x100 exclusion in the top left corner. |
113 auto* space = | 69 auto* space = ConstructConstraintSpace(kHorizontalTopBottom, LTR, size); |
114 ConstructConstraintSpace(kHorizontalTopBottom, LTR, physical_size); | |
115 NGExclusion exclusion; | 70 NGExclusion exclusion; |
116 exclusion.rect.size = {/* inline_size */ LayoutUnit(100), | 71 exclusion.rect.size = {/* inline_size */ LayoutUnit(100), |
117 /* block_size */ LayoutUnit(100)}; | 72 /* block_size */ LayoutUnit(100)}; |
118 exclusion.rect.offset = {/* inline_offset */ LayoutUnit(0), | 73 exclusion.rect.offset = {/* inline_offset */ LayoutUnit(0), |
119 /* block_offset */ LayoutUnit(0)}; | 74 /* block_offset */ LayoutUnit(0)}; |
120 space->AddExclusion(exclusion); | 75 space->AddExclusion(exclusion); |
121 | |
122 auto* iterator = space->LayoutOpportunities(); | 76 auto* iterator = space->LayoutOpportunities(); |
123 | |
124 // First opportunity should be to the right of the exclusion. | 77 // First opportunity should be to the right of the exclusion. |
125 EXPECT_EQ("100,0 500x400", OpportunityToString(iterator->Next())); | 78 EXPECT_EQ("100,0 500x400", OpportunityToString(iterator->Next())); |
126 | |
127 // Second opportunity should be below the exclusion. | 79 // Second opportunity should be below the exclusion. |
128 EXPECT_EQ("0,100 600x300", OpportunityToString(iterator->Next())); | 80 EXPECT_EQ("0,100 600x300", OpportunityToString(iterator->Next())); |
129 | |
130 // There should be no third opportunity. | 81 // There should be no third opportunity. |
131 EXPECT_EQ("(empty)", OpportunityToString(iterator->Next())); | 82 EXPECT_EQ("(empty)", OpportunityToString(iterator->Next())); |
132 } | 83 } |
133 | 84 |
134 // Verifies that Layout Opportunity iterator produces 7 layout opportunities | 85 // Verifies that Layout Opportunity iterator produces 7 layout opportunities |
135 // from 4 start points created by 2 CSS exclusions positioned in the middle of | 86 // from 4 start points created by 2 CSS exclusions positioned in the middle of |
136 // the main constraint space. | 87 // the main constraint space. |
137 // | 88 // |
138 // Test case visual representation: | 89 // Test case visual representation: |
139 // | 90 // |
140 // 100 200 300 400 500 | 91 // 100 200 300 400 500 |
141 // (1)--|----|-(2)-|----|----|-(3)-+ | 92 // (1)--|----|-(2)-|----|----|-(3)-+ |
142 // 50 | | | 93 // 50 | | |
143 // 100 | | | 94 // 100 | | |
144 // 150 | | | 95 // 150 | | |
145 // 200 | ****** | | 96 // 200 | ****** | |
146 // 250 | ****** | | 97 // 250 | ****** | |
147 // 300 (4) | | 98 // 300 (4) | |
148 // 350 | *** | | 99 // 350 | *** | |
149 // +-------------------------------+ | 100 // +-------------------------------+ |
150 // | 101 // |
151 // Expected: | 102 // Expected: |
152 // Layout opportunity iterator generates the next opportunities: | 103 // Layout opportunity iterator generates the next opportunities: |
153 // - 1st Start Point: 0,0 600x200; 0,0 150x400 | 104 // - 1st Start Point: 0,0 600x200; 0,0 150x400 |
154 // - 2nd Start Point: 250,0 350x350; 250,0 250x400 | 105 // - 2nd Start Point: 250,0 350x350; 250,0 250x400 |
155 // - 3rd Start Point: 550,0 50x400 | 106 // - 3rd Start Point: 550,0 50x400 |
156 // - 4th Start Point: 0,300 600x50; 0,300 500x100 | 107 // - 4th Start Point: 0,300 600x50; 0,300 500x100 |
157 TEST(NGConstraintSpaceTest, LayoutOpportunitiesTwoInMiddle) { | 108 TEST(NGConstraintSpaceTest, LayoutOpportunitiesTwoInMiddle) { |
158 NGPhysicalSize physical_size; | 109 NGLogicalSize size; |
159 physical_size.width = LayoutUnit(600); | 110 size.inline_size = LayoutUnit(600); |
160 physical_size.height = LayoutUnit(400); | 111 size.block_size = LayoutUnit(400); |
161 | 112 auto* space = ConstructConstraintSpace(kHorizontalTopBottom, LTR, size); |
162 auto* space = | |
163 ConstructConstraintSpace(kHorizontalTopBottom, LTR, physical_size); | |
164 // Add exclusions | 113 // Add exclusions |
165 NGExclusion exclusion1; | 114 NGExclusion exclusion1; |
166 exclusion1.rect.size = {/* inline_size */ LayoutUnit(100), | 115 exclusion1.rect.size = {/* inline_size */ LayoutUnit(100), |
167 /* block_size */ LayoutUnit(100)}; | 116 /* block_size */ LayoutUnit(100)}; |
168 exclusion1.rect.offset = {/* inline_offset */ LayoutUnit(150), | 117 exclusion1.rect.offset = {/* inline_offset */ LayoutUnit(150), |
169 /* block_offset */ LayoutUnit(200)}; | 118 /* block_offset */ LayoutUnit(200)}; |
170 space->AddExclusion(exclusion1); | 119 space->AddExclusion(exclusion1); |
171 NGExclusion exclusion2; | 120 NGExclusion exclusion2; |
172 exclusion2.rect.size = {/* inline_size */ LayoutUnit(50), | 121 exclusion2.rect.size = {/* inline_size */ LayoutUnit(50), |
173 /* block_size */ LayoutUnit(50)}; | 122 /* block_size */ LayoutUnit(50)}; |
174 exclusion2.rect.offset = {/* inline_offset */ LayoutUnit(500), | 123 exclusion2.rect.offset = {/* inline_offset */ LayoutUnit(500), |
175 /* block_offset */ LayoutUnit(350)}; | 124 /* block_offset */ LayoutUnit(350)}; |
176 space->AddExclusion(exclusion2); | 125 space->AddExclusion(exclusion2); |
177 | |
178 auto* iterator = space->LayoutOpportunities(); | 126 auto* iterator = space->LayoutOpportunities(); |
179 | |
180 // 1st Start point | 127 // 1st Start point |
181 EXPECT_EQ("0,0 600x200", OpportunityToString(iterator->Next())); | 128 EXPECT_EQ("0,0 600x200", OpportunityToString(iterator->Next())); |
182 EXPECT_EQ("0,0 150x400", OpportunityToString(iterator->Next())); | 129 EXPECT_EQ("0,0 150x400", OpportunityToString(iterator->Next())); |
183 | |
184 // 2nd Start point | 130 // 2nd Start point |
185 EXPECT_EQ("250,0 350x350", OpportunityToString(iterator->Next())); | 131 EXPECT_EQ("250,0 350x350", OpportunityToString(iterator->Next())); |
186 EXPECT_EQ("250,0 250x400", OpportunityToString(iterator->Next())); | 132 EXPECT_EQ("250,0 250x400", OpportunityToString(iterator->Next())); |
187 | |
188 // 3rd Start point | 133 // 3rd Start point |
189 EXPECT_EQ("550,0 50x400", OpportunityToString(iterator->Next())); | 134 EXPECT_EQ("550,0 50x400", OpportunityToString(iterator->Next())); |
190 | |
191 // 4th Start point | 135 // 4th Start point |
192 EXPECT_EQ("0,300 600x50", OpportunityToString(iterator->Next())); | 136 EXPECT_EQ("0,300 600x50", OpportunityToString(iterator->Next())); |
193 EXPECT_EQ("0,300 500x100", OpportunityToString(iterator->Next())); | 137 EXPECT_EQ("0,300 500x100", OpportunityToString(iterator->Next())); |
194 | |
195 // Iterator is exhausted. | 138 // Iterator is exhausted. |
196 EXPECT_EQ("(empty)", OpportunityToString(iterator->Next())); | 139 EXPECT_EQ("(empty)", OpportunityToString(iterator->Next())); |
197 } | 140 } |
198 | 141 |
199 // This test is the same as LayoutOpportunitiesTwoInMiddle with the only | 142 // This test is the same as LayoutOpportunitiesTwoInMiddle with the only |
200 // difference that NGLayoutOpportunityIterator takes 2 additional arguments: | 143 // difference that NGLayoutOpportunityIterator takes 2 additional arguments: |
201 // - origin_point that changes the iterator to return Layout Opportunities that | 144 // - origin_point that changes the iterator to return Layout Opportunities that |
202 // lay after the origin point. | 145 // lay after the origin point. |
203 // - leader_point that together with origin_point creates a temporary exclusion | 146 // - leader_point that together with origin_point creates a temporary exclusion |
204 // | 147 // |
205 // Expected: | 148 // Expected: |
206 // Layout opportunity iterator generates the next opportunities: | 149 // Layout opportunity iterator generates the next opportunities: |
207 // - 1st Start Point (0, 200): 350x150, 250x200 | 150 // - 1st Start Point (0, 200): 350x150, 250x200 |
208 // - 3rd Start Point (550, 200): 50x200 | 151 // - 3rd Start Point (550, 200): 50x200 |
209 // - 4th Start Point (0, 300): 600x50, 500x100 | 152 // - 4th Start Point (0, 300): 600x50, 500x100 |
210 // All other opportunities that are located before the origin point should be | 153 // All other opportunities that are located before the origin point should be |
211 // filtered out. | 154 // filtered out. |
212 TEST(NGConstraintSpaceTest, LayoutOpportunitiesTwoInMiddleWithOriginAndLeader) { | 155 TEST(NGConstraintSpaceTest, LayoutOpportunitiesTwoInMiddleWithOriginAndLeader) { |
213 NGPhysicalSize physical_size; | 156 NGLogicalSize size; |
214 physical_size.width = LayoutUnit(600); | 157 size.inline_size = LayoutUnit(600); |
215 physical_size.height = LayoutUnit(400); | 158 size.block_size = LayoutUnit(400); |
216 | 159 auto* space = ConstructConstraintSpace(kHorizontalTopBottom, LTR, size); |
217 auto* space = | |
218 ConstructConstraintSpace(kHorizontalTopBottom, LTR, physical_size); | |
219 // Add exclusions | 160 // Add exclusions |
220 NGExclusion exclusion1; | 161 NGExclusion exclusion1; |
221 exclusion1.rect.size = {/* inline_size */ LayoutUnit(100), | 162 exclusion1.rect.size = {/* inline_size */ LayoutUnit(100), |
222 /* block_size */ LayoutUnit(100)}; | 163 /* block_size */ LayoutUnit(100)}; |
223 exclusion1.rect.offset = {/* inline_offset */ LayoutUnit(150), | 164 exclusion1.rect.offset = {/* inline_offset */ LayoutUnit(150), |
224 /* block_offset */ LayoutUnit(200)}; | 165 /* block_offset */ LayoutUnit(200)}; |
225 space->AddExclusion(exclusion1); | 166 space->AddExclusion(exclusion1); |
226 NGExclusion exclusion2; | 167 NGExclusion exclusion2; |
227 exclusion2.rect.size = {/* inline_size */ LayoutUnit(50), | 168 exclusion2.rect.size = {/* inline_size */ LayoutUnit(50), |
228 /* block_size */ LayoutUnit(50)}; | 169 /* block_size */ LayoutUnit(50)}; |
229 exclusion2.rect.offset = {/* inline_offset */ LayoutUnit(500), | 170 exclusion2.rect.offset = {/* inline_offset */ LayoutUnit(500), |
230 /* block_offset */ LayoutUnit(350)}; | 171 /* block_offset */ LayoutUnit(350)}; |
231 space->AddExclusion(exclusion2); | 172 space->AddExclusion(exclusion2); |
232 | |
233 const NGLogicalOffset origin_point = {LayoutUnit(0), LayoutUnit(200)}; | 173 const NGLogicalOffset origin_point = {LayoutUnit(0), LayoutUnit(200)}; |
234 const NGLogicalOffset leader_point = {LayoutUnit(250), LayoutUnit(300)}; | 174 const NGLogicalOffset leader_point = {LayoutUnit(250), LayoutUnit(300)}; |
235 auto* iterator = | 175 auto* iterator = |
236 new NGLayoutOpportunityIterator(space, origin_point, leader_point); | 176 new NGLayoutOpportunityIterator(space, origin_point, leader_point); |
237 | |
238 // 1st Start Point | 177 // 1st Start Point |
239 EXPECT_EQ("250,200 350x150", OpportunityToString(iterator->Next())); | 178 EXPECT_EQ("250,200 350x150", OpportunityToString(iterator->Next())); |
240 EXPECT_EQ("250,200 250x200", OpportunityToString(iterator->Next())); | 179 EXPECT_EQ("250,200 250x200", OpportunityToString(iterator->Next())); |
241 | |
242 // 2nd Start Point | 180 // 2nd Start Point |
243 EXPECT_EQ("550,200 50x200", OpportunityToString(iterator->Next())); | 181 EXPECT_EQ("550,200 50x200", OpportunityToString(iterator->Next())); |
244 | |
245 // 3rd Start Point | 182 // 3rd Start Point |
246 EXPECT_EQ("0,300 600x50", OpportunityToString(iterator->Next())); | 183 EXPECT_EQ("0,300 600x50", OpportunityToString(iterator->Next())); |
247 EXPECT_EQ("0,300 500x100", OpportunityToString(iterator->Next())); | 184 EXPECT_EQ("0,300 500x100", OpportunityToString(iterator->Next())); |
248 | |
249 // Iterator is exhausted. | 185 // Iterator is exhausted. |
250 EXPECT_EQ("(empty)", OpportunityToString(iterator->Next())); | 186 EXPECT_EQ("(empty)", OpportunityToString(iterator->Next())); |
251 } | 187 } |
252 | |
253 // Verifies that Layout Opportunity iterator ignores the exclusion that is not | 188 // Verifies that Layout Opportunity iterator ignores the exclusion that is not |
254 // within constraint space. | 189 // within constraint space. |
255 // | 190 // |
256 // Test case visual representation: | 191 // Test case visual representation: |
257 // | 192 // |
258 // 100 200 300 400 500 | 193 // 100 200 300 400 500 |
259 // +----|----|----|----|----|----+ | 194 // +----|----|----|----|----|----+ |
260 // 50 | | | 195 // 50 | | |
261 // 100 | | | 196 // 100 | | |
262 // +-----------------------------+ | 197 // +-----------------------------+ |
263 // *** <- Exclusion | 198 // *** <- Exclusion |
264 // | 199 // |
265 // Expected: | 200 // Expected: |
266 // Layout opportunity iterator generates only one opportunity that equals to | 201 // Layout opportunity iterator generates only one opportunity that equals to |
267 // available constraint space, i.e. 0,0 600x200 | 202 // available constraint space, i.e. 0,0 600x200 |
268 TEST(NGConstraintSpaceTest, LayoutOpportunitiesWithOutOfBoundsExclusions) { | 203 TEST(NGConstraintSpaceTest, LayoutOpportunitiesWithOutOfBoundsExclusions) { |
269 NGPhysicalSize physical_size; | 204 NGLogicalSize size; |
270 physical_size.width = LayoutUnit(600); | 205 size.inline_size = LayoutUnit(600); |
271 physical_size.height = LayoutUnit(100); | 206 size.block_size = LayoutUnit(100); |
272 | 207 auto* space = ConstructConstraintSpace(kHorizontalTopBottom, LTR, size); |
273 auto* space = | |
274 ConstructConstraintSpace(kHorizontalTopBottom, LTR, physical_size); | |
275 NGExclusion exclusion; | 208 NGExclusion exclusion; |
276 exclusion.rect.size = {/* inline_size */ LayoutUnit(100), | 209 exclusion.rect.size = {/* inline_size */ LayoutUnit(100), |
277 /* block_size */ LayoutUnit(100)}; | 210 /* block_size */ LayoutUnit(100)}; |
278 exclusion.rect.offset = {/* inline_offset */ LayoutUnit(0), | 211 exclusion.rect.offset = {/* inline_offset */ LayoutUnit(0), |
279 /* block_offset */ LayoutUnit(150)}; | 212 /* block_offset */ LayoutUnit(150)}; |
280 space->AddExclusion(exclusion); | 213 space->AddExclusion(exclusion); |
281 | |
282 auto* iterator = space->LayoutOpportunities(); | 214 auto* iterator = space->LayoutOpportunities(); |
283 | |
284 EXPECT_EQ("0,0 600x100", OpportunityToString(iterator->Next())); | 215 EXPECT_EQ("0,0 600x100", OpportunityToString(iterator->Next())); |
285 EXPECT_EQ("(empty)", OpportunityToString(iterator->Next())); | 216 EXPECT_EQ("(empty)", OpportunityToString(iterator->Next())); |
286 } | 217 } |
287 | 218 |
288 } // namespace | 219 } // namespace |
289 } // namespace blink | 220 } // namespace blink |
OLD | NEW |