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_constraint_space_builder.h" |
9 #include "core/layout/ng/ng_layout_opportunity_iterator.h" | 9 #include "core/layout/ng/ng_layout_opportunity_iterator.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 .ToConstraintSpace(writing_mode); | 29 .ToConstraintSpace(writing_mode); |
30 } | 30 } |
31 | 31 |
32 TEST(NGConstraintSpaceTest, LayoutOpportunitiesNoExclusions) { | 32 TEST(NGConstraintSpaceTest, LayoutOpportunitiesNoExclusions) { |
33 NGLogicalSize size; | 33 NGLogicalSize size; |
34 size.inline_size = LayoutUnit(600); | 34 size.inline_size = LayoutUnit(600); |
35 size.block_size = LayoutUnit(400); | 35 size.block_size = LayoutUnit(400); |
36 RefPtr<NGConstraintSpace> space = | 36 RefPtr<NGConstraintSpace> space = |
37 ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::kLtr, size); | 37 ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::kLtr, size); |
38 | 38 |
39 NGLayoutOpportunityIterator iterator(space.Get(), space->AvailableSize()); | 39 NGLayoutOpportunityIterator iterator( |
| 40 space->Exclusions().get(), space->AvailableSize(), NGLogicalOffset()); |
40 // 600x400 at (0,0) | 41 // 600x400 at (0,0) |
41 NGLayoutOpportunity opp1 = {{}, {LayoutUnit(600), LayoutUnit(400)}}; | 42 NGLayoutOpportunity opp1 = {{}, {LayoutUnit(600), LayoutUnit(400)}}; |
42 EXPECT_EQ(opp1, iterator.Next()); | 43 EXPECT_EQ(opp1, iterator.Next()); |
43 | 44 |
44 EXPECT_EQ(NGLayoutOpportunity(), iterator.Next()); | 45 EXPECT_EQ(NGLayoutOpportunity(), iterator.Next()); |
45 } | 46 } |
46 | 47 |
47 TEST(NGConstraintSpaceTest, LayoutOpportunitiesTopRightExclusion) { | 48 TEST(NGConstraintSpaceTest, LayoutOpportunitiesTopRightExclusion) { |
48 NGLogicalSize size; | 49 NGLogicalSize size; |
49 size.inline_size = LayoutUnit(600); | 50 size.inline_size = LayoutUnit(600); |
50 size.block_size = LayoutUnit(400); | 51 size.block_size = LayoutUnit(400); |
51 // Create a space with a 100x100 exclusion in the top right corner. | 52 // Create a space with a 100x100 exclusion in the top right corner. |
52 RefPtr<NGConstraintSpace> space = | 53 RefPtr<NGConstraintSpace> space = |
53 ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::kLtr, size); | 54 ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::kLtr, size); |
54 NGExclusion exclusion; | 55 NGExclusion exclusion; |
55 exclusion.rect.size = {LayoutUnit(100), LayoutUnit(100)}; | 56 exclusion.rect.size = {LayoutUnit(100), LayoutUnit(100)}; |
56 exclusion.rect.offset = {LayoutUnit(500), LayoutUnit()}; | 57 exclusion.rect.offset = {LayoutUnit(500), LayoutUnit()}; |
57 space->AddExclusion(exclusion); | 58 space->AddExclusion(exclusion); |
58 | 59 |
59 NGLayoutOpportunityIterator iterator(space.Get(), space->AvailableSize()); | 60 NGLayoutOpportunityIterator iterator( |
| 61 space->Exclusions().get(), space->AvailableSize(), NGLogicalOffset()); |
60 | 62 |
61 // First opportunity should be to the left of the exclusion: 500x400 at (0,0) | 63 // First opportunity should be to the left of the exclusion: 500x400 at (0,0) |
62 NGLayoutOpportunity opp1 = {{}, {LayoutUnit(500), LayoutUnit(400)}}; | 64 NGLayoutOpportunity opp1 = {{}, {LayoutUnit(500), LayoutUnit(400)}}; |
63 EXPECT_EQ(opp1, iterator.Next()); | 65 EXPECT_EQ(opp1, iterator.Next()); |
64 | 66 |
65 // Second opportunity should be below the exclusion: 600x300 at (0,100) | 67 // Second opportunity should be below the exclusion: 600x300 at (0,100) |
66 NGLayoutOpportunity opp2 = {{LayoutUnit(), LayoutUnit(100)}, | 68 NGLayoutOpportunity opp2 = {{LayoutUnit(), LayoutUnit(100)}, |
67 {LayoutUnit(600), LayoutUnit(300)}}; | 69 {LayoutUnit(600), LayoutUnit(300)}}; |
68 EXPECT_EQ(opp2, iterator.Next()); | 70 EXPECT_EQ(opp2, iterator.Next()); |
69 | 71 |
70 EXPECT_EQ(NGLayoutOpportunity(), iterator.Next()); | 72 EXPECT_EQ(NGLayoutOpportunity(), iterator.Next()); |
71 } | 73 } |
72 | 74 |
73 TEST(NGConstraintSpaceTest, LayoutOpportunitiesTopLeftExclusion) { | 75 TEST(NGConstraintSpaceTest, LayoutOpportunitiesTopLeftExclusion) { |
74 NGLogicalSize size; | 76 NGLogicalSize size; |
75 size.inline_size = LayoutUnit(600); | 77 size.inline_size = LayoutUnit(600); |
76 size.block_size = LayoutUnit(400); | 78 size.block_size = LayoutUnit(400); |
77 // Create a space with a 100x100 exclusion in the top left corner. | 79 // Create a space with a 100x100 exclusion in the top left corner. |
78 RefPtr<NGConstraintSpace> space = | 80 RefPtr<NGConstraintSpace> space = |
79 ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::kLtr, size); | 81 ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::kLtr, size); |
80 NGExclusion exclusion; | 82 NGExclusion exclusion; |
81 exclusion.rect.size = {LayoutUnit(100), LayoutUnit(100)}; | 83 exclusion.rect.size = {LayoutUnit(100), LayoutUnit(100)}; |
82 space->AddExclusion(exclusion); | 84 space->AddExclusion(exclusion); |
83 | 85 |
84 NGLayoutOpportunityIterator iterator(space.Get(), space->AvailableSize()); | 86 NGLayoutOpportunityIterator iterator( |
| 87 space->Exclusions().get(), space->AvailableSize(), NGLogicalOffset()); |
85 // First opportunity should be to the right of the exclusion: | 88 // First opportunity should be to the right of the exclusion: |
86 // 500x400 at (100, 0) | 89 // 500x400 at (100, 0) |
87 NGLayoutOpportunity opp1 = {{LayoutUnit(100), LayoutUnit()}, | 90 NGLayoutOpportunity opp1 = {{LayoutUnit(100), LayoutUnit()}, |
88 {LayoutUnit(500), LayoutUnit(400)}}; | 91 {LayoutUnit(500), LayoutUnit(400)}}; |
89 EXPECT_EQ(opp1, iterator.Next()); | 92 EXPECT_EQ(opp1, iterator.Next()); |
90 | 93 |
91 // Second opportunity should be below the exclusion: 600x300 at (0,100) | 94 // Second opportunity should be below the exclusion: 600x300 at (0,100) |
92 NGLayoutOpportunity opp2 = {{LayoutUnit(), LayoutUnit(100)}, | 95 NGLayoutOpportunity opp2 = {{LayoutUnit(), LayoutUnit(100)}, |
93 {LayoutUnit(600), LayoutUnit(300)}}; | 96 {LayoutUnit(600), LayoutUnit(300)}}; |
94 EXPECT_EQ(opp2, iterator.Next()); | 97 EXPECT_EQ(opp2, iterator.Next()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 // Add exclusions | 131 // Add exclusions |
129 NGExclusion exclusion1; | 132 NGExclusion exclusion1; |
130 exclusion1.rect.size = {LayoutUnit(100), LayoutUnit(100)}; | 133 exclusion1.rect.size = {LayoutUnit(100), LayoutUnit(100)}; |
131 exclusion1.rect.offset = {LayoutUnit(150), LayoutUnit(200)}; | 134 exclusion1.rect.offset = {LayoutUnit(150), LayoutUnit(200)}; |
132 space->AddExclusion(exclusion1); | 135 space->AddExclusion(exclusion1); |
133 NGExclusion exclusion2; | 136 NGExclusion exclusion2; |
134 exclusion2.rect.size = {LayoutUnit(50), LayoutUnit(50)}; | 137 exclusion2.rect.size = {LayoutUnit(50), LayoutUnit(50)}; |
135 exclusion2.rect.offset = {LayoutUnit(500), LayoutUnit(350)}; | 138 exclusion2.rect.offset = {LayoutUnit(500), LayoutUnit(350)}; |
136 space->AddExclusion(exclusion2); | 139 space->AddExclusion(exclusion2); |
137 | 140 |
138 NGLayoutOpportunityIterator iterator(space.Get(), space->AvailableSize()); | 141 NGLayoutOpportunityIterator iterator( |
| 142 space->Exclusions().get(), space->AvailableSize(), NGLogicalOffset()); |
139 NGLogicalOffset start_point1; | 143 NGLogicalOffset start_point1; |
140 // 600x200 at (0,0) | 144 // 600x200 at (0,0) |
141 NGLayoutOpportunity opp1 = {start_point1, {LayoutUnit(600), LayoutUnit(200)}}; | 145 NGLayoutOpportunity opp1 = {start_point1, {LayoutUnit(600), LayoutUnit(200)}}; |
142 EXPECT_EQ(opp1, (iterator.Next())); | 146 EXPECT_EQ(opp1, (iterator.Next())); |
143 // 150x400 at (0,0) | 147 // 150x400 at (0,0) |
144 NGLayoutOpportunity opp2 = {start_point1, {LayoutUnit(150), LayoutUnit(400)}}; | 148 NGLayoutOpportunity opp2 = {start_point1, {LayoutUnit(150), LayoutUnit(400)}}; |
145 EXPECT_EQ(opp2, (iterator.Next())); | 149 EXPECT_EQ(opp2, (iterator.Next())); |
146 | 150 |
147 NGLogicalOffset start_point2 = {LayoutUnit(250), LayoutUnit()}; | 151 NGLogicalOffset start_point2 = {LayoutUnit(250), LayoutUnit()}; |
148 // 350x350 at (250,0) | 152 // 350x350 at (250,0) |
(...skipping 12 matching lines...) Expand all Loading... |
161 // 600x50 at (0,300) | 165 // 600x50 at (0,300) |
162 NGLayoutOpportunity opp6 = {start_point4, {LayoutUnit(600), LayoutUnit(50)}}; | 166 NGLayoutOpportunity opp6 = {start_point4, {LayoutUnit(600), LayoutUnit(50)}}; |
163 EXPECT_EQ(opp6, (iterator.Next())); | 167 EXPECT_EQ(opp6, (iterator.Next())); |
164 // 500x100 at (0,300) | 168 // 500x100 at (0,300) |
165 NGLayoutOpportunity opp7 = {start_point4, {LayoutUnit(500), LayoutUnit(100)}}; | 169 NGLayoutOpportunity opp7 = {start_point4, {LayoutUnit(500), LayoutUnit(100)}}; |
166 EXPECT_EQ(opp7, (iterator.Next())); | 170 EXPECT_EQ(opp7, (iterator.Next())); |
167 | 171 |
168 EXPECT_EQ(NGLayoutOpportunity(), iterator.Next()); | 172 EXPECT_EQ(NGLayoutOpportunity(), iterator.Next()); |
169 } | 173 } |
170 | 174 |
171 // This test is the same as LayoutOpportunitiesTwoInMiddle with the only | |
172 // difference that NGLayoutOpportunityIterator takes 2 additional arguments: | |
173 // - origin_point that changes the iterator to return Layout Opportunities that | |
174 // lay after the origin point. | |
175 // - leader_point that together with origin_point creates a temporary exclusion | |
176 // | |
177 // Expected: | |
178 // Layout opportunity iterator generates the next opportunities: | |
179 // - 1st Start Point (0, 200): 350x150, 250x400 | |
180 // - 3rd Start Point (550, 200): 50x400 | |
181 // - 4th Start Point (0, 300): 600x50, 500x300 | |
182 // - 5th Start Point (0, 400): 600x200 | |
183 // All other opportunities that are located before the origin point should be | |
184 // filtered out. | |
185 TEST(NGConstraintSpaceTest, LayoutOpportunitiesTwoInMiddleWithOriginAndLeader) { | |
186 NGLogicalSize size; | |
187 size.inline_size = LayoutUnit(600); | |
188 size.block_size = LayoutUnit(400); | |
189 RefPtr<NGConstraintSpace> space = | |
190 ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::kLtr, size); | |
191 // Add exclusions | |
192 NGExclusion exclusion1; | |
193 exclusion1.rect.size = {LayoutUnit(100), LayoutUnit(100)}; | |
194 exclusion1.rect.offset = {LayoutUnit(150), LayoutUnit(200)}; | |
195 space->AddExclusion(exclusion1); | |
196 NGExclusion exclusion2; | |
197 exclusion2.rect.size = {LayoutUnit(50), LayoutUnit(50)}; | |
198 exclusion2.rect.offset = {LayoutUnit(500), LayoutUnit(350)}; | |
199 space->AddExclusion(exclusion2); | |
200 | |
201 const NGLogicalOffset origin_point = {LayoutUnit(), LayoutUnit(200)}; | |
202 const NGLogicalOffset leader_point = {LayoutUnit(250), LayoutUnit(300)}; | |
203 NGLayoutOpportunityIterator iterator(space.Get(), space->AvailableSize(), | |
204 origin_point, leader_point); | |
205 | |
206 NGLogicalOffset start_point1 = {LayoutUnit(250), LayoutUnit(200)}; | |
207 // 350x150 at (250,200) | |
208 NGLayoutOpportunity opp1 = {start_point1, {LayoutUnit(350), LayoutUnit(150)}}; | |
209 EXPECT_EQ(opp1, iterator.Next()); | |
210 // 250x400 at (250,200) | |
211 NGLayoutOpportunity opp2 = {start_point1, {LayoutUnit(250), LayoutUnit(400)}}; | |
212 EXPECT_EQ(opp2, iterator.Next()); | |
213 | |
214 NGLogicalOffset start_point2 = {LayoutUnit(550), LayoutUnit(200)}; | |
215 // 50x400 at (550,200) | |
216 NGLayoutOpportunity opp3 = {start_point2, {LayoutUnit(50), LayoutUnit(400)}}; | |
217 EXPECT_EQ(opp3, iterator.Next()); | |
218 | |
219 NGLogicalOffset start_point3 = {LayoutUnit(), LayoutUnit(300)}; | |
220 // 600x50 at (0,300) | |
221 NGLayoutOpportunity opp4 = {start_point3, {LayoutUnit(600), LayoutUnit(50)}}; | |
222 EXPECT_EQ(opp4, iterator.Next()); | |
223 // 500x300 at (0,300) | |
224 NGLayoutOpportunity opp5 = {start_point3, {LayoutUnit(500), LayoutUnit(300)}}; | |
225 EXPECT_EQ(opp5, iterator.Next()); | |
226 | |
227 // 4th Start Point | |
228 NGLogicalOffset start_point4 = {LayoutUnit(), LayoutUnit(400)}; | |
229 // 600x200 at (0,400) | |
230 NGLayoutOpportunity opp6 = {start_point4, {LayoutUnit(600), LayoutUnit(200)}}; | |
231 EXPECT_EQ(opp6, iterator.Next()); | |
232 | |
233 // TODO(glebl): The opportunity below should not be generated. | |
234 EXPECT_EQ("350x200 at (250,400)", iterator.Next().ToString()); | |
235 | |
236 EXPECT_EQ(NGLayoutOpportunity(), iterator.Next()); | |
237 } | |
238 | |
239 // Verifies that Layout Opportunity iterator ignores the exclusion that is not | 175 // Verifies that Layout Opportunity iterator ignores the exclusion that is not |
240 // within constraint space. | 176 // within constraint space. |
241 // | 177 // |
242 // Test case visual representation: | 178 // Test case visual representation: |
243 // | 179 // |
244 // 100 200 300 400 500 | 180 // 100 200 300 400 500 |
245 // +----|----|----|----|----|----+ | 181 // +----|----|----|----|----|----+ |
246 // 50 | | | 182 // 50 | | |
247 // 100 | | | 183 // 100 | | |
248 // +-----------------------------+ | 184 // +-----------------------------+ |
249 // *** <- Exclusion | 185 // *** <- Exclusion |
250 // | 186 // |
251 // Expected: | 187 // Expected: |
252 // Layout opportunity iterator generates only one opportunity that equals to | 188 // Layout opportunity iterator generates only one opportunity that equals to |
253 // available constraint space, i.e. 0,0 600x200 | 189 // available constraint space, i.e. 0,0 600x200 |
254 TEST(NGConstraintSpaceTest, LayoutOpportunitiesWithOutOfBoundsExclusions) { | 190 TEST(NGConstraintSpaceTest, LayoutOpportunitiesWithOutOfBoundsExclusions) { |
255 NGLogicalSize size = {LayoutUnit(600), LayoutUnit(100)}; | 191 NGLogicalSize size = {LayoutUnit(600), LayoutUnit(100)}; |
256 RefPtr<NGConstraintSpace> space = | 192 RefPtr<NGConstraintSpace> space = |
257 ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::kLtr, size); | 193 ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::kLtr, size); |
258 NGExclusion exclusion; | 194 NGExclusion exclusion; |
259 exclusion.rect.size = {LayoutUnit(100), LayoutUnit(100)}; | 195 exclusion.rect.size = {LayoutUnit(100), LayoutUnit(100)}; |
260 exclusion.rect.offset = {LayoutUnit(), LayoutUnit(150)}; | 196 exclusion.rect.offset = {LayoutUnit(), LayoutUnit(150)}; |
261 space->AddExclusion(exclusion); | 197 space->AddExclusion(exclusion); |
262 | 198 |
263 NGLayoutOpportunityIterator iterator(space.Get(), space->AvailableSize()); | 199 NGLayoutOpportunityIterator iterator( |
| 200 space->Exclusions().get(), space->AvailableSize(), NGLogicalOffset()); |
264 // 600x100 at (0,0) | 201 // 600x100 at (0,0) |
265 NGLayoutOpportunity opp = {{}, size}; | 202 NGLayoutOpportunity opp = {{}, size}; |
266 EXPECT_EQ(opp, iterator.Next()); | 203 EXPECT_EQ(opp, iterator.Next()); |
267 | 204 |
268 EXPECT_EQ(NGLayoutOpportunity(), iterator.Next()); | 205 EXPECT_EQ(NGLayoutOpportunity(), iterator.Next()); |
269 } | 206 } |
270 | 207 |
271 // Verifies that we combine 2 adjoining left exclusions into one left exclusion. | 208 // Verifies that we combine 2 adjoining left exclusions into one left exclusion. |
272 TEST(NGConstraintSpaceTest, TwoLeftExclusionsShadowEachOther) { | 209 TEST(NGConstraintSpaceTest, TwoLeftExclusionsShadowEachOther) { |
273 NGLogicalOffset bfc_offset = {LayoutUnit(8), LayoutUnit(8)}; | 210 NGLogicalOffset bfc_offset = {LayoutUnit(8), LayoutUnit(8)}; |
274 RefPtr<NGConstraintSpace> space = | 211 RefPtr<NGConstraintSpace> space = |
275 ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::kLtr, | 212 ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::kLtr, |
276 {LayoutUnit(200), LayoutUnit(200)}, bfc_offset); | 213 {LayoutUnit(200), LayoutUnit(200)}, bfc_offset); |
277 | 214 |
278 NGExclusion small_left; | 215 NGExclusion small_left; |
279 small_left.rect.size = {LayoutUnit(10), LayoutUnit(10)}; | 216 small_left.rect.size = {LayoutUnit(10), LayoutUnit(10)}; |
280 small_left.rect.offset = bfc_offset; | 217 small_left.rect.offset = bfc_offset; |
281 small_left.type = NGExclusion::kFloatLeft; | 218 small_left.type = NGExclusion::kFloatLeft; |
282 space->AddExclusion(small_left); | 219 space->AddExclusion(small_left); |
283 | 220 |
284 NGExclusion big_left; | 221 NGExclusion big_left; |
285 big_left.rect.size = {LayoutUnit(20), LayoutUnit(20)}; | 222 big_left.rect.size = {LayoutUnit(20), LayoutUnit(20)}; |
286 big_left.rect.offset = bfc_offset; | 223 big_left.rect.offset = bfc_offset; |
287 big_left.rect.offset.inline_offset += small_left.rect.InlineSize(); | 224 big_left.rect.offset.inline_offset += small_left.rect.InlineSize(); |
288 big_left.type = NGExclusion::kFloatLeft; | 225 big_left.type = NGExclusion::kFloatLeft; |
289 space->AddExclusion(big_left); | 226 space->AddExclusion(big_left); |
290 | 227 |
291 NGLayoutOpportunityIterator iterator(space.Get(), space->AvailableSize(), | 228 NGLayoutOpportunityIterator iterator(space->Exclusions().get(), |
292 bfc_offset); | 229 space->AvailableSize(), bfc_offset); |
293 | 230 |
294 NGLogicalOffset start_point1 = bfc_offset; | 231 NGLogicalOffset start_point1 = bfc_offset; |
295 start_point1.inline_offset += | 232 start_point1.inline_offset += |
296 small_left.rect.InlineSize() + big_left.rect.InlineSize(); | 233 small_left.rect.InlineSize() + big_left.rect.InlineSize(); |
297 // 170x200 at (38, 8) | 234 // 170x200 at (38, 8) |
298 NGLayoutOpportunity opportunity1 = {start_point1, | 235 NGLayoutOpportunity opportunity1 = {start_point1, |
299 {LayoutUnit(170), LayoutUnit(200)}}; | 236 {LayoutUnit(170), LayoutUnit(200)}}; |
300 EXPECT_EQ(opportunity1, iterator.Next()); | 237 EXPECT_EQ(opportunity1, iterator.Next()); |
301 | 238 |
302 NGLogicalOffset start_point2 = bfc_offset; | 239 NGLogicalOffset start_point2 = bfc_offset; |
(...skipping 24 matching lines...) Expand all Loading... |
327 | 264 |
328 NGExclusion big_right; | 265 NGExclusion big_right; |
329 big_right.rect.size = {LayoutUnit(20), LayoutUnit(20)}; | 266 big_right.rect.size = {LayoutUnit(20), LayoutUnit(20)}; |
330 big_right.rect.offset = bfc_offset; | 267 big_right.rect.offset = bfc_offset; |
331 big_right.rect.offset.inline_offset += space->AvailableSize().inline_size - | 268 big_right.rect.offset.inline_offset += space->AvailableSize().inline_size - |
332 small_right.rect.InlineSize() - | 269 small_right.rect.InlineSize() - |
333 big_right.rect.InlineSize(); | 270 big_right.rect.InlineSize(); |
334 big_right.type = NGExclusion::kFloatRight; | 271 big_right.type = NGExclusion::kFloatRight; |
335 space->AddExclusion(big_right); | 272 space->AddExclusion(big_right); |
336 | 273 |
337 NGLayoutOpportunityIterator iterator(space.Get(), space->AvailableSize(), | 274 NGLayoutOpportunityIterator iterator(space->Exclusions().get(), |
338 bfc_offset); | 275 space->AvailableSize(), bfc_offset); |
339 | 276 |
340 NGLogicalOffset start_point1 = bfc_offset; | 277 NGLogicalOffset start_point1 = bfc_offset; |
341 // 170x200 at (8, 8) | 278 // 170x200 at (8, 8) |
342 NGLayoutOpportunity opportunity1 = {start_point1, | 279 NGLayoutOpportunity opportunity1 = {start_point1, |
343 {LayoutUnit(170), LayoutUnit(200)}}; | 280 {LayoutUnit(170), LayoutUnit(200)}}; |
344 EXPECT_EQ(opportunity1, iterator.Next()); | 281 EXPECT_EQ(opportunity1, iterator.Next()); |
345 | 282 |
346 NGLogicalOffset start_point2 = bfc_offset; | 283 NGLogicalOffset start_point2 = bfc_offset; |
347 start_point2.block_offset += big_right.rect.BlockSize(); | 284 start_point2.block_offset += big_right.rect.BlockSize(); |
348 // 200x180 at (8, 28) | 285 // 200x180 at (8, 28) |
349 NGLayoutOpportunity opportunity2 = {start_point2, | 286 NGLayoutOpportunity opportunity2 = {start_point2, |
350 {LayoutUnit(200), LayoutUnit(180)}}; | 287 {LayoutUnit(200), LayoutUnit(180)}}; |
351 EXPECT_EQ(opportunity2, iterator.Next()); | 288 EXPECT_EQ(opportunity2, iterator.Next()); |
352 | 289 |
353 EXPECT_EQ(NGLayoutOpportunity(), iterator.Next()); | 290 EXPECT_EQ(NGLayoutOpportunity(), iterator.Next()); |
354 } | 291 } |
355 | 292 |
356 } // namespace | 293 } // namespace |
357 } // namespace blink | 294 } // namespace blink |
OLD | NEW |