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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 RenderingTest::SetUp(); | 56 RenderingTest::SetUp(); |
57 enableCompositing(); | 57 enableCompositing(); |
58 } | 58 } |
59 | 59 |
60 RefPtr<NGPhysicalBoxFragment> RunBlockLayoutAlgorithm( | 60 RefPtr<NGPhysicalBoxFragment> RunBlockLayoutAlgorithm( |
61 NGConstraintSpace* space, | 61 NGConstraintSpace* space, |
62 NGBlockNode* first_child) { | 62 NGBlockNode* first_child) { |
63 NGBlockNode* node = new NGBlockNode(style_.get()); | 63 NGBlockNode* node = new NGBlockNode(style_.get()); |
64 node->SetFirstChild(first_child); | 64 node->SetFirstChild(first_child); |
65 | 65 |
66 RefPtr<NGPhysicalFragment> fragment = | 66 RefPtr<NGLayoutResult> result = |
67 NGBlockLayoutAlgorithm(node, space).Layout(); | 67 NGBlockLayoutAlgorithm(node, space).Layout(); |
68 | 68 |
69 return toNGPhysicalBoxFragment(fragment.get()); | 69 return toNGPhysicalBoxFragment(result->PhysicalFragment().get()); |
70 } | 70 } |
71 | 71 |
72 std::pair<RefPtr<NGPhysicalBoxFragment>, NGConstraintSpace*> | 72 std::pair<RefPtr<NGPhysicalBoxFragment>, NGConstraintSpace*> |
73 RunBlockLayoutAlgorithmForElement(Element* element) { | 73 RunBlockLayoutAlgorithmForElement(Element* element) { |
74 LayoutNGBlockFlow* block_flow = | 74 LayoutNGBlockFlow* block_flow = |
75 toLayoutNGBlockFlow(element->layoutObject()); | 75 toLayoutNGBlockFlow(element->layoutObject()); |
76 NGBlockNode* node = new NGBlockNode(block_flow); | 76 NGBlockNode* node = new NGBlockNode(block_flow); |
77 NGConstraintSpace* space = | 77 NGConstraintSpace* space = |
78 NGConstraintSpace::CreateFromLayoutObject(*block_flow); | 78 NGConstraintSpace::CreateFromLayoutObject(*block_flow); |
79 | 79 |
80 RefPtr<NGPhysicalFragment> fragment = | 80 RefPtr<NGLayoutResult> result = |
81 NGBlockLayoutAlgorithm(node, space).Layout(); | 81 NGBlockLayoutAlgorithm(node, space).Layout(); |
82 return std::make_pair(toNGPhysicalBoxFragment(fragment.get()), space); | 82 return std::make_pair( |
| 83 toNGPhysicalBoxFragment(result->PhysicalFragment().get()), space); |
83 } | 84 } |
84 | 85 |
85 MinAndMaxContentSizes RunComputeMinAndMax(NGBlockNode* first_child) { | 86 MinAndMaxContentSizes RunComputeMinAndMax(NGBlockNode* first_child) { |
86 // The constraint space is not used for min/max computation, but we need | 87 // The constraint space is not used for min/max computation, but we need |
87 // it to create the algorithm. | 88 // it to create the algorithm. |
88 NGConstraintSpace* space = | 89 NGConstraintSpace* space = |
89 ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::kLtr, | 90 ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::kLtr, |
90 NGLogicalSize(LayoutUnit(), LayoutUnit())); | 91 NGLogicalSize(LayoutUnit(), LayoutUnit())); |
91 NGBlockNode* node = new NGBlockNode(style_.get()); | 92 NGBlockNode* node = new NGBlockNode(style_.get()); |
92 node->SetFirstChild(first_child); | 93 node->SetFirstChild(first_child); |
(...skipping 1997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2090 | 2091 |
2091 auto* empty_block2 = | 2092 auto* empty_block2 = |
2092 toNGPhysicalBoxFragment(container_fragment->Children()[1].get()); | 2093 toNGPhysicalBoxFragment(container_fragment->Children()[1].get()); |
2093 // empty-block2's margin == 50 | 2094 // empty-block2's margin == 50 |
2094 EXPECT_THAT(NGPhysicalOffset(LayoutUnit(0), LayoutUnit(50)), | 2095 EXPECT_THAT(NGPhysicalOffset(LayoutUnit(0), LayoutUnit(50)), |
2095 empty_block2->Offset()); | 2096 empty_block2->Offset()); |
2096 } | 2097 } |
2097 | 2098 |
2098 } // namespace | 2099 } // namespace |
2099 } // namespace blink | 2100 } // namespace blink |
OLD | NEW |