Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: third_party/WebKit/Source/web/tests/NGInlineLayoutTest.cpp

Issue 2702403003: [layoutng] Split NGLayoutResult out of NGPhysicalFragment (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 49
50 NGInlineNode* inlineBox = 50 NGInlineNode* inlineBox =
51 new NGInlineNode(blockFlow->firstChild(), blockFlow->mutableStyle()); 51 new NGInlineNode(blockFlow->firstChild(), blockFlow->mutableStyle());
52 RefPtr<NGPhysicalFragment> fragment = 52 RefPtr<NGLayoutResult> result =
53 NGBlockLayoutAlgorithm(blockFlow, blockFlow->style(), inlineBox, 53 NGBlockLayoutAlgorithm(blockFlow, blockFlow->style(), inlineBox,
54 constraintSpace) 54 constraintSpace)
55 .Layout(); 55 .Layout();
56 EXPECT_TRUE(fragment); 56 EXPECT_TRUE(result);
57 57
58 String expectedText("Hello World!"); 58 String expectedText("Hello World!");
59 EXPECT_EQ(expectedText, inlineBox->Text(0, 12)); 59 EXPECT_EQ(expectedText, inlineBox->Text(0, 12));
60 } 60 }
61 61
62 TEST_F(NGInlineLayoutTest, BlockWithTextAndAtomicInline) { 62 TEST_F(NGInlineLayoutTest, BlockWithTextAndAtomicInline) {
63 RuntimeEnabledFeatures::setLayoutNGEnabled(true); 63 RuntimeEnabledFeatures::setLayoutNGEnabled(true);
64 RuntimeEnabledFeatures::setLayoutNGInlineEnabled(true); 64 RuntimeEnabledFeatures::setLayoutNGInlineEnabled(true);
65 65
66 SimRequest mainResource("https://example.com/", "text/html"); 66 SimRequest mainResource("https://example.com/", "text/html");
67 loadURL("https://example.com/"); 67 loadURL("https://example.com/");
68 mainResource.complete("<div id=\"target\">Hello <img>.</div>"); 68 mainResource.complete("<div id=\"target\">Hello <img>.</div>");
69 69
70 compositor().beginFrame(); 70 compositor().beginFrame();
71 ASSERT_FALSE(compositor().needsBeginFrame()); 71 ASSERT_FALSE(compositor().needsBeginFrame());
72 72
73 Element* target = document().getElementById("target"); 73 Element* target = document().getElementById("target");
74 LayoutNGBlockFlow* blockFlow = toLayoutNGBlockFlow(target->layoutObject()); 74 LayoutNGBlockFlow* blockFlow = toLayoutNGBlockFlow(target->layoutObject());
75 NGConstraintSpace* constraintSpace = constraintSpaceForElement(blockFlow); 75 NGConstraintSpace* constraintSpace = constraintSpaceForElement(blockFlow);
76 76
77 NGInlineNode* inlineBox = 77 NGInlineNode* inlineBox =
78 new NGInlineNode(blockFlow->firstChild(), blockFlow->mutableStyle()); 78 new NGInlineNode(blockFlow->firstChild(), blockFlow->mutableStyle());
79 RefPtr<NGPhysicalFragment> fragment = 79 RefPtr<NGLayoutResult> result =
80 NGBlockLayoutAlgorithm(blockFlow, blockFlow->style(), inlineBox, 80 NGBlockLayoutAlgorithm(blockFlow, blockFlow->style(), inlineBox,
81 constraintSpace) 81 constraintSpace)
82 .Layout(); 82 .Layout();
83 EXPECT_TRUE(fragment); 83 EXPECT_TRUE(result);
84 84
85 String expectedText("Hello "); 85 String expectedText("Hello ");
86 expectedText.append(objectReplacementCharacter); 86 expectedText.append(objectReplacementCharacter);
87 expectedText.append("."); 87 expectedText.append(".");
88 EXPECT_EQ(expectedText, inlineBox->Text(0, 8)); 88 EXPECT_EQ(expectedText, inlineBox->Text(0, 8));
89 89
90 // Delete the line box tree to avoid leaks in the test. 90 // Delete the line box tree to avoid leaks in the test.
91 blockFlow->deleteLineBoxTree(); 91 blockFlow->deleteLineBoxTree();
92 } 92 }
93 93
94 } // namespace blink 94 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698