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

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

Issue 2767793002: Merge LayoutNGInline into LayoutNG runtime enabled feature (Closed)
Patch Set: Created 3 years, 9 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 16 matching lines...) Expand all
27 .SetAvailableSize(NGLogicalSize(LayoutUnit(), LayoutUnit())) 27 .SetAvailableSize(NGLogicalSize(LayoutUnit(), LayoutUnit()))
28 .SetPercentageResolutionSize(NGLogicalSize(LayoutUnit(), LayoutUnit())) 28 .SetPercentageResolutionSize(NGLogicalSize(LayoutUnit(), LayoutUnit()))
29 .SetTextDirection(blockFlow->style()->direction()) 29 .SetTextDirection(blockFlow->style()->direction())
30 .ToConstraintSpace( 30 .ToConstraintSpace(
31 FromPlatformWritingMode(blockFlow->style()->getWritingMode())); 31 FromPlatformWritingMode(blockFlow->style()->getWritingMode()));
32 } 32 }
33 }; 33 };
34 34
35 TEST_F(NGInlineLayoutTest, BlockWithSingleTextNode) { 35 TEST_F(NGInlineLayoutTest, BlockWithSingleTextNode) {
36 RuntimeEnabledFeatures::setLayoutNGEnabled(true); 36 RuntimeEnabledFeatures::setLayoutNGEnabled(true);
37 RuntimeEnabledFeatures::setLayoutNGInlineEnabled(true);
38 37
39 SimRequest mainResource("https://example.com/", "text/html"); 38 SimRequest mainResource("https://example.com/", "text/html");
40 loadURL("https://example.com/"); 39 loadURL("https://example.com/");
41 mainResource.complete( 40 mainResource.complete(
42 "<div id=\"target\">Hello <strong>World</strong>!</div>"); 41 "<div id=\"target\">Hello <strong>World</strong>!</div>");
43 42
44 compositor().beginFrame(); 43 compositor().beginFrame();
45 ASSERT_FALSE(compositor().needsBeginFrame()); 44 ASSERT_FALSE(compositor().needsBeginFrame());
46 45
47 Element* target = document().getElementById("target"); 46 Element* target = document().getElementById("target");
48 LayoutNGBlockFlow* blockFlow = toLayoutNGBlockFlow(target->layoutObject()); 47 LayoutNGBlockFlow* blockFlow = toLayoutNGBlockFlow(target->layoutObject());
49 RefPtr<NGConstraintSpace> constraintSpace = 48 RefPtr<NGConstraintSpace> constraintSpace =
50 constraintSpaceForElement(blockFlow); 49 constraintSpaceForElement(blockFlow);
51 NGBlockNode* node = new NGBlockNode(blockFlow); 50 NGBlockNode* node = new NGBlockNode(blockFlow);
52 51
53 RefPtr<NGLayoutResult> result = 52 RefPtr<NGLayoutResult> result =
54 NGBlockLayoutAlgorithm(node, constraintSpace.get()).Layout(); 53 NGBlockLayoutAlgorithm(node, constraintSpace.get()).Layout();
55 EXPECT_TRUE(result); 54 EXPECT_TRUE(result);
56 55
57 String expectedText("Hello World!"); 56 String expectedText("Hello World!");
58 EXPECT_EQ(expectedText, toNGInlineNode(node->FirstChild())->Text(0, 12)); 57 EXPECT_EQ(expectedText, toNGInlineNode(node->FirstChild())->Text(0, 12));
59 } 58 }
60 59
61 TEST_F(NGInlineLayoutTest, BlockWithTextAndAtomicInline) { 60 TEST_F(NGInlineLayoutTest, BlockWithTextAndAtomicInline) {
62 RuntimeEnabledFeatures::setLayoutNGEnabled(true); 61 RuntimeEnabledFeatures::setLayoutNGEnabled(true);
63 RuntimeEnabledFeatures::setLayoutNGInlineEnabled(true);
64 62
65 SimRequest mainResource("https://example.com/", "text/html"); 63 SimRequest mainResource("https://example.com/", "text/html");
66 loadURL("https://example.com/"); 64 loadURL("https://example.com/");
67 mainResource.complete("<div id=\"target\">Hello <img>.</div>"); 65 mainResource.complete("<div id=\"target\">Hello <img>.</div>");
68 66
69 compositor().beginFrame(); 67 compositor().beginFrame();
70 ASSERT_FALSE(compositor().needsBeginFrame()); 68 ASSERT_FALSE(compositor().needsBeginFrame());
71 69
72 Element* target = document().getElementById("target"); 70 Element* target = document().getElementById("target");
73 LayoutNGBlockFlow* blockFlow = toLayoutNGBlockFlow(target->layoutObject()); 71 LayoutNGBlockFlow* blockFlow = toLayoutNGBlockFlow(target->layoutObject());
74 RefPtr<NGConstraintSpace> constraintSpace = 72 RefPtr<NGConstraintSpace> constraintSpace =
75 constraintSpaceForElement(blockFlow); 73 constraintSpaceForElement(blockFlow);
76 NGBlockNode* node = new NGBlockNode(blockFlow); 74 NGBlockNode* node = new NGBlockNode(blockFlow);
77 75
78 RefPtr<NGLayoutResult> result = 76 RefPtr<NGLayoutResult> result =
79 NGBlockLayoutAlgorithm(node, constraintSpace.get()).Layout(); 77 NGBlockLayoutAlgorithm(node, constraintSpace.get()).Layout();
80 EXPECT_TRUE(result); 78 EXPECT_TRUE(result);
81 79
82 String expectedText("Hello "); 80 String expectedText("Hello ");
83 expectedText.append(objectReplacementCharacter); 81 expectedText.append(objectReplacementCharacter);
84 expectedText.append("."); 82 expectedText.append(".");
85 EXPECT_EQ(expectedText, toNGInlineNode(node->FirstChild())->Text(0, 8)); 83 EXPECT_EQ(expectedText, toNGInlineNode(node->FirstChild())->Text(0, 8));
86 84
87 // Delete the line box tree to avoid leaks in the test. 85 // Delete the line box tree to avoid leaks in the test.
88 blockFlow->deleteLineBoxTree(); 86 blockFlow->deleteLineBoxTree();
89 } 87 }
90 88
91 } // namespace blink 89 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698