| 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/layout/ng/ng_block_node.h" | 7 #include "core/layout/ng/ng_block_node.h" |
| 8 #include "core/layout/ng/ng_constraint_space.h" | 8 #include "core/layout/ng/ng_constraint_space.h" |
| 9 #include "core/layout/ng/ng_constraint_space_builder.h" | 9 #include "core/layout/ng/ng_constraint_space_builder.h" |
| 10 #include "core/layout/ng/ng_physical_fragment_base.h" | 10 #include "core/layout/ng/ng_physical_fragment_base.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 // <div style="width:50px; | 113 // <div style="width:50px; |
| 114 // height: 50px; margin-left: 100px; | 114 // height: 50px; margin-left: 100px; |
| 115 // writing-mode: horizontal-tb;"></div> | 115 // writing-mode: horizontal-tb;"></div> |
| 116 // </div> | 116 // </div> |
| 117 TEST_F(NGBlockLayoutAlgorithmTest, LayoutBlockChildrenWithWritingMode) { | 117 TEST_F(NGBlockLayoutAlgorithmTest, LayoutBlockChildrenWithWritingMode) { |
| 118 const int kWidth = 50; | 118 const int kWidth = 50; |
| 119 const int kHeight = 50; | 119 const int kHeight = 50; |
| 120 const int kMarginLeft = 100; | 120 const int kMarginLeft = 100; |
| 121 | 121 |
| 122 RefPtr<ComputedStyle> div1_style = ComputedStyle::create(); | 122 RefPtr<ComputedStyle> div1_style = ComputedStyle::create(); |
| 123 div1_style->setWritingMode(LeftToRightWritingMode); | 123 div1_style->setWritingMode(WritingMode::VerticalLr); |
| 124 NGBlockNode* div1 = new NGBlockNode(div1_style.get()); | 124 NGBlockNode* div1 = new NGBlockNode(div1_style.get()); |
| 125 | 125 |
| 126 RefPtr<ComputedStyle> div2_style = ComputedStyle::create(); | 126 RefPtr<ComputedStyle> div2_style = ComputedStyle::create(); |
| 127 div2_style->setHeight(Length(kHeight, Fixed)); | 127 div2_style->setHeight(Length(kHeight, Fixed)); |
| 128 div2_style->setWidth(Length(kWidth, Fixed)); | 128 div2_style->setWidth(Length(kWidth, Fixed)); |
| 129 div1_style->setWritingMode(TopToBottomWritingMode); | 129 div1_style->setWritingMode(WritingMode::HorizontalTb); |
| 130 div2_style->setMarginLeft(Length(kMarginLeft, Fixed)); | 130 div2_style->setMarginLeft(Length(kMarginLeft, Fixed)); |
| 131 NGBlockNode* div2 = new NGBlockNode(div2_style.get()); | 131 NGBlockNode* div2 = new NGBlockNode(div2_style.get()); |
| 132 | 132 |
| 133 div1->SetFirstChild(div2); | 133 div1->SetFirstChild(div2); |
| 134 | 134 |
| 135 auto* space = | 135 auto* space = |
| 136 ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::Ltr, | 136 ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::Ltr, |
| 137 NGLogicalSize(LayoutUnit(500), LayoutUnit(500))); | 137 NGLogicalSize(LayoutUnit(500), LayoutUnit(500))); |
| 138 NGPhysicalFragment* frag = RunBlockLayoutAlgorithm(space, div1); | 138 NGPhysicalFragment* frag = RunBlockLayoutAlgorithm(space, div1); |
| 139 | 139 |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 // horizontal | 386 // horizontal |
| 387 // </div> | 387 // </div> |
| 388 // </div> | 388 // </div> |
| 389 TEST_F(NGBlockLayoutAlgorithmTest, CollapsingMarginsCase5) { | 389 TEST_F(NGBlockLayoutAlgorithmTest, CollapsingMarginsCase5) { |
| 390 const int kVerticalDivMarginRight = 60; | 390 const int kVerticalDivMarginRight = 60; |
| 391 const int kVerticalDivWidth = 50; | 391 const int kVerticalDivWidth = 50; |
| 392 const int kHorizontalDivMarginLeft = 100; | 392 const int kHorizontalDivMarginLeft = 100; |
| 393 | 393 |
| 394 style_->setWidth(Length(500, Fixed)); | 394 style_->setWidth(Length(500, Fixed)); |
| 395 style_->setHeight(Length(500, Fixed)); | 395 style_->setHeight(Length(500, Fixed)); |
| 396 style_->setWritingMode(LeftToRightWritingMode); | 396 style_->setWritingMode(WritingMode::VerticalLr); |
| 397 | 397 |
| 398 // Vertical DIV | 398 // Vertical DIV |
| 399 RefPtr<ComputedStyle> vertical_style = ComputedStyle::create(); | 399 RefPtr<ComputedStyle> vertical_style = ComputedStyle::create(); |
| 400 vertical_style->setMarginRight(Length(kVerticalDivMarginRight, Fixed)); | 400 vertical_style->setMarginRight(Length(kVerticalDivMarginRight, Fixed)); |
| 401 vertical_style->setWidth(Length(kVerticalDivWidth, Fixed)); | 401 vertical_style->setWidth(Length(kVerticalDivWidth, Fixed)); |
| 402 NGBlockNode* vertical_div = new NGBlockNode(vertical_style.get()); | 402 NGBlockNode* vertical_div = new NGBlockNode(vertical_style.get()); |
| 403 | 403 |
| 404 // Horizontal DIV | 404 // Horizontal DIV |
| 405 RefPtr<ComputedStyle> horizontal_style = ComputedStyle::create(); | 405 RefPtr<ComputedStyle> horizontal_style = ComputedStyle::create(); |
| 406 horizontal_style->setMarginLeft(Length(kHorizontalDivMarginLeft, Fixed)); | 406 horizontal_style->setMarginLeft(Length(kHorizontalDivMarginLeft, Fixed)); |
| 407 horizontal_style->setWritingMode(TopToBottomWritingMode); | 407 horizontal_style->setWritingMode(WritingMode::HorizontalTb); |
| 408 NGBlockNode* horizontal_div = new NGBlockNode(horizontal_style.get()); | 408 NGBlockNode* horizontal_div = new NGBlockNode(horizontal_style.get()); |
| 409 | 409 |
| 410 vertical_div->SetNextSibling(horizontal_div); | 410 vertical_div->SetNextSibling(horizontal_div); |
| 411 | 411 |
| 412 auto* space = | 412 auto* space = |
| 413 ConstructConstraintSpace(kVerticalLeftRight, TextDirection::Ltr, | 413 ConstructConstraintSpace(kVerticalLeftRight, TextDirection::Ltr, |
| 414 NGLogicalSize(LayoutUnit(500), LayoutUnit(500))); | 414 NGLogicalSize(LayoutUnit(500), LayoutUnit(500))); |
| 415 NGPhysicalFragment* frag = RunBlockLayoutAlgorithm(space, vertical_div); | 415 NGPhysicalFragment* frag = RunBlockLayoutAlgorithm(space, vertical_div); |
| 416 | 416 |
| 417 ASSERT_EQ(frag->Children().size(), 2UL); | 417 ASSERT_EQ(frag->Children().size(), 2UL); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 441 const int kMarginLeft = -20; | 441 const int kMarginLeft = -20; |
| 442 const int kMarginTop = 40; | 442 const int kMarginTop = 40; |
| 443 | 443 |
| 444 style_->setWidth(Length(500, Fixed)); | 444 style_->setWidth(Length(500, Fixed)); |
| 445 style_->setHeight(Length(500, Fixed)); | 445 style_->setHeight(Length(500, Fixed)); |
| 446 | 446 |
| 447 // DIV1 | 447 // DIV1 |
| 448 RefPtr<ComputedStyle> div1_style = ComputedStyle::create(); | 448 RefPtr<ComputedStyle> div1_style = ComputedStyle::create(); |
| 449 div1_style->setWidth(Length(kWidth, Fixed)); | 449 div1_style->setWidth(Length(kWidth, Fixed)); |
| 450 div1_style->setHeight(Length(kHeight, Fixed)); | 450 div1_style->setHeight(Length(kHeight, Fixed)); |
| 451 div1_style->setWritingMode(RightToLeftWritingMode); | 451 div1_style->setWritingMode(WritingMode::VerticalRl); |
| 452 div1_style->setMarginBottom(Length(kMarginBottom, Fixed)); | 452 div1_style->setMarginBottom(Length(kMarginBottom, Fixed)); |
| 453 NGBlockNode* div1 = new NGBlockNode(div1_style.get()); | 453 NGBlockNode* div1 = new NGBlockNode(div1_style.get()); |
| 454 | 454 |
| 455 // DIV2 | 455 // DIV2 |
| 456 RefPtr<ComputedStyle> div2_style = ComputedStyle::create(); | 456 RefPtr<ComputedStyle> div2_style = ComputedStyle::create(); |
| 457 div2_style->setWidth(Length(kWidth, Fixed)); | 457 div2_style->setWidth(Length(kWidth, Fixed)); |
| 458 div2_style->setMarginLeft(Length(kMarginLeft, Fixed)); | 458 div2_style->setMarginLeft(Length(kMarginLeft, Fixed)); |
| 459 NGBlockNode* div2 = new NGBlockNode(div2_style.get()); | 459 NGBlockNode* div2 = new NGBlockNode(div2_style.get()); |
| 460 | 460 |
| 461 // DIV3 | 461 // DIV3 |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 frag = RunBlockLayoutAlgorithm(space, div1); | 774 frag = RunBlockLayoutAlgorithm(space, div1); |
| 775 space = ConstructConstraintSpace( | 775 space = ConstructConstraintSpace( |
| 776 kHorizontalTopBottom, TextDirection::Ltr, | 776 kHorizontalTopBottom, TextDirection::Ltr, |
| 777 NGLogicalSize(LayoutUnit(kParentSize), LayoutUnit(kParentSize))); | 777 NGLogicalSize(LayoutUnit(kParentSize), LayoutUnit(kParentSize))); |
| 778 child3 = frag->Children()[2]; | 778 child3 = frag->Children()[2]; |
| 779 EXPECT_EQ(kDiv1Size + kDiv2Size, child3->TopOffset()); | 779 EXPECT_EQ(kDiv1Size + kDiv2Size, child3->TopOffset()); |
| 780 } | 780 } |
| 781 | 781 |
| 782 } // namespace | 782 } // namespace |
| 783 } // namespace blink | 783 } // namespace blink |
| OLD | NEW |