OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_base_layout_algorithm_test.h" | 5 #include "core/layout/ng/ng_base_layout_algorithm_test.h" |
6 | 6 |
7 #include "core/layout/ng/layout_ng_block_flow.h" | 7 #include "core/layout/ng/layout_ng_block_flow.h" |
8 #include "core/layout/ng/ng_block_layout_algorithm.h" | 8 #include "core/layout/ng/ng_block_layout_algorithm.h" |
9 #include "core/layout/ng/ng_physical_fragment.h" | 9 #include "core/layout/ng/ng_physical_fragment.h" |
10 namespace blink { | 10 namespace blink { |
11 | 11 |
12 NGBaseLayoutAlgorithmTest::NGBaseLayoutAlgorithmTest() { | 12 NGBaseLayoutAlgorithmTest::NGBaseLayoutAlgorithmTest() { |
13 RuntimeEnabledFeatures::setLayoutNGEnabled(true); | 13 RuntimeEnabledFeatures::setLayoutNGEnabled(true); |
14 RuntimeEnabledFeatures::setLayoutNGInlineEnabled(true); | |
15 } | 14 } |
16 | 15 |
17 NGBaseLayoutAlgorithmTest::~NGBaseLayoutAlgorithmTest() { | 16 NGBaseLayoutAlgorithmTest::~NGBaseLayoutAlgorithmTest() { |
18 RuntimeEnabledFeatures::setLayoutNGEnabled(false); | 17 RuntimeEnabledFeatures::setLayoutNGEnabled(false); |
19 RuntimeEnabledFeatures::setLayoutNGInlineEnabled(false); | |
20 } | 18 } |
21 | 19 |
22 void NGBaseLayoutAlgorithmTest::SetUp() { | 20 void NGBaseLayoutAlgorithmTest::SetUp() { |
23 RenderingTest::SetUp(); | 21 RenderingTest::SetUp(); |
24 enableCompositing(); | 22 enableCompositing(); |
25 } | 23 } |
26 | 24 |
27 std::pair<RefPtr<NGPhysicalBoxFragment>, RefPtr<NGConstraintSpace>> | 25 std::pair<RefPtr<NGPhysicalBoxFragment>, RefPtr<NGConstraintSpace>> |
28 NGBaseLayoutAlgorithmTest::RunBlockLayoutAlgorithmForElement(Element* element) { | 26 NGBaseLayoutAlgorithmTest::RunBlockLayoutAlgorithmForElement(Element* element) { |
29 LayoutNGBlockFlow* block_flow = toLayoutNGBlockFlow(element->layoutObject()); | 27 LayoutNGBlockFlow* block_flow = toLayoutNGBlockFlow(element->layoutObject()); |
30 NGBlockNode* node = new NGBlockNode(block_flow); | 28 NGBlockNode* node = new NGBlockNode(block_flow); |
31 RefPtr<NGConstraintSpace> space = | 29 RefPtr<NGConstraintSpace> space = |
32 NGConstraintSpace::CreateFromLayoutObject(*block_flow); | 30 NGConstraintSpace::CreateFromLayoutObject(*block_flow); |
33 | 31 |
34 RefPtr<NGLayoutResult> result = | 32 RefPtr<NGLayoutResult> result = |
35 NGBlockLayoutAlgorithm(node, space.get()).Layout(); | 33 NGBlockLayoutAlgorithm(node, space.get()).Layout(); |
36 return std::make_pair( | 34 return std::make_pair( |
37 toNGPhysicalBoxFragment(result->PhysicalFragment().get()), space); | 35 toNGPhysicalBoxFragment(result->PhysicalFragment().get()), space); |
38 } | 36 } |
39 | 37 |
40 } // namespace blink | 38 } // namespace blink |
OLD | NEW |