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/layout_ng_block_flow.h" | 5 #include "core/layout/ng/layout_ng_block_flow.h" |
6 #include "core/layout/ng/ng_block_layout_algorithm.h" | 6 #include "core/layout/ng/ng_block_layout_algorithm.h" |
7 #include "core/layout/ng/ng_constraint_space_builder.h" | 7 #include "core/layout/ng/ng_constraint_space_builder.h" |
8 #include "core/layout/ng/ng_inline_node.h" | 8 #include "core/layout/ng/ng_inline_node.h" |
9 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" | 9 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
10 #include "platform/testing/UnitTestHelpers.h" | 10 #include "platform/testing/UnitTestHelpers.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 "<div id=\"target\">Hello <strong>World</strong>!</div>"); | 41 "<div id=\"target\">Hello <strong>World</strong>!</div>"); |
42 | 42 |
43 compositor().beginFrame(); | 43 compositor().beginFrame(); |
44 ASSERT_FALSE(compositor().needsBeginFrame()); | 44 ASSERT_FALSE(compositor().needsBeginFrame()); |
45 | 45 |
46 Element* target = document().getElementById("target"); | 46 Element* target = document().getElementById("target"); |
47 LayoutNGBlockFlow* blockFlow = toLayoutNGBlockFlow(target->layoutObject()); | 47 LayoutNGBlockFlow* blockFlow = toLayoutNGBlockFlow(target->layoutObject()); |
48 NGConstraintSpace* constraintSpace = constraintSpaceForElement(blockFlow); | 48 NGConstraintSpace* constraintSpace = constraintSpaceForElement(blockFlow); |
49 NGBlockNode* node = new NGBlockNode(blockFlow); | 49 NGBlockNode* node = new NGBlockNode(blockFlow); |
50 | 50 |
51 RefPtr<NGPhysicalFragment> fragment = | 51 RefPtr<NGLayoutResult> result = |
52 NGBlockLayoutAlgorithm(node, constraintSpace).Layout(); | 52 NGBlockLayoutAlgorithm(node, constraintSpace).Layout(); |
53 EXPECT_TRUE(fragment); | 53 EXPECT_TRUE(result); |
54 | 54 |
55 String expectedText("Hello World!"); | 55 String expectedText("Hello World!"); |
56 EXPECT_EQ(expectedText, toNGInlineNode(node->FirstChild())->Text(0, 12)); | 56 EXPECT_EQ(expectedText, toNGInlineNode(node->FirstChild())->Text(0, 12)); |
57 } | 57 } |
58 | 58 |
59 TEST_F(NGInlineLayoutTest, BlockWithTextAndAtomicInline) { | 59 TEST_F(NGInlineLayoutTest, BlockWithTextAndAtomicInline) { |
60 RuntimeEnabledFeatures::setLayoutNGEnabled(true); | 60 RuntimeEnabledFeatures::setLayoutNGEnabled(true); |
61 RuntimeEnabledFeatures::setLayoutNGInlineEnabled(true); | 61 RuntimeEnabledFeatures::setLayoutNGInlineEnabled(true); |
62 | 62 |
63 SimRequest mainResource("https://example.com/", "text/html"); | 63 SimRequest mainResource("https://example.com/", "text/html"); |
64 loadURL("https://example.com/"); | 64 loadURL("https://example.com/"); |
65 mainResource.complete("<div id=\"target\">Hello <img>.</div>"); | 65 mainResource.complete("<div id=\"target\">Hello <img>.</div>"); |
66 | 66 |
67 compositor().beginFrame(); | 67 compositor().beginFrame(); |
68 ASSERT_FALSE(compositor().needsBeginFrame()); | 68 ASSERT_FALSE(compositor().needsBeginFrame()); |
69 | 69 |
70 Element* target = document().getElementById("target"); | 70 Element* target = document().getElementById("target"); |
71 LayoutNGBlockFlow* blockFlow = toLayoutNGBlockFlow(target->layoutObject()); | 71 LayoutNGBlockFlow* blockFlow = toLayoutNGBlockFlow(target->layoutObject()); |
72 NGConstraintSpace* constraintSpace = constraintSpaceForElement(blockFlow); | 72 NGConstraintSpace* constraintSpace = constraintSpaceForElement(blockFlow); |
73 NGBlockNode* node = new NGBlockNode(blockFlow); | 73 NGBlockNode* node = new NGBlockNode(blockFlow); |
74 | 74 |
75 RefPtr<NGPhysicalFragment> fragment = | 75 RefPtr<NGLayoutResult> result = |
76 NGBlockLayoutAlgorithm(node, constraintSpace).Layout(); | 76 NGBlockLayoutAlgorithm(node, constraintSpace).Layout(); |
77 EXPECT_TRUE(fragment); | 77 EXPECT_TRUE(result); |
78 | 78 |
79 String expectedText("Hello "); | 79 String expectedText("Hello "); |
80 expectedText.append(objectReplacementCharacter); | 80 expectedText.append(objectReplacementCharacter); |
81 expectedText.append("."); | 81 expectedText.append("."); |
82 EXPECT_EQ(expectedText, toNGInlineNode(node->FirstChild())->Text(0, 8)); | 82 EXPECT_EQ(expectedText, toNGInlineNode(node->FirstChild())->Text(0, 8)); |
83 | 83 |
84 // Delete the line box tree to avoid leaks in the test. | 84 // Delete the line box tree to avoid leaks in the test. |
85 blockFlow->deleteLineBoxTree(); | 85 blockFlow->deleteLineBoxTree(); |
86 } | 86 } |
87 | 87 |
88 } // namespace blink | 88 } // namespace blink |
OLD | NEW |