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_block_layout_algorithm.h" | 5 #include "core/layout/ng/ng_block_layout_algorithm.h" |
6 | 6 |
7 #include "core/dom/NodeComputedStyle.h" | 7 #include "core/dom/NodeComputedStyle.h" |
8 #include "core/dom/TagCollection.h" | 8 #include "core/dom/TagCollection.h" |
9 #include "core/layout/ng/layout_ng_block_flow.h" | 9 #include "core/layout/ng/layout_ng_block_flow.h" |
10 #include "core/layout/ng/ng_block_node.h" | 10 #include "core/layout/ng/ng_block_node.h" |
11 #include "core/layout/ng/ng_constraint_space.h" | 11 #include "core/layout/ng/ng_constraint_space.h" |
12 #include "core/layout/ng/ng_constraint_space_builder.h" | 12 #include "core/layout/ng/ng_constraint_space_builder.h" |
13 #include "core/layout/ng/ng_floating_object.h" | 13 #include "core/layout/ng/ng_floating_object.h" |
14 #include "core/layout/ng/ng_length_utils.h" | 14 #include "core/layout/ng/ng_length_utils.h" |
15 #include "core/layout/LayoutTestHelper.h" | 15 #include "core/layout/LayoutTestHelper.h" |
16 #include "core/layout/ng/ng_physical_box_fragment.h" | 16 #include "core/layout/ng/ng_physical_box_fragment.h" |
17 #include "core/layout/ng/ng_physical_fragment.h" | 17 #include "core/layout/ng/ng_physical_fragment.h" |
18 #include "core/layout/ng/ng_units.h" | 18 #include "core/layout/ng/ng_units.h" |
19 #include "core/style/ComputedStyle.h" | 19 #include "core/style/ComputedStyle.h" |
20 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
22 | 22 |
23 namespace blink { | 23 namespace blink { |
24 namespace { | 24 namespace { |
25 | 25 |
26 using testing::ElementsAre; | 26 using testing::ElementsAre; |
27 using testing::Pointee; | 27 using testing::Pointee; |
28 | 28 |
29 NGConstraintSpace* ConstructConstraintSpace(NGWritingMode writing_mode, | 29 NGConstraintSpace* ConstructConstraintSpace( |
30 TextDirection direction, | 30 NGWritingMode writing_mode, |
31 NGLogicalSize size, | 31 TextDirection direction, |
32 bool shrink_to_fit = false) { | 32 NGLogicalSize size, |
33 bool shrink_to_fit = false, | |
34 LayoutUnit fragmentainer_space_available = LayoutUnit()) { | |
35 NGFragmentationType block_fragmentation = | |
36 fragmentainer_space_available != LayoutUnit() | |
37 ? NGFragmentationType::kFragmentColumn | |
38 : NGFragmentationType::kFragmentNone; | |
39 | |
33 return NGConstraintSpaceBuilder(writing_mode) | 40 return NGConstraintSpaceBuilder(writing_mode) |
34 .SetAvailableSize(size) | 41 .SetAvailableSize(size) |
35 .SetPercentageResolutionSize(size) | 42 .SetPercentageResolutionSize(size) |
36 .SetTextDirection(direction) | 43 .SetTextDirection(direction) |
37 .SetIsShrinkToFit(shrink_to_fit) | 44 .SetIsShrinkToFit(shrink_to_fit) |
45 .SetFragmentainerSpaceAvailable(fragmentainer_space_available) | |
46 .SetFragmentationType(block_fragmentation) | |
38 .ToConstraintSpace(writing_mode); | 47 .ToConstraintSpace(writing_mode); |
39 } | 48 } |
40 | 49 |
41 typedef bool TestParamLayoutNG; | 50 typedef bool TestParamLayoutNG; |
42 class NGBlockLayoutAlgorithmTest | 51 class NGBlockLayoutAlgorithmTest |
43 : public ::testing::WithParamInterface<TestParamLayoutNG>, | 52 : public ::testing::WithParamInterface<TestParamLayoutNG>, |
44 public RenderingTest { | 53 public RenderingTest { |
45 public: | 54 public: |
46 NGBlockLayoutAlgorithmTest() { | 55 NGBlockLayoutAlgorithmTest() { |
47 RuntimeEnabledFeatures::setLayoutNGEnabled(true); | 56 RuntimeEnabledFeatures::setLayoutNGEnabled(true); |
(...skipping 2041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2089 EXPECT_THAT(NGPhysicalOffset(LayoutUnit(8), LayoutUnit(8)), | 2098 EXPECT_THAT(NGPhysicalOffset(LayoutUnit(8), LayoutUnit(8)), |
2090 empty_block1->Offset()); | 2099 empty_block1->Offset()); |
2091 | 2100 |
2092 auto* empty_block2 = | 2101 auto* empty_block2 = |
2093 toNGPhysicalBoxFragment(container_fragment->Children()[1].get()); | 2102 toNGPhysicalBoxFragment(container_fragment->Children()[1].get()); |
2094 // empty-block2's margin == 50 | 2103 // empty-block2's margin == 50 |
2095 EXPECT_THAT(NGPhysicalOffset(LayoutUnit(0), LayoutUnit(50)), | 2104 EXPECT_THAT(NGPhysicalOffset(LayoutUnit(0), LayoutUnit(50)), |
2096 empty_block2->Offset()); | 2105 empty_block2->Offset()); |
2097 } | 2106 } |
2098 | 2107 |
2108 // Tests that a block child won't fragment if it doesn't reach the fragmentation | |
2109 // line. | |
2110 TEST_F(NGBlockLayoutAlgorithmTest, NoFragmentation) { | |
2111 setBodyInnerHTML(R"HTML( | |
2112 <!DOCTYPE html> | |
2113 <style> | |
2114 #container { | |
2115 width: 150px; | |
2116 height: 200px; | |
2117 } | |
2118 </style> | |
2119 <div id='container'></div> | |
2120 )HTML"); | |
2121 | |
2122 LayoutUnit kFragmentainerSpaceAvailable(200); | |
2123 | |
2124 NGBlockNode* node = new NGBlockNode( | |
2125 toLayoutBlockFlow(getLayoutObjectByElementId("container"))); | |
2126 auto* space = ConstructConstraintSpace( | |
2127 kHorizontalTopBottom, TextDirection::kLtr, | |
2128 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite), false, | |
2129 kFragmentainerSpaceAvailable); | |
2130 | |
2131 // We should only have one 150x200 fragment with no fragmentation. | |
2132 RefPtr<const NGPhysicalFragment> fragment = | |
2133 NGBlockLayoutAlgorithm(node, space).Layout()->PhysicalFragment(); | |
2134 EXPECT_EQ(LayoutUnit(150), fragment->Width()); | |
Gleb Lanbin
2017/02/24 21:51:28
.nit
use fragment->Size()
EXPECT_EQ(fragment->Siz
ikilpatrick
2017/02/25 00:57:22
Done.
| |
2135 EXPECT_EQ(LayoutUnit(200), fragment->Height()); | |
2136 ASSERT_TRUE(fragment->BreakToken()->IsFinished()); | |
2137 } | |
2138 | |
2139 // Tests that a block child with fragment if it reaches the fragmentation line. | |
2140 TEST_F(NGBlockLayoutAlgorithmTest, SimpleFragmentation) { | |
2141 setBodyInnerHTML(R"HTML( | |
2142 <!DOCTYPE html> | |
2143 <style> | |
2144 #container { | |
2145 width: 150px; | |
2146 height: 300px; | |
2147 } | |
2148 </style> | |
2149 <div id='container'></div> | |
2150 )HTML"); | |
2151 | |
2152 LayoutUnit kFragmentainerSpaceAvailable(200); | |
2153 | |
2154 NGBlockNode* node = new NGBlockNode( | |
2155 toLayoutBlockFlow(getLayoutObjectByElementId("container"))); | |
2156 auto* space = ConstructConstraintSpace( | |
2157 kHorizontalTopBottom, TextDirection::kLtr, | |
2158 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite), false, | |
2159 kFragmentainerSpaceAvailable); | |
2160 | |
2161 RefPtr<const NGPhysicalFragment> fragment = | |
2162 NGBlockLayoutAlgorithm(node, space).Layout()->PhysicalFragment(); | |
2163 EXPECT_EQ(LayoutUnit(150), fragment->Width()); | |
2164 EXPECT_EQ(LayoutUnit(200), fragment->Height()); | |
2165 ASSERT_FALSE(fragment->BreakToken()->IsFinished()); | |
2166 | |
2167 fragment = NGBlockLayoutAlgorithm(node, space, | |
2168 toNGBlockBreakToken(fragment->BreakToken())) | |
2169 .Layout() | |
2170 ->PhysicalFragment(); | |
2171 EXPECT_EQ(LayoutUnit(150), fragment->Width()); | |
2172 EXPECT_EQ(LayoutUnit(100), fragment->Height()); | |
2173 ASSERT_TRUE(fragment->BreakToken()->IsFinished()); | |
2174 } | |
2175 | |
2176 // Tests that children inside the same block formatting context fragment when | |
2177 // reaching a fragmentation line. | |
2178 TEST_F(NGBlockLayoutAlgorithmTest, InnerChildrenFragmentation) { | |
2179 setBodyInnerHTML(R"HTML( | |
2180 <!DOCTYPE html> | |
2181 <style> | |
2182 #container { | |
2183 width: 150px; | |
2184 padding-top: 20px; | |
2185 } | |
2186 #child1 { | |
2187 height: 200px; | |
2188 margin-bottom: 20px; | |
2189 } | |
2190 #child2 { | |
2191 height: 100px; | |
2192 margin-top: 20px; | |
2193 } | |
2194 </style> | |
2195 <div id='container'> | |
2196 <div id='child1'></div> | |
2197 <div id='child2'></div> | |
2198 </div> | |
2199 )HTML"); | |
2200 | |
2201 LayoutUnit kFragmentainerSpaceAvailable(200); | |
2202 | |
2203 NGBlockNode* node = new NGBlockNode( | |
2204 toLayoutBlockFlow(getLayoutObjectByElementId("container"))); | |
2205 auto* space = ConstructConstraintSpace( | |
2206 kHorizontalTopBottom, TextDirection::kLtr, | |
2207 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite), false, | |
2208 kFragmentainerSpaceAvailable); | |
2209 | |
2210 RefPtr<const NGPhysicalFragment> fragment = | |
2211 NGBlockLayoutAlgorithm(node, space).Layout()->PhysicalFragment(); | |
2212 EXPECT_EQ(LayoutUnit(150), fragment->Width()); | |
2213 EXPECT_EQ(LayoutUnit(200), fragment->Height()); | |
2214 ASSERT_FALSE(fragment->BreakToken()->IsFinished()); | |
2215 | |
2216 FragmentChildIterator iterator(toNGPhysicalBoxFragment(fragment.get())); | |
2217 const NGPhysicalBoxFragment* child = iterator.NextChild(); | |
2218 EXPECT_EQ(LayoutUnit(150), child->Width()); | |
2219 EXPECT_EQ(LayoutUnit(180), child->Height()); | |
2220 EXPECT_EQ(LayoutUnit(0), child->LeftOffset()); | |
2221 EXPECT_EQ(LayoutUnit(20), child->TopOffset()); | |
2222 | |
2223 EXPECT_FALSE(iterator.NextChild()); | |
2224 | |
2225 fragment = NGBlockLayoutAlgorithm(node, space, | |
2226 toNGBlockBreakToken(fragment->BreakToken())) | |
2227 .Layout() | |
2228 ->PhysicalFragment(); | |
2229 EXPECT_EQ(LayoutUnit(150), fragment->Width()); | |
2230 EXPECT_EQ(LayoutUnit(140), fragment->Height()); | |
2231 ASSERT_TRUE(fragment->BreakToken()->IsFinished()); | |
2232 | |
2233 iterator.SetParent(toNGPhysicalBoxFragment(fragment.get())); | |
2234 child = iterator.NextChild(); | |
2235 EXPECT_EQ(LayoutUnit(150), child->Width()); | |
2236 EXPECT_EQ(LayoutUnit(20), child->Height()); | |
2237 EXPECT_EQ(LayoutUnit(0), child->LeftOffset()); | |
2238 EXPECT_EQ(LayoutUnit(0), child->TopOffset()); | |
2239 | |
2240 child = iterator.NextChild(); | |
2241 EXPECT_EQ(LayoutUnit(150), child->Width()); | |
2242 EXPECT_EQ(LayoutUnit(100), child->Height()); | |
2243 EXPECT_EQ(LayoutUnit(0), child->LeftOffset()); | |
2244 EXPECT_EQ(LayoutUnit(40), child->TopOffset()); | |
2245 | |
2246 EXPECT_FALSE(iterator.NextChild()); | |
2247 } | |
2248 | |
2249 // Tests that children inside which establish new formatting contexts fragment | |
2250 // correctly. | |
2251 TEST_F(NGBlockLayoutAlgorithmTest, | |
2252 InnerFormattingContextChildrenFragmentation) { | |
2253 setBodyInnerHTML(R"HTML( | |
2254 <!DOCTYPE html> | |
2255 <style> | |
2256 #container { | |
2257 width: 150px; | |
2258 padding-top: 20px; | |
2259 } | |
2260 #child1 { | |
2261 height: 200px; | |
2262 margin-bottom: 20px; | |
2263 contain: paint; | |
2264 } | |
2265 #child2 { | |
2266 height: 100px; | |
2267 margin-top: 20px; | |
2268 contain: paint; | |
2269 } | |
2270 </style> | |
2271 <div id='container'> | |
2272 <div id='child1'></div> | |
2273 <div id='child2'></div> | |
2274 </div> | |
2275 )HTML"); | |
2276 | |
2277 LayoutUnit kFragmentainerSpaceAvailable(200); | |
2278 | |
2279 NGBlockNode* node = new NGBlockNode( | |
2280 toLayoutBlockFlow(getLayoutObjectByElementId("container"))); | |
2281 auto* space = ConstructConstraintSpace( | |
2282 kHorizontalTopBottom, TextDirection::kLtr, | |
2283 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite), false, | |
2284 kFragmentainerSpaceAvailable); | |
2285 | |
2286 RefPtr<const NGPhysicalFragment> fragment = | |
2287 NGBlockLayoutAlgorithm(node, space).Layout()->PhysicalFragment(); | |
2288 EXPECT_EQ(LayoutUnit(150), fragment->Width()); | |
2289 EXPECT_EQ(LayoutUnit(200), fragment->Height()); | |
2290 ASSERT_FALSE(fragment->BreakToken()->IsFinished()); | |
2291 | |
2292 FragmentChildIterator iterator(toNGPhysicalBoxFragment(fragment.get())); | |
2293 const NGPhysicalBoxFragment* child = iterator.NextChild(); | |
2294 EXPECT_EQ(LayoutUnit(150), child->Width()); | |
2295 EXPECT_EQ(LayoutUnit(180), child->Height()); | |
2296 EXPECT_EQ(LayoutUnit(0), child->LeftOffset()); | |
2297 EXPECT_EQ(LayoutUnit(20), child->TopOffset()); | |
2298 | |
2299 EXPECT_FALSE(iterator.NextChild()); | |
2300 | |
2301 fragment = NGBlockLayoutAlgorithm(node, space, | |
2302 toNGBlockBreakToken(fragment->BreakToken())) | |
2303 .Layout() | |
2304 ->PhysicalFragment(); | |
2305 EXPECT_EQ(LayoutUnit(150), fragment->Width()); | |
2306 EXPECT_EQ(LayoutUnit(140), fragment->Height()); | |
2307 ASSERT_TRUE(fragment->BreakToken()->IsFinished()); | |
2308 | |
2309 iterator.SetParent(toNGPhysicalBoxFragment(fragment.get())); | |
2310 child = iterator.NextChild(); | |
2311 EXPECT_EQ(LayoutUnit(150), child->Width()); | |
2312 EXPECT_EQ(LayoutUnit(20), child->Height()); | |
2313 EXPECT_EQ(LayoutUnit(0), child->LeftOffset()); | |
2314 EXPECT_EQ(LayoutUnit(0), child->TopOffset()); | |
2315 | |
2316 child = iterator.NextChild(); | |
2317 EXPECT_EQ(LayoutUnit(150), child->Width()); | |
2318 EXPECT_EQ(LayoutUnit(100), child->Height()); | |
2319 EXPECT_EQ(LayoutUnit(0), child->LeftOffset()); | |
2320 EXPECT_EQ(LayoutUnit(40), child->TopOffset()); | |
2321 | |
2322 EXPECT_FALSE(iterator.NextChild()); | |
2323 } | |
2324 | |
2325 // Tests that children inside which establish new formatting contexts fragment | |
2326 // correctly. | |
2327 TEST_F(NGBlockLayoutAlgorithmTest, InnerChildrenFragmentationSmallHeight) { | |
2328 setBodyInnerHTML(R"HTML( | |
2329 <!DOCTYPE html> | |
2330 <style> | |
2331 #container { | |
2332 width: 150px; | |
2333 padding-top: 20px; | |
2334 height: 50px; | |
2335 } | |
2336 #child1 { | |
2337 height: 200px; | |
2338 margin-bottom: 20px; | |
2339 } | |
2340 #child2 { | |
2341 height: 100px; | |
2342 margin-top: 20px; | |
2343 } | |
2344 </style> | |
2345 <div id='container'> | |
2346 <div id='child1'></div> | |
2347 <div id='child2'></div> | |
2348 </div> | |
2349 )HTML"); | |
2350 | |
2351 LayoutUnit kFragmentainerSpaceAvailable(200); | |
2352 | |
2353 NGBlockNode* node = new NGBlockNode( | |
2354 toLayoutBlockFlow(getLayoutObjectByElementId("container"))); | |
2355 auto* space = ConstructConstraintSpace( | |
2356 kHorizontalTopBottom, TextDirection::kLtr, | |
2357 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite), false, | |
2358 kFragmentainerSpaceAvailable); | |
2359 | |
2360 RefPtr<const NGPhysicalFragment> fragment = | |
2361 NGBlockLayoutAlgorithm(node, space).Layout()->PhysicalFragment(); | |
2362 EXPECT_EQ(LayoutUnit(150), fragment->Width()); | |
2363 EXPECT_EQ(LayoutUnit(70), fragment->Height()); | |
2364 ASSERT_FALSE(fragment->BreakToken()->IsFinished()); | |
2365 | |
2366 FragmentChildIterator iterator(toNGPhysicalBoxFragment(fragment.get())); | |
2367 const NGPhysicalBoxFragment* child = iterator.NextChild(); | |
2368 EXPECT_EQ(LayoutUnit(150), child->Width()); | |
2369 EXPECT_EQ(LayoutUnit(180), child->Height()); | |
2370 EXPECT_EQ(LayoutUnit(0), child->LeftOffset()); | |
2371 EXPECT_EQ(LayoutUnit(20), child->TopOffset()); | |
2372 | |
2373 EXPECT_FALSE(iterator.NextChild()); | |
2374 | |
2375 fragment = NGBlockLayoutAlgorithm(node, space, | |
2376 toNGBlockBreakToken(fragment->BreakToken())) | |
2377 .Layout() | |
2378 ->PhysicalFragment(); | |
2379 EXPECT_EQ(LayoutUnit(150), fragment->Width()); | |
2380 EXPECT_EQ(LayoutUnit(0), fragment->Height()); | |
2381 ASSERT_TRUE(fragment->BreakToken()->IsFinished()); | |
2382 | |
2383 iterator.SetParent(toNGPhysicalBoxFragment(fragment.get())); | |
2384 child = iterator.NextChild(); | |
2385 EXPECT_EQ(LayoutUnit(150), child->Width()); | |
2386 EXPECT_EQ(LayoutUnit(20), child->Height()); | |
2387 EXPECT_EQ(LayoutUnit(0), child->LeftOffset()); | |
2388 EXPECT_EQ(LayoutUnit(0), child->TopOffset()); | |
2389 | |
2390 child = iterator.NextChild(); | |
2391 EXPECT_EQ(LayoutUnit(150), child->Width()); | |
2392 EXPECT_EQ(LayoutUnit(100), child->Height()); | |
2393 EXPECT_EQ(LayoutUnit(0), child->LeftOffset()); | |
2394 EXPECT_EQ(LayoutUnit(40), child->TopOffset()); | |
2395 | |
2396 EXPECT_FALSE(iterator.NextChild()); | |
2397 } | |
2398 | |
2399 /*TEST_F(NGBlockLayoutAlgorithmTest, ParallelFlowFragmentation) { | |
Gleb Lanbin
2017/02/24 21:51:28
use DISABLED_ prefix and TODO, i.e. DISABLED_Paral
ikilpatrick
2017/02/25 00:57:22
Blah sorry, removed, this was from an older patch,
| |
2400 setBodyInnerHTML(R"HTML( | |
2401 <!DOCTYPE html> | |
2402 <style> | |
2403 #container { | |
2404 width: 150px; | |
2405 } | |
2406 #float_left { | |
2407 float: left; | |
2408 width: 20px; | |
2409 height: 300px; | |
2410 } | |
2411 #float_right { | |
2412 float: right; | |
2413 width: 50px; | |
2414 height: 500px; | |
2415 } | |
2416 #in_flow { | |
2417 height: 550px; | |
2418 } | |
2419 </style> | |
2420 <div id='container'> | |
2421 <div id='float_left'></div> | |
2422 <div id='float_right'></div> | |
2423 <div id='in_flow'></div> | |
2424 </div> | |
2425 )HTML"); | |
2426 | |
2427 LayoutUnit kFragmentainerSpaceAvailable(200); | |
2428 | |
2429 NGBlockNode* node = new NGBlockNode(toLayoutBlockFlow( | |
2430 document().getElementById("container")->layoutObject())); | |
2431 auto* space = ConstructConstraintSpace( | |
2432 kHorizontalTopBottom, TextDirection::kLtr, | |
2433 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite), false, | |
2434 kFragmentainerSpaceAvailable); | |
2435 | |
2436 // The first fragment should have ... | |
2437 RefPtr<const NGPhysicalFragment> fragment = | |
2438 NGBlockLayoutAlgorithm(node, space).Layout(); | |
2439 EXPECT_EQ(LayoutUnit(150), fragment->Width()); | |
2440 EXPECT_EQ(LayoutUnit(200), fragment->Height()); | |
2441 ASSERT_FALSE(fragment->BreakToken()->IsFinished()); | |
2442 | |
2443 FragmentChildIterator iterator(toNGPhysicalBoxFragment(fragment.get())); | |
2444 | |
2445 // #float_left child. | |
2446 const NGPhysicalBoxFragment* child = iterator.NextChild(); | |
2447 EXPECT_EQ(LayoutUnit(20), child->Width()); | |
2448 EXPECT_EQ(LayoutUnit(200), child->Height()); | |
2449 EXPECT_EQ(LayoutUnit(0), child->LeftOffset()); | |
2450 EXPECT_EQ(LayoutUnit(0), child->TopOffset()); | |
2451 | |
2452 // #float_right child. | |
2453 child = iterator.NextChild(); | |
2454 EXPECT_EQ(LayoutUnit(50), child->Width()); | |
2455 EXPECT_EQ(LayoutUnit(200), child->Height()); | |
2456 EXPECT_EQ(LayoutUnit(100), child->LeftOffset()); | |
2457 EXPECT_EQ(LayoutUnit(0), child->TopOffset()); | |
2458 | |
2459 // #in_flow child. | |
2460 child = iterator.NextChild(); | |
2461 EXPECT_EQ(LayoutUnit(150), child->Width()); | |
2462 EXPECT_EQ(LayoutUnit(200), child->Height()); | |
2463 EXPECT_EQ(LayoutUnit(0), child->LeftOffset()); | |
2464 EXPECT_EQ(LayoutUnit(0), child->TopOffset()); | |
2465 | |
2466 EXPECT_FALSE(iterator.NextChild()); | |
2467 | |
2468 fragment = NGBlockLayoutAlgorithm(node, space, | |
2469 toNGBlockBreakToken(fragment->BreakToken())) | |
2470 .Layout(); | |
2471 EXPECT_EQ(LayoutUnit(150), fragment->Width()); | |
2472 EXPECT_EQ(LayoutUnit(200), fragment->Height()); | |
2473 ASSERT_FALSE(fragment->BreakToken()->IsFinished()); | |
2474 | |
2475 iterator.SetParent(toNGPhysicalBoxFragment(fragment.get())); | |
2476 | |
2477 // #float_left child. | |
2478 child = iterator.NextChild(); | |
2479 EXPECT_EQ(LayoutUnit(20), child->Width()); | |
2480 EXPECT_EQ(LayoutUnit(100), child->Height()); | |
2481 EXPECT_EQ(LayoutUnit(0), child->LeftOffset()); | |
2482 EXPECT_EQ(LayoutUnit(0), child->TopOffset()); | |
2483 EXPECT_TRUE(child->BreakToken()->IsFinished()); | |
2484 | |
2485 // #float_right child. | |
2486 child = iterator.NextChild(); | |
2487 EXPECT_EQ(LayoutUnit(50), child->Width()); | |
2488 EXPECT_EQ(LayoutUnit(200), child->Height()); | |
2489 EXPECT_EQ(LayoutUnit(100), child->LeftOffset()); | |
2490 EXPECT_EQ(LayoutUnit(0), child->TopOffset()); | |
2491 | |
2492 // #in_flow child. | |
2493 child = iterator.NextChild(); | |
2494 EXPECT_EQ(LayoutUnit(150), child->Width()); | |
2495 EXPECT_EQ(LayoutUnit(200), child->Height()); | |
2496 EXPECT_EQ(LayoutUnit(0), child->LeftOffset()); | |
2497 EXPECT_EQ(LayoutUnit(0), child->TopOffset()); | |
2498 | |
2499 EXPECT_FALSE(iterator.NextChild()); | |
2500 | |
2501 fragment = NGBlockLayoutAlgorithm(node, space, | |
2502 toNGBlockBreakToken(fragment->BreakToken())) | |
2503 .Layout(); | |
2504 | |
2505 EXPECT_EQ(LayoutUnit(150), fragment->Width()); | |
2506 EXPECT_EQ(LayoutUnit(150), fragment->Height()); | |
2507 ASSERT_FALSE(fragment->BreakToken()->IsFinished()); | |
2508 | |
2509 iterator.SetParent(toNGPhysicalBoxFragment(fragment.get())); | |
2510 | |
2511 // #float_right child. | |
2512 child = iterator.NextChild(); | |
2513 EXPECT_EQ(LayoutUnit(50), child->Width()); | |
2514 EXPECT_EQ(LayoutUnit(100), child->Height()); | |
2515 EXPECT_EQ(LayoutUnit(100), child->LeftOffset()); | |
2516 EXPECT_EQ(LayoutUnit(0), child->TopOffset()); | |
2517 | |
2518 // #in_flow child. | |
2519 child = iterator.NextChild(); | |
2520 EXPECT_EQ(LayoutUnit(150), child->Width()); | |
2521 EXPECT_EQ(LayoutUnit(150), child->Height()); | |
2522 EXPECT_EQ(LayoutUnit(0), child->LeftOffset()); | |
2523 EXPECT_EQ(LayoutUnit(0), child->TopOffset()); | |
2524 | |
2525 EXPECT_FALSE(iterator.NextChild()); | |
2526 }*/ | |
2527 | |
2099 } // namespace | 2528 } // namespace |
2100 } // namespace blink | 2529 } // namespace blink |
OLD | NEW |