| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 NGInlineLayoutAlgorithm* layoutAlgorithm = new NGInlineLayoutAlgorithm( | 51 NGInlineLayoutAlgorithm* layoutAlgorithm = new NGInlineLayoutAlgorithm( |
| 52 blockFlow->style(), inlineBox, constraintSpace); | 52 blockFlow->style(), inlineBox, constraintSpace); |
| 53 | 53 |
| 54 NGPhysicalFragmentBase* fragment; |
| 55 while (layoutAlgorithm->Layout(nullptr, &fragment, nullptr) != kNewFragment) { |
| 56 // Repeat until layout completes. |
| 57 } |
| 58 |
| 54 String expectedText("Hello World!"); | 59 String expectedText("Hello World!"); |
| 55 EXPECT_EQ(expectedText, inlineBox->Text(0, 12)); | 60 EXPECT_EQ(expectedText, inlineBox->Text(0, 12)); |
| 56 | |
| 57 NGPhysicalFragmentBase* fragment; | |
| 58 layoutAlgorithm->Layout(nullptr, &fragment, nullptr); | |
| 59 } | 61 } |
| 60 | 62 |
| 61 TEST_F(NGInlineLayoutTest, BlockWithTextAndAtomicInline) { | 63 TEST_F(NGInlineLayoutTest, BlockWithTextAndAtomicInline) { |
| 62 RuntimeEnabledFeatures::setLayoutNGEnabled(true); | 64 RuntimeEnabledFeatures::setLayoutNGEnabled(true); |
| 63 RuntimeEnabledFeatures::setLayoutNGInlineEnabled(true); | 65 RuntimeEnabledFeatures::setLayoutNGInlineEnabled(true); |
| 64 | 66 |
| 65 SimRequest mainResource("https://example.com/", "text/html"); | 67 SimRequest mainResource("https://example.com/", "text/html"); |
| 66 loadURL("https://example.com/"); | 68 loadURL("https://example.com/"); |
| 67 mainResource.complete("<div id=\"target\">Hello <img>.</div>"); | 69 mainResource.complete("<div id=\"target\">Hello <img>.</div>"); |
| 68 | 70 |
| 69 compositor().beginFrame(); | 71 compositor().beginFrame(); |
| 70 ASSERT_FALSE(compositor().needsBeginFrame()); | 72 ASSERT_FALSE(compositor().needsBeginFrame()); |
| 71 | 73 |
| 72 Element* target = document().getElementById("target"); | 74 Element* target = document().getElementById("target"); |
| 73 LayoutNGBlockFlow* blockFlow = toLayoutNGBlockFlow(target->layoutObject()); | 75 LayoutNGBlockFlow* blockFlow = toLayoutNGBlockFlow(target->layoutObject()); |
| 74 NGConstraintSpace* constraintSpace = constraintSpaceForElement(blockFlow); | 76 NGConstraintSpace* constraintSpace = constraintSpaceForElement(blockFlow); |
| 75 | 77 |
| 76 NGInlineNode* inlineBox = | 78 NGInlineNode* inlineBox = |
| 77 new NGInlineNode(blockFlow->firstChild(), blockFlow->mutableStyle()); | 79 new NGInlineNode(blockFlow->firstChild(), blockFlow->mutableStyle()); |
| 78 NGInlineLayoutAlgorithm* layoutAlgorithm = new NGInlineLayoutAlgorithm( | 80 NGInlineLayoutAlgorithm* layoutAlgorithm = new NGInlineLayoutAlgorithm( |
| 79 blockFlow->style(), inlineBox, constraintSpace); | 81 blockFlow->style(), inlineBox, constraintSpace); |
| 80 | 82 |
| 83 NGPhysicalFragmentBase* fragment; |
| 84 while (layoutAlgorithm->Layout(nullptr, &fragment, nullptr) != kNewFragment) { |
| 85 // Repeat until layout completes. |
| 86 } |
| 87 |
| 81 String expectedText("Hello "); | 88 String expectedText("Hello "); |
| 82 expectedText.append(objectReplacementCharacter); | 89 expectedText.append(objectReplacementCharacter); |
| 83 expectedText.append("."); | 90 expectedText.append("."); |
| 84 EXPECT_EQ(expectedText, inlineBox->Text(0, 8)); | 91 EXPECT_EQ(expectedText, inlineBox->Text(0, 8)); |
| 85 | |
| 86 NGPhysicalFragmentBase* fragment; | |
| 87 layoutAlgorithm->Layout(nullptr, &fragment, nullptr); | |
| 88 } | 92 } |
| 89 | 93 |
| 90 } // namespace blink | 94 } // namespace blink |
| OLD | NEW |