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" |
11 #include "core/layout/ng/ng_physical_fragment.h" | 11 #include "core/layout/ng/ng_physical_fragment.h" |
12 #include "core/layout/ng/ng_layout_coordinator.h" | 12 #include "core/layout/ng/ng_layout_coordinator.h" |
13 #include "core/layout/ng/ng_length_utils.h" | 13 #include "core/layout/ng/ng_length_utils.h" |
14 #include "core/layout/ng/ng_units.h" | 14 #include "core/layout/ng/ng_units.h" |
15 #include "core/style/ComputedStyle.h" | 15 #include "core/style/ComputedStyle.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 | 17 |
18 namespace blink { | 18 namespace blink { |
19 namespace { | 19 namespace { |
20 | 20 |
21 NGConstraintSpace* ConstructConstraintSpace(NGWritingMode writing_mode, | 21 NGConstraintSpace* ConstructConstraintSpace(NGWritingMode writing_mode, |
22 TextDirection direction, | 22 TextDirection direction, |
23 NGLogicalSize size) { | 23 NGLogicalSize size) { |
24 return NGConstraintSpaceBuilder(writing_mode) | 24 return NGConstraintSpaceBuilder(writing_mode) |
25 .SetAvailableSize(size) | 25 .SetAvailableSize(size) |
26 .SetPercentageResolutionSize(size) | 26 .SetPercentageResolutionSize(size) |
27 .SetTextDirection(direction) | 27 .SetTextDirection(direction) |
| 28 .SetWritingMode(writing_mode) |
28 .ToConstraintSpace(); | 29 .ToConstraintSpace(); |
29 } | 30 } |
30 | 31 |
31 class NGBlockLayoutAlgorithmTest : public ::testing::Test { | 32 class NGBlockLayoutAlgorithmTest : public ::testing::Test { |
32 protected: | 33 protected: |
33 void SetUp() override { style_ = ComputedStyle::create(); } | 34 void SetUp() override { style_ = ComputedStyle::create(); } |
34 | 35 |
35 NGPhysicalFragment* RunBlockLayoutAlgorithm(NGConstraintSpace* space, | 36 NGPhysicalFragment* RunBlockLayoutAlgorithm(NGConstraintSpace* space, |
36 NGBlockNode* first_child) { | 37 NGBlockNode* first_child) { |
37 NGBlockNode parent(style_.get()); | 38 NGBlockNode parent(style_.get()); |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 // | 381 // |
381 // Test case's HTML representation: | 382 // Test case's HTML representation: |
382 // <div style="writing-mode: vertical-lr;"> | 383 // <div style="writing-mode: vertical-lr;"> |
383 // <div style="margin-right: 60px; width: 60px;">vertical</div> | 384 // <div style="margin-right: 60px; width: 60px;">vertical</div> |
384 // <div style="margin-left: 100px; writing-mode: horizontal-tb;"> | 385 // <div style="margin-left: 100px; writing-mode: horizontal-tb;"> |
385 // horizontal | 386 // horizontal |
386 // </div> | 387 // </div> |
387 // </div> | 388 // </div> |
388 TEST_F(NGBlockLayoutAlgorithmTest, CollapsingMarginsCase5) { | 389 TEST_F(NGBlockLayoutAlgorithmTest, CollapsingMarginsCase5) { |
389 const int kVerticalDivMarginRight = 60; | 390 const int kVerticalDivMarginRight = 60; |
390 const int kVerticalDivWidth = 60; | 391 const int kVerticalDivWidth = 50; |
391 const int kHorizontalDivMarginLeft = 100; | 392 const int kHorizontalDivMarginLeft = 100; |
392 | 393 |
393 style_->setWidth(Length(500, Fixed)); | 394 style_->setWidth(Length(500, Fixed)); |
394 style_->setHeight(Length(500, Fixed)); | 395 style_->setHeight(Length(500, Fixed)); |
395 style_->setWritingMode(LeftToRightWritingMode); | 396 style_->setWritingMode(LeftToRightWritingMode); |
396 | 397 |
397 // Vertical DIV | 398 // Vertical DIV |
398 RefPtr<ComputedStyle> vertical_style = ComputedStyle::create(); | 399 RefPtr<ComputedStyle> vertical_style = ComputedStyle::create(); |
399 vertical_style->setMarginRight(Length(kVerticalDivMarginRight, Fixed)); | 400 vertical_style->setMarginRight(Length(kVerticalDivMarginRight, Fixed)); |
400 vertical_style->setWidth(Length(kVerticalDivWidth, Fixed)); | 401 vertical_style->setWidth(Length(kVerticalDivWidth, Fixed)); |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 frag = RunBlockLayoutAlgorithm(space, div1); | 773 frag = RunBlockLayoutAlgorithm(space, div1); |
773 space = ConstructConstraintSpace( | 774 space = ConstructConstraintSpace( |
774 kHorizontalTopBottom, LTR, | 775 kHorizontalTopBottom, LTR, |
775 NGLogicalSize(LayoutUnit(kParentSize), LayoutUnit(kParentSize))); | 776 NGLogicalSize(LayoutUnit(kParentSize), LayoutUnit(kParentSize))); |
776 child3 = frag->Children()[2]; | 777 child3 = frag->Children()[2]; |
777 EXPECT_EQ(kDiv1Size + kDiv2Size, child3->TopOffset()); | 778 EXPECT_EQ(kDiv1Size + kDiv2Size, child3->TopOffset()); |
778 } | 779 } |
779 | 780 |
780 } // namespace | 781 } // namespace |
781 } // namespace blink | 782 } // namespace blink |
OLD | NEW |