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

Side by Side Diff: third_party/WebKit/Source/core/layout/ng/ng_block_child_iterator_test.cc

Issue 2797053002: Remove redundant casts, use NGLayoutInputNode base functions everywhere (Closed)
Patch Set: Created 3 years, 8 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/ng_block_child_iterator.h" 5 #include "core/layout/ng/ng_block_child_iterator.h"
6 6
7 #include "core/layout/LayoutTestHelper.h" 7 #include "core/layout/LayoutTestHelper.h"
8 #include "core/layout/ng/ng_block_break_token.h" 8 #include "core/layout/ng/ng_block_break_token.h"
9 #include "core/layout/ng/ng_block_node.h" 9 #include "core/layout/ng/ng_block_node.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 <div id='child3'></div> 48 <div id='child3'></div>
49 </div> 49 </div>
50 )HTML"); 50 )HTML");
51 NGBlockNode* container = new NGBlockNode( 51 NGBlockNode* container = new NGBlockNode(
52 toLayoutBlockFlow(getLayoutObjectByElementId("container"))); 52 toLayoutBlockFlow(getLayoutObjectByElementId("container")));
53 NGLayoutInputNode* node1 = container->FirstChild(); 53 NGLayoutInputNode* node1 = container->FirstChild();
54 NGLayoutInputNode* node2 = node1->NextSibling(); 54 NGLayoutInputNode* node2 = node1->NextSibling();
55 NGLayoutInputNode* node3 = node2->NextSibling(); 55 NGLayoutInputNode* node3 = node2->NextSibling();
56 56
57 Vector<RefPtr<NGBreakToken>> child_break_tokens; 57 Vector<RefPtr<NGBreakToken>> child_break_tokens;
58 child_break_tokens.push_back(NGBlockBreakToken::create(toNGBlockNode(node1))); 58 child_break_tokens.push_back(NGBlockBreakToken::create(node1));
59 RefPtr<NGBlockBreakToken> parent_token = 59 RefPtr<NGBlockBreakToken> parent_token =
60 NGBlockBreakToken::create(container, LayoutUnit(50), child_break_tokens); 60 NGBlockBreakToken::create(container, LayoutUnit(50), child_break_tokens);
61 61
62 // The iterator should loop through two children. 62 // The iterator should loop through two children.
63 NGBlockChildIterator iterator(node1, parent_token.get()); 63 NGBlockChildIterator iterator(node1, parent_token.get());
64 ASSERT_EQ(NGBlockChildIterator::Entry(node2, nullptr), iterator.NextChild()); 64 ASSERT_EQ(NGBlockChildIterator::Entry(node2, nullptr), iterator.NextChild());
65 ASSERT_EQ(NGBlockChildIterator::Entry(node3, nullptr), iterator.NextChild()); 65 ASSERT_EQ(NGBlockChildIterator::Entry(node3, nullptr), iterator.NextChild());
66 ASSERT_EQ(NGBlockChildIterator::Entry(nullptr, nullptr), 66 ASSERT_EQ(NGBlockChildIterator::Entry(nullptr, nullptr),
67 iterator.NextChild()); 67 iterator.NextChild());
68 68
69 child_break_tokens.push_back(NGBlockBreakToken::create(toNGBlockNode(node2))); 69 child_break_tokens.push_back(NGBlockBreakToken::create(node2));
70 parent_token = 70 parent_token =
71 NGBlockBreakToken::create(container, LayoutUnit(50), child_break_tokens); 71 NGBlockBreakToken::create(container, LayoutUnit(50), child_break_tokens);
72 72
73 // The iterator should loop through two children. 73 // The iterator should loop through two children.
74 NGBlockChildIterator iterator2(node1, parent_token.get()); 74 NGBlockChildIterator iterator2(node1, parent_token.get());
75 ASSERT_EQ(NGBlockChildIterator::Entry(node1, nullptr), iterator2.NextChild()); 75 ASSERT_EQ(NGBlockChildIterator::Entry(node1, nullptr), iterator2.NextChild());
76 ASSERT_EQ(NGBlockChildIterator::Entry(node3, nullptr), iterator2.NextChild()); 76 ASSERT_EQ(NGBlockChildIterator::Entry(node3, nullptr), iterator2.NextChild());
77 ASSERT_EQ(NGBlockChildIterator::Entry(nullptr, nullptr), 77 ASSERT_EQ(NGBlockChildIterator::Entry(nullptr, nullptr),
78 iterator2.NextChild()); 78 iterator2.NextChild());
79 } 79 }
80 80
81 TEST_F(NGBlockChildIteratorTest, BreakTokenWithUnFinishedChild) { 81 TEST_F(NGBlockChildIteratorTest, BreakTokenWithUnFinishedChild) {
82 setBodyInnerHTML(R"HTML( 82 setBodyInnerHTML(R"HTML(
83 <div id='container'> 83 <div id='container'>
84 <div id='child1'></div> 84 <div id='child1'></div>
85 <div id='child2'></div> 85 <div id='child2'></div>
86 <div id='child3'></div> 86 <div id='child3'></div>
87 </div> 87 </div>
88 )HTML"); 88 )HTML");
89 NGBlockNode* container = new NGBlockNode( 89 NGBlockNode* container = new NGBlockNode(
90 toLayoutBlockFlow(getLayoutObjectByElementId("container"))); 90 toLayoutBlockFlow(getLayoutObjectByElementId("container")));
91 NGLayoutInputNode* node1 = container->FirstChild(); 91 NGLayoutInputNode* node1 = container->FirstChild();
92 NGLayoutInputNode* node2 = node1->NextSibling(); 92 NGLayoutInputNode* node2 = node1->NextSibling();
93 NGLayoutInputNode* node3 = node2->NextSibling(); 93 NGLayoutInputNode* node3 = node2->NextSibling();
94 94
95 Vector<RefPtr<NGBreakToken>> child_break_tokens; 95 Vector<RefPtr<NGBreakToken>> child_break_tokens;
96 RefPtr<NGBreakToken> child_token = NGBlockBreakToken::create( 96 RefPtr<NGBreakToken> child_token =
97 toNGBlockNode(node1), LayoutUnit(), child_break_tokens); 97 NGBlockBreakToken::create(node1, LayoutUnit(), child_break_tokens);
98 child_break_tokens.push_back(child_token); 98 child_break_tokens.push_back(child_token);
99 RefPtr<NGBlockBreakToken> parent_token = 99 RefPtr<NGBlockBreakToken> parent_token =
100 NGBlockBreakToken::create(container, LayoutUnit(50), child_break_tokens); 100 NGBlockBreakToken::create(container, LayoutUnit(50), child_break_tokens);
101 101
102 // The iterator should loop through three children, one with a break token. 102 // The iterator should loop through three children, one with a break token.
103 NGBlockChildIterator iterator(node1, parent_token.get()); 103 NGBlockChildIterator iterator(node1, parent_token.get());
104 ASSERT_EQ(NGBlockChildIterator::Entry(node1, child_token.get()), 104 ASSERT_EQ(NGBlockChildIterator::Entry(node1, child_token.get()),
105 iterator.NextChild()); 105 iterator.NextChild());
106 ASSERT_EQ(NGBlockChildIterator::Entry(node2, nullptr), iterator.NextChild()); 106 ASSERT_EQ(NGBlockChildIterator::Entry(node2, nullptr), iterator.NextChild());
107 ASSERT_EQ(NGBlockChildIterator::Entry(node3, nullptr), iterator.NextChild()); 107 ASSERT_EQ(NGBlockChildIterator::Entry(node3, nullptr), iterator.NextChild());
108 ASSERT_EQ(NGBlockChildIterator::Entry(nullptr, nullptr), 108 ASSERT_EQ(NGBlockChildIterator::Entry(nullptr, nullptr),
109 iterator.NextChild()); 109 iterator.NextChild());
110 110
111 child_token = NGBlockBreakToken::create(toNGBlockNode(node2), LayoutUnit(), 111 child_token =
112 child_break_tokens); 112 NGBlockBreakToken::create(node2, LayoutUnit(), child_break_tokens);
113 child_break_tokens.push_back(child_token); 113 child_break_tokens.push_back(child_token);
114 parent_token = 114 parent_token =
115 NGBlockBreakToken::create(container, LayoutUnit(50), child_break_tokens); 115 NGBlockBreakToken::create(container, LayoutUnit(50), child_break_tokens);
116 116
117 // The iterator should loop through three children, one with a break token. 117 // The iterator should loop through three children, one with a break token.
118 NGBlockChildIterator iterator2(node1, parent_token.get()); 118 NGBlockChildIterator iterator2(node1, parent_token.get());
119 ASSERT_EQ(NGBlockChildIterator::Entry(node1, nullptr), iterator2.NextChild()); 119 ASSERT_EQ(NGBlockChildIterator::Entry(node1, nullptr), iterator2.NextChild());
120 ASSERT_EQ(NGBlockChildIterator::Entry(node2, child_token.get()), 120 ASSERT_EQ(NGBlockChildIterator::Entry(node2, child_token.get()),
121 iterator2.NextChild()); 121 iterator2.NextChild());
122 ASSERT_EQ(NGBlockChildIterator::Entry(node3, nullptr), iterator2.NextChild()); 122 ASSERT_EQ(NGBlockChildIterator::Entry(node3, nullptr), iterator2.NextChild());
123 ASSERT_EQ(NGBlockChildIterator::Entry(nullptr, nullptr), 123 ASSERT_EQ(NGBlockChildIterator::Entry(nullptr, nullptr),
124 iterator2.NextChild()); 124 iterator2.NextChild());
125 } 125 }
126 126
127 } // namespace 127 } // namespace
128 } // namespace blink 128 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698