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" |
(...skipping 25 matching lines...) Expand all Loading... |
36 .SetTextDirection(direction) | 36 .SetTextDirection(direction) |
37 .SetWritingMode(writing_mode) | 37 .SetWritingMode(writing_mode) |
38 .SetIsShrinkToFit(shrink_to_fit) | 38 .SetIsShrinkToFit(shrink_to_fit) |
39 .ToConstraintSpace(); | 39 .ToConstraintSpace(); |
40 } | 40 } |
41 | 41 |
42 typedef bool TestParamLayoutNG; | 42 typedef bool TestParamLayoutNG; |
43 class NGBlockLayoutAlgorithmTest | 43 class NGBlockLayoutAlgorithmTest |
44 : public ::testing::WithParamInterface<TestParamLayoutNG>, | 44 : public ::testing::WithParamInterface<TestParamLayoutNG>, |
45 public RenderingTest { | 45 public RenderingTest { |
46 public: | |
47 NGBlockLayoutAlgorithmTest() {} | |
48 | |
49 protected: | 46 protected: |
50 void SetUp() override { | 47 void SetUp() override { |
51 style_ = ComputedStyle::create(); | 48 style_ = ComputedStyle::create(); |
52 RenderingTest::SetUp(); | 49 RenderingTest::SetUp(); |
53 enableCompositing(); | 50 enableCompositing(); |
54 } | 51 } |
55 | 52 |
56 NGPhysicalBoxFragment* RunBlockLayoutAlgorithm(NGConstraintSpace* space, | 53 NGPhysicalBoxFragment* RunBlockLayoutAlgorithm(NGConstraintSpace* space, |
57 NGBlockNode* first_child) { | 54 NGBlockNode* first_child) { |
58 NGBlockNode parent(style_.get()); | 55 NGBlockNode parent(style_.get()); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 176 |
180 const NGPhysicalFragment* child = frag->Children()[0]; | 177 const NGPhysicalFragment* child = frag->Children()[0]; |
181 // DIV2 | 178 // DIV2 |
182 child = static_cast<const NGPhysicalBoxFragment*>(child)->Children()[0]; | 179 child = static_cast<const NGPhysicalBoxFragment*>(child)->Children()[0]; |
183 | 180 |
184 EXPECT_EQ(kHeight, child->Height()); | 181 EXPECT_EQ(kHeight, child->Height()); |
185 EXPECT_EQ(0, child->TopOffset()); | 182 EXPECT_EQ(0, child->TopOffset()); |
186 EXPECT_EQ(kMarginLeft, child->LeftOffset()); | 183 EXPECT_EQ(kMarginLeft, child->LeftOffset()); |
187 } | 184 } |
188 | 185 |
189 // Verifies the collapsing margins case for the next pair: | |
190 // - top margin of a box and top margin of its first in-flow child. | |
191 // Verifies that floats are positioned at the top of the first child that can | 186 // Verifies that floats are positioned at the top of the first child that can |
192 // determine its position after margins collapsed. | 187 // determine its position after margins collapsed. |
193 // TODO(glebl): Enable with new the float/margins collapsing algorithm. | 188 TEST_F(NGBlockLayoutAlgorithmTest, CollapsingMarginsCase1WithFloats) { |
194 TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_CollapsingMarginsCase1WithFloats) { | |
195 setBodyInnerHTML( | 189 setBodyInnerHTML( |
196 "<style>" | 190 "<style>" |
197 " #container {" | 191 " #container {" |
198 " height: 200px;" | 192 " height: 200px;" |
199 " width: 200px;" | 193 " width: 200px;" |
200 " margin-top: 10px;" | 194 " margin-top: 10px;" |
201 " padding: 0 7px;" | 195 " padding: 0 7px;" |
202 " background-color: red;" | 196 " background-color: red;" |
203 " }" | 197 " }" |
204 " #first-child {" | 198 " #first-child {" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 NGLogicalOffset exclusion2_offset = {LayoutUnit(185), | 282 NGLogicalOffset exclusion2_offset = {LayoutUnit(185), |
289 LayoutUnit(first_child_block_offset)}; | 283 LayoutUnit(first_child_block_offset)}; |
290 NGLogicalRect exclusion2_rect = {exclusion2_offset, exclusion2_size}; | 284 NGLogicalRect exclusion2_rect = {exclusion2_offset, exclusion2_size}; |
291 NGExclusion expected_exclusion2 = {exclusion2_rect, NGExclusion::kFloatRight}; | 285 NGExclusion expected_exclusion2 = {exclusion2_rect, NGExclusion::kFloatRight}; |
292 | 286 |
293 EXPECT_THAT(space->Exclusions()->storage, | 287 EXPECT_THAT(space->Exclusions()->storage, |
294 (ElementsAre(Pointee(expected_exclusion1), | 288 (ElementsAre(Pointee(expected_exclusion1), |
295 Pointee(expected_exclusion2)))); | 289 Pointee(expected_exclusion2)))); |
296 } | 290 } |
297 | 291 |
298 // Verifies the collapsing margins case for the next pair: | 292 // Verifies the collapsing margins case for the next pairs: |
299 // - bottom margin of box and top margin of its next in-flow following sibling. | 293 // - bottom margin of box and top margin of its next in-flow following sibling. |
300 // - top and bottom margins of a box that does not establish a new block | 294 // - top and bottom margins of a box that does not establish a new block |
301 // formatting context and that has zero computed 'min-height', zero or 'auto' | 295 // formatting context and that has zero computed 'min-height', zero or 'auto' |
302 // computed 'height', and no in-flow children | 296 // computed 'height', and no in-flow children |
303 // TODO(glebl): Enable with new the float/margins collapsing algorithm. | 297 TEST_F(NGBlockLayoutAlgorithmTest, CollapsingMarginsCase2WithFloats) { |
304 TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_CollapsingMarginsCase2WithFloats) { | |
305 setBodyInnerHTML( | 298 setBodyInnerHTML( |
306 "<style>" | 299 "<style>" |
307 "#first-child {" | 300 "#first-child {" |
308 " background-color: red;" | 301 " background-color: red;" |
309 " height: 50px;" | 302 " height: 50px;" |
310 " margin-bottom: 20px;" | 303 " margin-bottom: 20px;" |
311 "}" | 304 "}" |
312 "#float-between-empties {" | 305 "#float-between-empties {" |
313 " background-color: green;" | 306 " background-color: green;" |
314 " float: left;" | 307 " float: left;" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 | 416 |
424 EXPECT_THAT(space->Exclusions()->storage, | 417 EXPECT_THAT(space->Exclusions()->storage, |
425 (ElementsAre(Pointee(float_empties_exclusion), | 418 (ElementsAre(Pointee(float_empties_exclusion), |
426 Pointee(float_nonempties_exclusion), | 419 Pointee(float_nonempties_exclusion), |
427 Pointee(float_top_align_exclusion)))); | 420 Pointee(float_top_align_exclusion)))); |
428 } | 421 } |
429 | 422 |
430 // Verifies the collapsing margins case for the next pair: | 423 // Verifies the collapsing margins case for the next pair: |
431 // - bottom margin of a last in-flow child and bottom margin of its parent if | 424 // - bottom margin of a last in-flow child and bottom margin of its parent if |
432 // the parent has 'auto' computed height | 425 // the parent has 'auto' computed height |
433 // TODO(glebl): Enable with new the float/margins collapsing algorithm. | 426 TEST_F(NGBlockLayoutAlgorithmTest, CollapsingMarginsCase3) { |
434 TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_CollapsingMarginsCase3) { | |
435 setBodyInnerHTML( | 427 setBodyInnerHTML( |
436 "<style>" | 428 "<style>" |
437 " #container {" | 429 " #container {" |
438 " margin-bottom: 20px;" | 430 " margin-bottom: 20px;" |
439 " }" | 431 " }" |
440 " #child {" | 432 " #child {" |
441 " margin-bottom: 200px;" | 433 " margin-bottom: 200px;" |
442 " height: 50px;" | 434 " height: 50px;" |
443 " }" | 435 " }" |
444 "</style>" | 436 "</style>" |
(...skipping 15 matching lines...) Expand all Loading... |
460 container_fragment = toNGPhysicalBoxFragment(body_fragment->Children()[0]); | 452 container_fragment = toNGPhysicalBoxFragment(body_fragment->Children()[0]); |
461 ASSERT_EQ(1UL, container_fragment->Children().size()); | 453 ASSERT_EQ(1UL, container_fragment->Children().size()); |
462 child_fragment = toNGPhysicalBoxFragment(container_fragment->Children()[0]); | 454 child_fragment = toNGPhysicalBoxFragment(container_fragment->Children()[0]); |
463 }; | 455 }; |
464 | 456 |
465 // height == auto | 457 // height == auto |
466 run_test(Length(Auto)); | 458 run_test(Length(Auto)); |
467 // Margins are collapsed with the result 200 = std::max(20, 200) | 459 // Margins are collapsed with the result 200 = std::max(20, 200) |
468 // The fragment size 258 == body's margin 8 + child's height 50 + 200 | 460 // The fragment size 258 == body's margin 8 + child's height 50 + 200 |
469 EXPECT_EQ(NGPhysicalSize(LayoutUnit(800), LayoutUnit(258)), fragment->Size()); | 461 EXPECT_EQ(NGPhysicalSize(LayoutUnit(800), LayoutUnit(258)), fragment->Size()); |
470 // EXPECT_EQ(NGMarginStrut({LayoutUnit(200)}), | 462 EXPECT_EQ(NGMarginStrut({LayoutUnit(200)}), |
471 // container_fragment->EndMarginStrut()); | 463 container_fragment->EndMarginStrut()); |
472 | 464 |
473 // height == fixed | 465 // height == fixed |
474 run_test(Length(50, Fixed)); | 466 run_test(Length(50, Fixed)); |
475 // Margins are not collapsed, so fragment still has margins == 20. | 467 // Margins are not collapsed, so fragment still has margins == 20. |
476 // The fragment size 78 == body's margin 8 + child's height 50 + 20 | 468 // The fragment size 78 == body's margin 8 + child's height 50 + 20 |
477 // EXPECT_EQ(NGPhysicalSize(LayoutUnit(800), LayoutUnit(78)), | 469 EXPECT_EQ(NGPhysicalSize(LayoutUnit(800), LayoutUnit(78)), fragment->Size()); |
478 // fragment->Size()); | 470 EXPECT_EQ(NGMarginStrut(), container_fragment->EndMarginStrut()); |
479 // EXPECT_EQ(NGMarginStrut(), container_fragment->EndMarginStrut()); | |
480 } | 471 } |
481 | 472 |
482 // Verifies that 2 adjoining margins are not collapsed if there is padding or | 473 // Verifies that 2 adjoining margins are not collapsed if there is padding or |
483 // border that separates them. | 474 // border that separates them. |
484 // TODO(glebl): Enable with new the float/margins collapsing algorithm. | 475 TEST_F(NGBlockLayoutAlgorithmTest, CollapsingMarginsCase4) { |
485 TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_CollapsingMarginsCase4) { | |
486 setBodyInnerHTML( | 476 setBodyInnerHTML( |
487 "<style>" | 477 "<style>" |
488 " #container {" | 478 " #container {" |
489 " margin: 30px 0px;" | 479 " margin: 30px 0px;" |
490 " width: 200px;" | 480 " width: 200px;" |
491 " }" | 481 " }" |
492 " #child {" | 482 " #child {" |
493 " margin: 200px 0px;" | 483 " margin: 200px 0px;" |
494 " height: 50px;" | 484 " height: 50px;" |
495 " background-color: blue;" | 485 " background-color: blue;" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 // Verifies that margins of 2 adjoining blocks with different writing modes | 529 // Verifies that margins of 2 adjoining blocks with different writing modes |
540 // get collapsed. | 530 // get collapsed. |
541 // | 531 // |
542 // Test case's HTML representation: | 532 // Test case's HTML representation: |
543 // <div style="writing-mode: vertical-lr;"> | 533 // <div style="writing-mode: vertical-lr;"> |
544 // <div style="margin-right: 60px; width: 60px;">vertical</div> | 534 // <div style="margin-right: 60px; width: 60px;">vertical</div> |
545 // <div style="margin-left: 100px; writing-mode: horizontal-tb;"> | 535 // <div style="margin-left: 100px; writing-mode: horizontal-tb;"> |
546 // horizontal | 536 // horizontal |
547 // </div> | 537 // </div> |
548 // </div> | 538 // </div> |
549 TEST_F(NGBlockLayoutAlgorithmTest, CollapsingMarginsCase5) { | 539 // TODO(glebl): fix writing modes support after new margin collapsing/floats |
| 540 // algorithm is checked in. |
| 541 TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_CollapsingMarginsCase5) { |
550 const int kVerticalDivMarginRight = 60; | 542 const int kVerticalDivMarginRight = 60; |
551 const int kVerticalDivWidth = 50; | 543 const int kVerticalDivWidth = 50; |
552 const int kHorizontalDivMarginLeft = 100; | 544 const int kHorizontalDivMarginLeft = 100; |
553 | 545 |
554 style_->setWidth(Length(500, Fixed)); | 546 style_->setWidth(Length(500, Fixed)); |
555 style_->setHeight(Length(500, Fixed)); | 547 style_->setHeight(Length(500, Fixed)); |
556 style_->setWritingMode(WritingMode::kVerticalLr); | 548 style_->setWritingMode(WritingMode::kVerticalLr); |
557 | 549 |
558 // Vertical DIV | 550 // Vertical DIV |
559 RefPtr<ComputedStyle> vertical_style = ComputedStyle::create(); | 551 RefPtr<ComputedStyle> vertical_style = ComputedStyle::create(); |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 auto floating_object = floating_objects.takeFirst(); | 855 auto floating_object = floating_objects.takeFirst(); |
864 ASSERT_TRUE(floating_object->isPlaced()); | 856 ASSERT_TRUE(floating_object->isPlaced()); |
865 // 80 = float_inline_offset(25) + accumulative offset of empty blocks(35 + 20) | 857 // 80 = float_inline_offset(25) + accumulative offset of empty blocks(35 + 20) |
866 EXPECT_THAT(LayoutUnit(80), floating_object->x()); | 858 EXPECT_THAT(LayoutUnit(80), floating_object->x()); |
867 // 10 = float's padding | 859 // 10 = float's padding |
868 EXPECT_THAT(LayoutUnit(10), floating_object->y()); | 860 EXPECT_THAT(LayoutUnit(10), floating_object->y()); |
869 } | 861 } |
870 | 862 |
871 // Verifies that left/right floating and regular blocks can be positioned | 863 // Verifies that left/right floating and regular blocks can be positioned |
872 // correctly by the algorithm. | 864 // correctly by the algorithm. |
873 // TODO(glebl): Enable with new the float/margins collapsing algorithm. | 865 TEST_F(NGBlockLayoutAlgorithmTest, PositionFloatFragments) { |
874 TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_PositionFloatFragments) { | |
875 setBodyInnerHTML( | 866 setBodyInnerHTML( |
876 "<style>" | 867 "<style>" |
877 " #container {" | 868 " #container {" |
878 " height: 200px;" | 869 " height: 200px;" |
879 " width: 200px;" | 870 " width: 200px;" |
880 " }" | 871 " }" |
881 " #left-float {" | 872 " #left-float {" |
882 " background-color: red;" | 873 " background-color: red;" |
883 " float:left;" | 874 " float:left;" |
884 " height: 30px;" | 875 " height: 30px;" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1037 left_float_with_margin_exclusion_rect, NGExclusion::kFloatLeft}; | 1028 left_float_with_margin_exclusion_rect, NGExclusion::kFloatLeft}; |
1038 | 1029 |
1039 EXPECT_THAT( | 1030 EXPECT_THAT( |
1040 space->Exclusions()->storage, | 1031 space->Exclusions()->storage, |
1041 (ElementsAre(Pointee(left_float_exclusion), Pointee(left_wide_exclusion), | 1032 (ElementsAre(Pointee(left_float_exclusion), Pointee(left_wide_exclusion), |
1042 Pointee(right_float_exclusion), | 1033 Pointee(right_float_exclusion), |
1043 Pointee(left_float_with_margin_exclusion)))); | 1034 Pointee(left_float_with_margin_exclusion)))); |
1044 } | 1035 } |
1045 | 1036 |
1046 // Verifies that NG block layout algorithm respects "clear" CSS property. | 1037 // Verifies that NG block layout algorithm respects "clear" CSS property. |
1047 // TODO(glebl): Enable with new the float/margins collapsing algorithm. | 1038 TEST_F(NGBlockLayoutAlgorithmTest, PositionFragmentsWithClear) { |
1048 TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_PositionFragmentsWithClear) { | |
1049 setBodyInnerHTML( | 1039 setBodyInnerHTML( |
1050 "<style>" | 1040 "<style>" |
1051 " #container {" | 1041 " #container {" |
1052 " height: 200px;" | 1042 " height: 200px;" |
1053 " width: 200px;" | 1043 " width: 200px;" |
1054 " }" | 1044 " }" |
1055 " #float-left {" | 1045 " #float-left {" |
1056 " background-color: red;" | 1046 " background-color: red;" |
1057 " float: left;" | 1047 " float: left;" |
1058 " height: 30px;" | 1048 " height: 30px;" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1245 | 1235 |
1246 private: | 1236 private: |
1247 Member<const NGPhysicalBoxFragment> parent_; | 1237 Member<const NGPhysicalBoxFragment> parent_; |
1248 unsigned index_; | 1238 unsigned index_; |
1249 }; | 1239 }; |
1250 | 1240 |
1251 // Test case's HTML representation: | 1241 // Test case's HTML representation: |
1252 // <div id="parent" style="columns:2; column-fill:auto; column-gap:10px; | 1242 // <div id="parent" style="columns:2; column-fill:auto; column-gap:10px; |
1253 // width:210px; height:100px;"> | 1243 // width:210px; height:100px;"> |
1254 // </div> | 1244 // </div> |
1255 TEST_F(NGBlockLayoutAlgorithmTest, EmptyMulticol) { | 1245 // TODO(glebl): reenable multicol after new margin collapsing/floats algorithm |
| 1246 // is checked in. |
| 1247 TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_EmptyMulticol) { |
1256 // parent | 1248 // parent |
1257 RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); | 1249 RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); |
1258 parent_style->setColumnCount(2); | 1250 parent_style->setColumnCount(2); |
1259 parent_style->setColumnFill(ColumnFillAuto); | 1251 parent_style->setColumnFill(ColumnFillAuto); |
1260 parent_style->setColumnGap(10); | 1252 parent_style->setColumnGap(10); |
1261 parent_style->setHeight(Length(100, Fixed)); | 1253 parent_style->setHeight(Length(100, Fixed)); |
1262 parent_style->setWidth(Length(210, Fixed)); | 1254 parent_style->setWidth(Length(210, Fixed)); |
1263 NGBlockNode* parent = new NGBlockNode(parent_style.get()); | 1255 NGBlockNode* parent = new NGBlockNode(parent_style.get()); |
1264 | 1256 |
1265 auto* space = ConstructConstraintSpace( | 1257 auto* space = ConstructConstraintSpace( |
1266 kHorizontalTopBottom, TextDirection::kLtr, | 1258 kHorizontalTopBottom, TextDirection::kLtr, |
1267 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); | 1259 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); |
1268 const auto* fragment = RunBlockLayoutAlgorithm(space, parent); | 1260 const auto* fragment = RunBlockLayoutAlgorithm(space, parent); |
1269 FragmentChildIterator iterator(fragment); | 1261 FragmentChildIterator iterator(fragment); |
1270 fragment = iterator.NextChild(); | 1262 fragment = iterator.NextChild(); |
1271 ASSERT_TRUE(fragment); | 1263 ASSERT_TRUE(fragment); |
1272 EXPECT_EQ(LayoutUnit(210), fragment->Width()); | 1264 EXPECT_EQ(LayoutUnit(210), fragment->Width()); |
1273 EXPECT_EQ(LayoutUnit(100), fragment->Height()); | 1265 EXPECT_EQ(LayoutUnit(100), fragment->Height()); |
1274 EXPECT_FALSE(iterator.NextChild()); | 1266 EXPECT_FALSE(iterator.NextChild()); |
1275 | 1267 |
1276 // There should be nothing inside the multicol container. | 1268 // There should be nothing inside the multicol container. |
1277 EXPECT_FALSE(FragmentChildIterator(fragment).NextChild()); | 1269 EXPECT_FALSE(FragmentChildIterator(fragment).NextChild()); |
1278 } | 1270 } |
1279 | 1271 |
1280 // Test case's HTML representation: | 1272 // Test case's HTML representation: |
1281 // <div id="parent" style="columns:2; column-fill:auto; column-gap:10px; | 1273 // <div id="parent" style="columns:2; column-fill:auto; column-gap:10px; |
1282 // width:210px; height:100px;"> | 1274 // width:210px; height:100px;"> |
1283 // <div id="child"></div> | 1275 // <div id="child"></div> |
1284 // </div> | 1276 // </div> |
1285 TEST_F(NGBlockLayoutAlgorithmTest, EmptyBlock) { | 1277 // TODO(glebl): reenable multicol after new margin collapsing/floats algorithm |
| 1278 // is checked in. |
| 1279 TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_EmptyBlock) { |
1286 // parent | 1280 // parent |
1287 RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); | 1281 RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); |
1288 parent_style->setColumnCount(2); | 1282 parent_style->setColumnCount(2); |
1289 parent_style->setColumnFill(ColumnFillAuto); | 1283 parent_style->setColumnFill(ColumnFillAuto); |
1290 parent_style->setColumnGap(10); | 1284 parent_style->setColumnGap(10); |
1291 parent_style->setHeight(Length(100, Fixed)); | 1285 parent_style->setHeight(Length(100, Fixed)); |
1292 parent_style->setWidth(Length(210, Fixed)); | 1286 parent_style->setWidth(Length(210, Fixed)); |
1293 NGBlockNode* parent = new NGBlockNode(parent_style.get()); | 1287 NGBlockNode* parent = new NGBlockNode(parent_style.get()); |
1294 | 1288 |
1295 // child | 1289 // child |
(...skipping 23 matching lines...) Expand all Loading... |
1319 EXPECT_EQ(LayoutUnit(), fragment->Height()); | 1313 EXPECT_EQ(LayoutUnit(), fragment->Height()); |
1320 EXPECT_EQ(0UL, fragment->Children().size()); | 1314 EXPECT_EQ(0UL, fragment->Children().size()); |
1321 EXPECT_FALSE(iterator.NextChild()); | 1315 EXPECT_FALSE(iterator.NextChild()); |
1322 } | 1316 } |
1323 | 1317 |
1324 // Test case's HTML representation: | 1318 // Test case's HTML representation: |
1325 // <div id="parent" style="columns:2; column-fill:auto; column-gap:10px; | 1319 // <div id="parent" style="columns:2; column-fill:auto; column-gap:10px; |
1326 // width:310px; height:100px;"> | 1320 // width:310px; height:100px;"> |
1327 // <div id="child" style="width:60%; height:100px;"></div> | 1321 // <div id="child" style="width:60%; height:100px;"></div> |
1328 // </div> | 1322 // </div> |
1329 TEST_F(NGBlockLayoutAlgorithmTest, BlockInOneColumn) { | 1323 // TODO(glebl): reenable multicol after new margin collapsing/floats algorithm |
| 1324 // is checked in. |
| 1325 TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_BlockInOneColumn) { |
1330 // parent | 1326 // parent |
1331 RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); | 1327 RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); |
1332 parent_style->setColumnCount(2); | 1328 parent_style->setColumnCount(2); |
1333 parent_style->setColumnFill(ColumnFillAuto); | 1329 parent_style->setColumnFill(ColumnFillAuto); |
1334 parent_style->setColumnGap(10); | 1330 parent_style->setColumnGap(10); |
1335 parent_style->setHeight(Length(100, Fixed)); | 1331 parent_style->setHeight(Length(100, Fixed)); |
1336 parent_style->setWidth(Length(310, Fixed)); | 1332 parent_style->setWidth(Length(310, Fixed)); |
1337 NGBlockNode* parent = new NGBlockNode(parent_style.get()); | 1333 NGBlockNode* parent = new NGBlockNode(parent_style.get()); |
1338 | 1334 |
1339 // child | 1335 // child |
(...skipping 26 matching lines...) Expand all Loading... |
1366 EXPECT_EQ(LayoutUnit(100), fragment->Height()); | 1362 EXPECT_EQ(LayoutUnit(100), fragment->Height()); |
1367 EXPECT_EQ(0UL, fragment->Children().size()); | 1363 EXPECT_EQ(0UL, fragment->Children().size()); |
1368 EXPECT_FALSE(iterator.NextChild()); | 1364 EXPECT_FALSE(iterator.NextChild()); |
1369 } | 1365 } |
1370 | 1366 |
1371 // Test case's HTML representation: | 1367 // Test case's HTML representation: |
1372 // <div id="parent" style="columns:2; column-fill:auto; column-gap:10px; | 1368 // <div id="parent" style="columns:2; column-fill:auto; column-gap:10px; |
1373 // width:210px; height:100px;"> | 1369 // width:210px; height:100px;"> |
1374 // <div id="child" style="width:75%; height:150px;"></div> | 1370 // <div id="child" style="width:75%; height:150px;"></div> |
1375 // </div> | 1371 // </div> |
1376 TEST_F(NGBlockLayoutAlgorithmTest, BlockInTwoColumns) { | 1372 // TODO(glebl): reenable multicol after new margin collapsing/floats algorithm |
| 1373 // is checked in. |
| 1374 TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_BlockInTwoColumns) { |
1377 // parent | 1375 // parent |
1378 RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); | 1376 RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); |
1379 parent_style->setColumnCount(2); | 1377 parent_style->setColumnCount(2); |
1380 parent_style->setColumnFill(ColumnFillAuto); | 1378 parent_style->setColumnFill(ColumnFillAuto); |
1381 parent_style->setColumnGap(10); | 1379 parent_style->setColumnGap(10); |
1382 parent_style->setHeight(Length(100, Fixed)); | 1380 parent_style->setHeight(Length(100, Fixed)); |
1383 parent_style->setWidth(Length(210, Fixed)); | 1381 parent_style->setWidth(Length(210, Fixed)); |
1384 NGBlockNode* parent = new NGBlockNode(parent_style.get()); | 1382 NGBlockNode* parent = new NGBlockNode(parent_style.get()); |
1385 | 1383 |
1386 // child | 1384 // child |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1422 EXPECT_EQ(LayoutUnit(50), fragment->Height()); | 1420 EXPECT_EQ(LayoutUnit(50), fragment->Height()); |
1423 EXPECT_EQ(0U, fragment->Children().size()); | 1421 EXPECT_EQ(0U, fragment->Children().size()); |
1424 EXPECT_FALSE(iterator.NextChild()); | 1422 EXPECT_FALSE(iterator.NextChild()); |
1425 } | 1423 } |
1426 | 1424 |
1427 // Test case's HTML representation: | 1425 // Test case's HTML representation: |
1428 // <div id="parent" style="columns:3; column-fill:auto; column-gap:10px; | 1426 // <div id="parent" style="columns:3; column-fill:auto; column-gap:10px; |
1429 // width:320px; height:100px;"> | 1427 // width:320px; height:100px;"> |
1430 // <div id="child" style="width:75%; height:250px;"></div> | 1428 // <div id="child" style="width:75%; height:250px;"></div> |
1431 // </div> | 1429 // </div> |
1432 TEST_F(NGBlockLayoutAlgorithmTest, BlockInThreeColumns) { | 1430 // TODO(glebl): reenable multicol after new margin collapsing/floats algorithm |
| 1431 // is checked in. |
| 1432 TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_BlockInThreeColumns) { |
1433 // parent | 1433 // parent |
1434 RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); | 1434 RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); |
1435 parent_style->setColumnCount(3); | 1435 parent_style->setColumnCount(3); |
1436 parent_style->setColumnFill(ColumnFillAuto); | 1436 parent_style->setColumnFill(ColumnFillAuto); |
1437 parent_style->setColumnGap(10); | 1437 parent_style->setColumnGap(10); |
1438 parent_style->setHeight(Length(100, Fixed)); | 1438 parent_style->setHeight(Length(100, Fixed)); |
1439 parent_style->setWidth(Length(320, Fixed)); | 1439 parent_style->setWidth(Length(320, Fixed)); |
1440 NGBlockNode* parent = new NGBlockNode(parent_style.get()); | 1440 NGBlockNode* parent = new NGBlockNode(parent_style.get()); |
1441 | 1441 |
1442 // child | 1442 // child |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1487 EXPECT_EQ(LayoutUnit(50), fragment->Height()); | 1487 EXPECT_EQ(LayoutUnit(50), fragment->Height()); |
1488 EXPECT_EQ(0U, fragment->Children().size()); | 1488 EXPECT_EQ(0U, fragment->Children().size()); |
1489 EXPECT_FALSE(iterator.NextChild()); | 1489 EXPECT_FALSE(iterator.NextChild()); |
1490 } | 1490 } |
1491 | 1491 |
1492 // Test case's HTML representation: | 1492 // Test case's HTML representation: |
1493 // <div id="parent" style="columns:2; column-fill:auto; column-gap:10px; | 1493 // <div id="parent" style="columns:2; column-fill:auto; column-gap:10px; |
1494 // width:210px; height:100px;"> | 1494 // width:210px; height:100px;"> |
1495 // <div id="child" style="width:1px; height:250px;"></div> | 1495 // <div id="child" style="width:1px; height:250px;"></div> |
1496 // </div> | 1496 // </div> |
1497 TEST_F(NGBlockLayoutAlgorithmTest, ActualColumnCountGreaterThanSpecified) { | 1497 // TODO(glebl): reenable multicol after new margin collapsing/floats algorithm |
| 1498 // is checked in. |
| 1499 TEST_F(NGBlockLayoutAlgorithmTest, |
| 1500 DISABLED_ActualColumnCountGreaterThanSpecified) { |
1498 // parent | 1501 // parent |
1499 RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); | 1502 RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); |
1500 parent_style->setColumnCount(2); | 1503 parent_style->setColumnCount(2); |
1501 parent_style->setColumnFill(ColumnFillAuto); | 1504 parent_style->setColumnFill(ColumnFillAuto); |
1502 parent_style->setColumnGap(10); | 1505 parent_style->setColumnGap(10); |
1503 parent_style->setHeight(Length(100, Fixed)); | 1506 parent_style->setHeight(Length(100, Fixed)); |
1504 parent_style->setWidth(Length(210, Fixed)); | 1507 parent_style->setWidth(Length(210, Fixed)); |
1505 NGBlockNode* parent = new NGBlockNode(parent_style.get()); | 1508 NGBlockNode* parent = new NGBlockNode(parent_style.get()); |
1506 | 1509 |
1507 // child | 1510 // child |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1553 EXPECT_EQ(0U, fragment->Children().size()); | 1556 EXPECT_EQ(0U, fragment->Children().size()); |
1554 EXPECT_FALSE(iterator.NextChild()); | 1557 EXPECT_FALSE(iterator.NextChild()); |
1555 } | 1558 } |
1556 | 1559 |
1557 // Test case's HTML representation: | 1560 // Test case's HTML representation: |
1558 // <div id="parent" style="columns:3; column-fill:auto; column-gap:10px; | 1561 // <div id="parent" style="columns:3; column-fill:auto; column-gap:10px; |
1559 // width:320px; height:100px;"> | 1562 // width:320px; height:100px;"> |
1560 // <div id="child1" style="width:75%; height:60px;"></div> | 1563 // <div id="child1" style="width:75%; height:60px;"></div> |
1561 // <div id="child2" style="width:85%; height:60px;"></div> | 1564 // <div id="child2" style="width:85%; height:60px;"></div> |
1562 // </div> | 1565 // </div> |
1563 TEST_F(NGBlockLayoutAlgorithmTest, TwoBlocksInTwoColumns) { | 1566 // TODO(glebl): reenable multicol after new margin collapsing/floats algorithm |
| 1567 // is checked in. |
| 1568 TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_TwoBlocksInTwoColumns) { |
1564 // parent | 1569 // parent |
1565 RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); | 1570 RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); |
1566 parent_style->setColumnCount(3); | 1571 parent_style->setColumnCount(3); |
1567 parent_style->setColumnFill(ColumnFillAuto); | 1572 parent_style->setColumnFill(ColumnFillAuto); |
1568 parent_style->setColumnGap(10); | 1573 parent_style->setColumnGap(10); |
1569 parent_style->setHeight(Length(100, Fixed)); | 1574 parent_style->setHeight(Length(100, Fixed)); |
1570 parent_style->setWidth(Length(320, Fixed)); | 1575 parent_style->setWidth(Length(320, Fixed)); |
1571 NGBlockNode* parent = new NGBlockNode(parent_style.get()); | 1576 NGBlockNode* parent = new NGBlockNode(parent_style.get()); |
1572 | 1577 |
1573 // child1 | 1578 // child1 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1628 | 1633 |
1629 // Test case's HTML representation: | 1634 // Test case's HTML representation: |
1630 // <div id="parent" style="columns:3; column-fill:auto; column-gap:10px; | 1635 // <div id="parent" style="columns:3; column-fill:auto; column-gap:10px; |
1631 // width:320px; height:100px;"> | 1636 // width:320px; height:100px;"> |
1632 // <div id="child1" style="width:75%; height:60px;"> | 1637 // <div id="child1" style="width:75%; height:60px;"> |
1633 // <div id="grandchild1" style="width:50px; height:120px;"></div> | 1638 // <div id="grandchild1" style="width:50px; height:120px;"></div> |
1634 // <div id="grandchild2" style="width:40px; height:20px;"></div> | 1639 // <div id="grandchild2" style="width:40px; height:20px;"></div> |
1635 // </div> | 1640 // </div> |
1636 // <div id="child2" style="width:85%; height:10px;"></div> | 1641 // <div id="child2" style="width:85%; height:10px;"></div> |
1637 // </div> | 1642 // </div> |
1638 TEST_F(NGBlockLayoutAlgorithmTest, OverflowedBlock) { | 1643 // TODO(glebl): reenable multicol after new margin collapsing/floats algorithm |
| 1644 // is checked in. |
| 1645 TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_OverflowedBlock) { |
1639 // parent | 1646 // parent |
1640 RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); | 1647 RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); |
1641 parent_style->setColumnCount(3); | 1648 parent_style->setColumnCount(3); |
1642 parent_style->setColumnFill(ColumnFillAuto); | 1649 parent_style->setColumnFill(ColumnFillAuto); |
1643 parent_style->setColumnGap(10); | 1650 parent_style->setColumnGap(10); |
1644 parent_style->setHeight(Length(100, Fixed)); | 1651 parent_style->setHeight(Length(100, Fixed)); |
1645 parent_style->setWidth(Length(320, Fixed)); | 1652 parent_style->setWidth(Length(320, Fixed)); |
1646 NGBlockNode* parent = new NGBlockNode(parent_style.get()); | 1653 NGBlockNode* parent = new NGBlockNode(parent_style.get()); |
1647 | 1654 |
1648 // child1 | 1655 // child1 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1736 EXPECT_EQ(LayoutUnit(20), fragment->Height()); | 1743 EXPECT_EQ(LayoutUnit(20), fragment->Height()); |
1737 EXPECT_FALSE(grandchild_iterator.NextChild()); | 1744 EXPECT_FALSE(grandchild_iterator.NextChild()); |
1738 EXPECT_FALSE(iterator.NextChild()); | 1745 EXPECT_FALSE(iterator.NextChild()); |
1739 } | 1746 } |
1740 | 1747 |
1741 // Test case's HTML representation: | 1748 // Test case's HTML representation: |
1742 // <div id="parent" style="columns:3; column-fill:auto; column-gap:10px; | 1749 // <div id="parent" style="columns:3; column-fill:auto; column-gap:10px; |
1743 // width:320px; height:100px;"> | 1750 // width:320px; height:100px;"> |
1744 // <div id="child" style="float:left; width:75%; height:100px;"></div> | 1751 // <div id="child" style="float:left; width:75%; height:100px;"></div> |
1745 // </div> | 1752 // </div> |
1746 TEST_F(NGBlockLayoutAlgorithmTest, FloatInOneColumn) { | 1753 // TODO(glebl): reenable multicol after new margin collapsing/floats algorithm |
| 1754 // is checked in. |
| 1755 TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_FloatInOneColumn) { |
1747 // parent | 1756 // parent |
1748 RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); | 1757 RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); |
1749 parent_style->setColumnCount(3); | 1758 parent_style->setColumnCount(3); |
1750 parent_style->setColumnFill(ColumnFillAuto); | 1759 parent_style->setColumnFill(ColumnFillAuto); |
1751 parent_style->setColumnGap(10); | 1760 parent_style->setColumnGap(10); |
1752 parent_style->setHeight(Length(100, Fixed)); | 1761 parent_style->setHeight(Length(100, Fixed)); |
1753 parent_style->setWidth(Length(320, Fixed)); | 1762 parent_style->setWidth(Length(320, Fixed)); |
1754 NGBlockNode* parent = new NGBlockNode(parent_style.get()); | 1763 NGBlockNode* parent = new NGBlockNode(parent_style.get()); |
1755 | 1764 |
1756 // child | 1765 // child |
(...skipping 28 matching lines...) Expand all Loading... |
1785 EXPECT_EQ(0UL, fragment->Children().size()); | 1794 EXPECT_EQ(0UL, fragment->Children().size()); |
1786 EXPECT_FALSE(iterator.NextChild()); | 1795 EXPECT_FALSE(iterator.NextChild()); |
1787 } | 1796 } |
1788 | 1797 |
1789 // Test case's HTML representation: | 1798 // Test case's HTML representation: |
1790 // <div id="parent" style="columns:3; column-fill:auto; column-gap:10px; | 1799 // <div id="parent" style="columns:3; column-fill:auto; column-gap:10px; |
1791 // width:320px; height:100px;"> | 1800 // width:320px; height:100px;"> |
1792 // <div id="child1" style="float:left; width:15%; height:100px;"></div> | 1801 // <div id="child1" style="float:left; width:15%; height:100px;"></div> |
1793 // <div id="child2" style="float:right; width:16%; height:100px;"></div> | 1802 // <div id="child2" style="float:right; width:16%; height:100px;"></div> |
1794 // </div> | 1803 // </div> |
1795 TEST_F(NGBlockLayoutAlgorithmTest, TwoFloatsInOneColumn) { | 1804 // TODO(glebl): reenable multicol after new margin collapsing/floats algorithm |
| 1805 // is checked in. |
| 1806 TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_TwoFloatsInOneColumn) { |
1796 // parent | 1807 // parent |
1797 RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); | 1808 RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); |
1798 parent_style->setColumnCount(3); | 1809 parent_style->setColumnCount(3); |
1799 parent_style->setColumnFill(ColumnFillAuto); | 1810 parent_style->setColumnFill(ColumnFillAuto); |
1800 parent_style->setColumnGap(10); | 1811 parent_style->setColumnGap(10); |
1801 parent_style->setHeight(Length(100, Fixed)); | 1812 parent_style->setHeight(Length(100, Fixed)); |
1802 parent_style->setWidth(Length(320, Fixed)); | 1813 parent_style->setWidth(Length(320, Fixed)); |
1803 NGBlockNode* parent = new NGBlockNode(parent_style.get()); | 1814 NGBlockNode* parent = new NGBlockNode(parent_style.get()); |
1804 | 1815 |
1805 // child1 | 1816 // child1 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1850 EXPECT_EQ(0UL, fragment->Children().size()); | 1861 EXPECT_EQ(0UL, fragment->Children().size()); |
1851 EXPECT_FALSE(iterator.NextChild()); | 1862 EXPECT_FALSE(iterator.NextChild()); |
1852 } | 1863 } |
1853 | 1864 |
1854 // Test case's HTML representation: | 1865 // Test case's HTML representation: |
1855 // <div id="parent" style="columns:3; column-fill:auto; column-gap:10px; | 1866 // <div id="parent" style="columns:3; column-fill:auto; column-gap:10px; |
1856 // width:320px; height:100px;"> | 1867 // width:320px; height:100px;"> |
1857 // <div id="child1" style="float:left; width:15%; height:150px;"></div> | 1868 // <div id="child1" style="float:left; width:15%; height:150px;"></div> |
1858 // <div id="child2" style="float:right; width:16%; height:150px;"></div> | 1869 // <div id="child2" style="float:right; width:16%; height:150px;"></div> |
1859 // </div> | 1870 // </div> |
1860 TEST_F(NGBlockLayoutAlgorithmTest, TwoFloatsInTwoColumns) { | 1871 // TODO(glebl): reenable multicol after new margin collapsing/floats algorithm |
| 1872 // is checked in. |
| 1873 TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_TwoFloatsInTwoColumns) { |
1861 // parent | 1874 // parent |
1862 RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); | 1875 RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); |
1863 parent_style->setColumnCount(3); | 1876 parent_style->setColumnCount(3); |
1864 parent_style->setColumnFill(ColumnFillAuto); | 1877 parent_style->setColumnFill(ColumnFillAuto); |
1865 parent_style->setColumnGap(10); | 1878 parent_style->setColumnGap(10); |
1866 parent_style->setHeight(Length(100, Fixed)); | 1879 parent_style->setHeight(Length(100, Fixed)); |
1867 parent_style->setWidth(Length(320, Fixed)); | 1880 parent_style->setWidth(Length(320, Fixed)); |
1868 NGBlockNode* parent = new NGBlockNode(parent_style.get()); | 1881 NGBlockNode* parent = new NGBlockNode(parent_style.get()); |
1869 | 1882 |
1870 // child1 | 1883 // child1 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1928 EXPECT_EQ(LayoutUnit(194), fragment->LeftOffset()); | 1941 EXPECT_EQ(LayoutUnit(194), fragment->LeftOffset()); |
1929 EXPECT_EQ(LayoutUnit(), fragment->TopOffset()); | 1942 EXPECT_EQ(LayoutUnit(), fragment->TopOffset()); |
1930 EXPECT_EQ(LayoutUnit(16), fragment->Width()); | 1943 EXPECT_EQ(LayoutUnit(16), fragment->Width()); |
1931 EXPECT_EQ(LayoutUnit(50), fragment->Height()); | 1944 EXPECT_EQ(LayoutUnit(50), fragment->Height()); |
1932 EXPECT_EQ(0UL, fragment->Children().size()); | 1945 EXPECT_EQ(0UL, fragment->Children().size()); |
1933 EXPECT_FALSE(iterator.NextChild()); | 1946 EXPECT_FALSE(iterator.NextChild()); |
1934 } | 1947 } |
1935 | 1948 |
1936 } // namespace | 1949 } // namespace |
1937 } // namespace blink | 1950 } // namespace blink |
OLD | NEW |