| 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_constraint_space_builder.h" | 6 #include "core/layout/ng/ng_constraint_space_builder.h" |
| 7 #include "core/layout/ng/ng_inline_layout_algorithm.h" | 7 #include "core/layout/ng/ng_inline_layout_algorithm.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 | 41 |
| 42 compositor().beginFrame(); | 42 compositor().beginFrame(); |
| 43 ASSERT_FALSE(compositor().needsBeginFrame()); | 43 ASSERT_FALSE(compositor().needsBeginFrame()); |
| 44 | 44 |
| 45 Element* target = document().getElementById("target"); | 45 Element* target = document().getElementById("target"); |
| 46 LayoutNGBlockFlow* blockFlow = toLayoutNGBlockFlow(target->layoutObject()); | 46 LayoutNGBlockFlow* blockFlow = toLayoutNGBlockFlow(target->layoutObject()); |
| 47 NGConstraintSpace* constraintSpace = constraintSpaceForElement(blockFlow); | 47 NGConstraintSpace* constraintSpace = constraintSpaceForElement(blockFlow); |
| 48 | 48 |
| 49 NGInlineNode* inlineBox = | 49 NGInlineNode* inlineBox = |
| 50 new NGInlineNode(blockFlow->firstChild(), blockFlow->mutableStyle()); | 50 new NGInlineNode(blockFlow->firstChild(), blockFlow->mutableStyle()); |
| 51 NGPhysicalFragment* fragment = | 51 RefPtr<NGPhysicalFragment> fragment = |
| 52 NGInlineLayoutAlgorithm(blockFlow, blockFlow->style(), inlineBox, | 52 NGInlineLayoutAlgorithm(blockFlow, blockFlow->style(), inlineBox, |
| 53 constraintSpace) | 53 constraintSpace) |
| 54 .Layout(); | 54 .Layout(); |
| 55 EXPECT_TRUE(fragment); | 55 EXPECT_TRUE(fragment); |
| 56 | 56 |
| 57 String expectedText("Hello World!"); | 57 String expectedText("Hello World!"); |
| 58 EXPECT_EQ(expectedText, inlineBox->Text(0, 12)); | 58 EXPECT_EQ(expectedText, inlineBox->Text(0, 12)); |
| 59 } | 59 } |
| 60 | 60 |
| 61 TEST_F(NGInlineLayoutTest, BlockWithTextAndAtomicInline) { | 61 TEST_F(NGInlineLayoutTest, BlockWithTextAndAtomicInline) { |
| 62 RuntimeEnabledFeatures::setLayoutNGEnabled(true); | 62 RuntimeEnabledFeatures::setLayoutNGEnabled(true); |
| 63 RuntimeEnabledFeatures::setLayoutNGInlineEnabled(true); | 63 RuntimeEnabledFeatures::setLayoutNGInlineEnabled(true); |
| 64 | 64 |
| 65 SimRequest mainResource("https://example.com/", "text/html"); | 65 SimRequest mainResource("https://example.com/", "text/html"); |
| 66 loadURL("https://example.com/"); | 66 loadURL("https://example.com/"); |
| 67 mainResource.complete("<div id=\"target\">Hello <img>.</div>"); | 67 mainResource.complete("<div id=\"target\">Hello <img>.</div>"); |
| 68 | 68 |
| 69 compositor().beginFrame(); | 69 compositor().beginFrame(); |
| 70 ASSERT_FALSE(compositor().needsBeginFrame()); | 70 ASSERT_FALSE(compositor().needsBeginFrame()); |
| 71 | 71 |
| 72 Element* target = document().getElementById("target"); | 72 Element* target = document().getElementById("target"); |
| 73 LayoutNGBlockFlow* blockFlow = toLayoutNGBlockFlow(target->layoutObject()); | 73 LayoutNGBlockFlow* blockFlow = toLayoutNGBlockFlow(target->layoutObject()); |
| 74 NGConstraintSpace* constraintSpace = constraintSpaceForElement(blockFlow); | 74 NGConstraintSpace* constraintSpace = constraintSpaceForElement(blockFlow); |
| 75 | 75 |
| 76 NGInlineNode* inlineBox = | 76 NGInlineNode* inlineBox = |
| 77 new NGInlineNode(blockFlow->firstChild(), blockFlow->mutableStyle()); | 77 new NGInlineNode(blockFlow->firstChild(), blockFlow->mutableStyle()); |
| 78 NGPhysicalFragment* fragment = | 78 RefPtr<NGPhysicalFragment> fragment = |
| 79 NGInlineLayoutAlgorithm(blockFlow, blockFlow->style(), inlineBox, | 79 NGInlineLayoutAlgorithm(blockFlow, blockFlow->style(), inlineBox, |
| 80 constraintSpace) | 80 constraintSpace) |
| 81 .Layout(); | 81 .Layout(); |
| 82 EXPECT_TRUE(fragment); | 82 EXPECT_TRUE(fragment); |
| 83 | 83 |
| 84 String expectedText("Hello "); | 84 String expectedText("Hello "); |
| 85 expectedText.append(objectReplacementCharacter); | 85 expectedText.append(objectReplacementCharacter); |
| 86 expectedText.append("."); | 86 expectedText.append("."); |
| 87 EXPECT_EQ(expectedText, inlineBox->Text(0, 8)); | 87 EXPECT_EQ(expectedText, inlineBox->Text(0, 8)); |
| 88 |
| 89 // Delete the line box tree to avoid leaks in the test. |
| 90 blockFlow->deleteLineBoxTree(); |
| 88 } | 91 } |
| 89 | 92 |
| 90 } // namespace blink | 93 } // namespace blink |
| OLD | NEW |