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/exported/WebViewBase.h" | 5 #include "core/exported/WebViewBase.h" |
6 #include "core/layout/ng/inline/ng_inline_node.h" | 6 #include "core/layout/ng/inline/ng_inline_node.h" |
7 #include "core/layout/ng/layout_ng_block_flow.h" | 7 #include "core/layout/ng/layout_ng_block_flow.h" |
8 #include "core/layout/ng/ng_block_layout_algorithm.h" | 8 #include "core/layout/ng/ng_block_layout_algorithm.h" |
9 #include "core/layout/ng/ng_constraint_space_builder.h" | 9 #include "core/layout/ng/ng_constraint_space_builder.h" |
10 #include "core/layout/ng/ng_layout_result.h" | 10 #include "core/layout/ng/ng_layout_result.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 "<div id=\"target\">Hello <strong>World</strong>!</div>"); | 42 "<div id=\"target\">Hello <strong>World</strong>!</div>"); |
43 | 43 |
44 Compositor().BeginFrame(); | 44 Compositor().BeginFrame(); |
45 ASSERT_FALSE(Compositor().NeedsBeginFrame()); | 45 ASSERT_FALSE(Compositor().NeedsBeginFrame()); |
46 | 46 |
47 Element* target = GetDocument().getElementById("target"); | 47 Element* target = GetDocument().getElementById("target"); |
48 LayoutNGBlockFlow* block_flow = | 48 LayoutNGBlockFlow* block_flow = |
49 ToLayoutNGBlockFlow(target->GetLayoutObject()); | 49 ToLayoutNGBlockFlow(target->GetLayoutObject()); |
50 RefPtr<NGConstraintSpace> constraint_space = | 50 RefPtr<NGConstraintSpace> constraint_space = |
51 ConstraintSpaceForElement(block_flow); | 51 ConstraintSpaceForElement(block_flow); |
52 NGBlockNode* node = new NGBlockNode(block_flow); | 52 NGBlockNode node(block_flow); |
53 | 53 |
54 RefPtr<NGLayoutResult> result = | 54 RefPtr<NGLayoutResult> result = |
55 NGBlockLayoutAlgorithm(node, constraint_space.Get()).Layout(); | 55 NGBlockLayoutAlgorithm(node, constraint_space.Get()).Layout(); |
56 EXPECT_TRUE(result); | 56 EXPECT_TRUE(result); |
57 | 57 |
58 String expected_text("Hello World!"); | 58 String expected_text("Hello World!"); |
59 EXPECT_EQ(expected_text, ToNGInlineNode(node->FirstChild())->Text(0, 12)); | 59 EXPECT_EQ(expected_text, ToNGInlineNode(node.FirstChild()).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 | 64 |
65 SimRequest main_resource("https://example.com/", "text/html"); | 65 SimRequest main_resource("https://example.com/", "text/html"); |
66 LoadURL("https://example.com/"); | 66 LoadURL("https://example.com/"); |
67 main_resource.Complete("<div id=\"target\">Hello <img>.</div>"); | 67 main_resource.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 = GetDocument().getElementById("target"); | 72 Element* target = GetDocument().getElementById("target"); |
73 LayoutNGBlockFlow* block_flow = | 73 LayoutNGBlockFlow* block_flow = |
74 ToLayoutNGBlockFlow(target->GetLayoutObject()); | 74 ToLayoutNGBlockFlow(target->GetLayoutObject()); |
75 RefPtr<NGConstraintSpace> constraint_space = | 75 RefPtr<NGConstraintSpace> constraint_space = |
76 ConstraintSpaceForElement(block_flow); | 76 ConstraintSpaceForElement(block_flow); |
77 NGBlockNode* node = new NGBlockNode(block_flow); | 77 NGBlockNode node(block_flow); |
78 | 78 |
79 RefPtr<NGLayoutResult> result = | 79 RefPtr<NGLayoutResult> result = |
80 NGBlockLayoutAlgorithm(node, constraint_space.Get()).Layout(); | 80 NGBlockLayoutAlgorithm(node, constraint_space.Get()).Layout(); |
81 EXPECT_TRUE(result); | 81 EXPECT_TRUE(result); |
82 | 82 |
83 String expected_text("Hello "); | 83 String expected_text("Hello "); |
84 expected_text.append(kObjectReplacementCharacter); | 84 expected_text.append(kObjectReplacementCharacter); |
85 expected_text.append("."); | 85 expected_text.append("."); |
86 EXPECT_EQ(expected_text, ToNGInlineNode(node->FirstChild())->Text(0, 8)); | 86 EXPECT_EQ(expected_text, ToNGInlineNode(node.FirstChild()).Text(0, 8)); |
87 | 87 |
88 // Delete the line box tree to avoid leaks in the test. | 88 // Delete the line box tree to avoid leaks in the test. |
89 block_flow->DeleteLineBoxTree(); | 89 block_flow->DeleteLineBoxTree(); |
90 } | 90 } |
91 | 91 |
92 } // namespace blink | 92 } // namespace blink |
OLD | NEW |