OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/LayoutMultiColumnFlowThread.h" | 5 #include "core/layout/LayoutMultiColumnFlowThread.h" |
6 | 6 |
7 #include "core/layout/LayoutMultiColumnSet.h" | 7 #include "core/layout/LayoutMultiColumnSet.h" |
8 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h" | 8 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h" |
9 #include "core/layout/LayoutTestHelper.h" | 9 #include "core/layout/LayoutTestHelper.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 // established. 'c' is used for regular column content sets, while 's' is us
ed for spanners. | 21 // established. 'c' is used for regular column content sets, while 's' is us
ed for spanners. |
22 // '?' is used when there's an unknown box type (which should be considered
a failure). | 22 // '?' is used when there's an unknown box type (which should be considered
a failure). |
23 String columnSetSignature(LayoutMultiColumnFlowThread*); | 23 String columnSetSignature(LayoutMultiColumnFlowThread*); |
24 String columnSetSignature(const char* multicolId); | 24 String columnSetSignature(const char* multicolId); |
25 | 25 |
26 void setMulticolHTML(const String&); | 26 void setMulticolHTML(const String&); |
27 }; | 27 }; |
28 | 28 |
29 LayoutMultiColumnFlowThread* MultiColumnRenderingTest::findFlowThread(const char
* id) const | 29 LayoutMultiColumnFlowThread* MultiColumnRenderingTest::findFlowThread(const char
* id) const |
30 { | 30 { |
31 Node* multicol = document().getElementById(id); | 31 if (LayoutBlockFlow* multicolContainer = toLayoutBlockFlow(getLayoutObjectBy
ElementId(id))) |
32 if (!multicol) | 32 return multicolContainer->multiColumnFlowThread(); |
33 return nullptr; | 33 return nullptr; |
34 LayoutBlockFlow* multicolContainer = toLayoutBlockFlow(multicol->layoutObjec
t()); | |
35 if (!multicolContainer) | |
36 return nullptr; | |
37 return multicolContainer->multiColumnFlowThread(); | |
38 } | 34 } |
39 | 35 |
40 String MultiColumnRenderingTest::columnSetSignature(LayoutMultiColumnFlowThread*
flowThread) | 36 String MultiColumnRenderingTest::columnSetSignature(LayoutMultiColumnFlowThread*
flowThread) |
41 { | 37 { |
42 String signature = ""; | 38 String signature = ""; |
43 for (LayoutBox* columnBox = flowThread->firstMultiColumnBox(); | 39 for (LayoutBox* columnBox = flowThread->firstMultiColumnBox(); |
44 columnBox; | 40 columnBox; |
45 columnBox = columnBox->nextSiblingMultiColumnBox()) { | 41 columnBox = columnBox->nextSiblingMultiColumnBox()) { |
46 if (columnBox->isLayoutMultiColumnSpannerPlaceholder()) | 42 if (columnBox->isLayoutMultiColumnSpannerPlaceholder()) |
47 signature.append('s'); | 43 signature.append('s'); |
(...skipping 17 matching lines...) Expand all Loading... |
65 " #mc { -webkit-columns:2; }" | 61 " #mc { -webkit-columns:2; }" |
66 " .s, #spanner, #spanner1, #spanner2 { -webkit-column-span:all; }" | 62 " .s, #spanner, #spanner1, #spanner2 { -webkit-column-span:all; }" |
67 "</style>"; | 63 "</style>"; |
68 setBodyInnerHTML(style + html); | 64 setBodyInnerHTML(style + html); |
69 } | 65 } |
70 | 66 |
71 TEST_F(MultiColumnRenderingTest, OneBlockWithInDepthTreeStructureCheck) | 67 TEST_F(MultiColumnRenderingTest, OneBlockWithInDepthTreeStructureCheck) |
72 { | 68 { |
73 // Examine the layout tree established by a simple multicol container with a
block with some text inside. | 69 // Examine the layout tree established by a simple multicol container with a
block with some text inside. |
74 setMulticolHTML("<div id='mc'><div>xxx</div></div>"); | 70 setMulticolHTML("<div id='mc'><div>xxx</div></div>"); |
75 Node* multicol = document().getElementById("mc"); | 71 LayoutBlockFlow* multicolContainer = toLayoutBlockFlow(getLayoutObjectByElem
entId("mc")); |
76 ASSERT_TRUE(multicol); | |
77 LayoutBlockFlow* multicolContainer = toLayoutBlockFlow(multicol->layoutObjec
t()); | |
78 ASSERT_TRUE(multicolContainer); | 72 ASSERT_TRUE(multicolContainer); |
79 LayoutMultiColumnFlowThread* flowThread = multicolContainer->multiColumnFlow
Thread(); | 73 LayoutMultiColumnFlowThread* flowThread = multicolContainer->multiColumnFlow
Thread(); |
80 ASSERT_TRUE(flowThread); | 74 ASSERT_TRUE(flowThread); |
81 EXPECT_EQ(columnSetSignature(flowThread), "c"); | 75 EXPECT_EQ(columnSetSignature(flowThread), "c"); |
82 EXPECT_EQ(flowThread->parent(), multicolContainer); | 76 EXPECT_EQ(flowThread->parent(), multicolContainer); |
83 EXPECT_FALSE(flowThread->previousSibling()); | 77 EXPECT_FALSE(flowThread->previousSibling()); |
84 LayoutMultiColumnSet* columnSet = flowThread->firstMultiColumnSet(); | 78 LayoutMultiColumnSet* columnSet = flowThread->firstMultiColumnSet(); |
85 ASSERT_TRUE(columnSet); | 79 ASSERT_TRUE(columnSet); |
86 EXPECT_EQ(columnSet->previousSibling(), flowThread); | 80 EXPECT_EQ(columnSet->previousSibling(), flowThread); |
87 EXPECT_FALSE(columnSet->nextSibling()); | 81 EXPECT_FALSE(columnSet->nextSibling()); |
(...skipping 12 matching lines...) Expand all Loading... |
100 EXPECT_EQ(columnSetSignature("mc"), ""); | 94 EXPECT_EQ(columnSetSignature("mc"), ""); |
101 } | 95 } |
102 | 96 |
103 TEST_F(MultiColumnRenderingTest, OneBlock) | 97 TEST_F(MultiColumnRenderingTest, OneBlock) |
104 { | 98 { |
105 // There is some content, so we should create a column set. | 99 // There is some content, so we should create a column set. |
106 setMulticolHTML("<div id='mc'><div id='block'></div></div>"); | 100 setMulticolHTML("<div id='mc'><div id='block'></div></div>"); |
107 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); | 101 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); |
108 ASSERT_EQ(columnSetSignature(flowThread), "c"); | 102 ASSERT_EQ(columnSetSignature(flowThread), "c"); |
109 LayoutMultiColumnSet* columnSet = flowThread->firstMultiColumnSet(); | 103 LayoutMultiColumnSet* columnSet = flowThread->firstMultiColumnSet(); |
110 EXPECT_EQ(flowThread->mapDescendantToColumnSet(document().getElementById("bl
ock")->layoutObject()), columnSet); | 104 EXPECT_EQ(flowThread->mapDescendantToColumnSet(getLayoutObjectByElementId("b
lock")), columnSet); |
111 } | 105 } |
112 | 106 |
113 TEST_F(MultiColumnRenderingTest, TwoBlocks) | 107 TEST_F(MultiColumnRenderingTest, TwoBlocks) |
114 { | 108 { |
115 // No matter how much content, we should only create one column set (unless
there are spanners). | 109 // No matter how much content, we should only create one column set (unless
there are spanners). |
116 setMulticolHTML("<div id='mc'><div id='block1'></div><div id='block2'></div>
</div>"); | 110 setMulticolHTML("<div id='mc'><div id='block1'></div><div id='block2'></div>
</div>"); |
117 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); | 111 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); |
118 ASSERT_EQ(columnSetSignature(flowThread), "c"); | 112 ASSERT_EQ(columnSetSignature(flowThread), "c"); |
119 LayoutMultiColumnSet* columnSet = flowThread->firstMultiColumnSet(); | 113 LayoutMultiColumnSet* columnSet = flowThread->firstMultiColumnSet(); |
120 EXPECT_EQ(flowThread->mapDescendantToColumnSet(document().getElementById("bl
ock1")->layoutObject()), columnSet); | 114 EXPECT_EQ(flowThread->mapDescendantToColumnSet(getLayoutObjectByElementId("b
lock1")), columnSet); |
121 EXPECT_EQ(flowThread->mapDescendantToColumnSet(document().getElementById("bl
ock2")->layoutObject()), columnSet); | 115 EXPECT_EQ(flowThread->mapDescendantToColumnSet(getLayoutObjectByElementId("b
lock2")), columnSet); |
122 } | 116 } |
123 | 117 |
124 TEST_F(MultiColumnRenderingTest, Spanner) | 118 TEST_F(MultiColumnRenderingTest, Spanner) |
125 { | 119 { |
126 // With one spanner and no column content, we should create a spanner set. | 120 // With one spanner and no column content, we should create a spanner set. |
127 setMulticolHTML("<div id='mc'><div id='spanner'></div></div>"); | 121 setMulticolHTML("<div id='mc'><div id='spanner'></div></div>"); |
128 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); | 122 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); |
129 ASSERT_EQ(columnSetSignature(flowThread), "s"); | 123 ASSERT_EQ(columnSetSignature(flowThread), "s"); |
130 LayoutBox* columnBox = flowThread->firstMultiColumnBox(); | 124 LayoutBox* columnBox = flowThread->firstMultiColumnBox(); |
131 EXPECT_EQ(flowThread->firstMultiColumnSet(), nullptr); | 125 EXPECT_EQ(flowThread->firstMultiColumnSet(), nullptr); |
132 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(document().getEleme
ntById("spanner")->layoutObject()), columnBox); | 126 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(getLayoutObjectByEl
ementId("spanner")), columnBox); |
133 EXPECT_EQ(document().getElementById("spanner")->layoutObject()->spannerPlace
holder(), columnBox); | 127 EXPECT_EQ(getLayoutObjectByElementId("spanner")->spannerPlaceholder(), colum
nBox); |
134 } | 128 } |
135 | 129 |
136 TEST_F(MultiColumnRenderingTest, ContentThenSpanner) | 130 TEST_F(MultiColumnRenderingTest, ContentThenSpanner) |
137 { | 131 { |
138 // With some column content followed by a spanner, we need a column set foll
owed by a spanner set. | 132 // With some column content followed by a spanner, we need a column set foll
owed by a spanner set. |
139 setMulticolHTML("<div id='mc'><div id='columnContent'></div><div id='spanner
'></div></div>"); | 133 setMulticolHTML("<div id='mc'><div id='columnContent'></div><div id='spanner
'></div></div>"); |
140 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); | 134 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); |
141 ASSERT_EQ(columnSetSignature(flowThread), "cs"); | 135 ASSERT_EQ(columnSetSignature(flowThread), "cs"); |
142 LayoutBox* columnBox = flowThread->firstMultiColumnBox(); | 136 LayoutBox* columnBox = flowThread->firstMultiColumnBox(); |
143 EXPECT_EQ(flowThread->mapDescendantToColumnSet(document().getElementById("co
lumnContent")->layoutObject()), columnBox); | 137 EXPECT_EQ(flowThread->mapDescendantToColumnSet(getLayoutObjectByElementId("c
olumnContent")), columnBox); |
144 columnBox = columnBox->nextSiblingMultiColumnBox(); | 138 columnBox = columnBox->nextSiblingMultiColumnBox(); |
145 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(document().getEleme
ntById("spanner")->layoutObject()), columnBox); | 139 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(getLayoutObjectByEl
ementId("spanner")), columnBox); |
146 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(document().getEleme
ntById("columnContent")->layoutObject()), nullptr); | 140 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(getLayoutObjectByEl
ementId("columnContent")), nullptr); |
147 } | 141 } |
148 | 142 |
149 TEST_F(MultiColumnRenderingTest, SpannerThenContent) | 143 TEST_F(MultiColumnRenderingTest, SpannerThenContent) |
150 { | 144 { |
151 // With a spanner followed by some column content, we need a spanner set fol
lowed by a column set. | 145 // With a spanner followed by some column content, we need a spanner set fol
lowed by a column set. |
152 setMulticolHTML("<div id='mc'><div id='spanner'></div><div id='columnContent
'></div></div>"); | 146 setMulticolHTML("<div id='mc'><div id='spanner'></div><div id='columnContent
'></div></div>"); |
153 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); | 147 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); |
154 ASSERT_EQ(columnSetSignature(flowThread), "sc"); | 148 ASSERT_EQ(columnSetSignature(flowThread), "sc"); |
155 LayoutBox* columnBox = flowThread->firstMultiColumnBox(); | 149 LayoutBox* columnBox = flowThread->firstMultiColumnBox(); |
156 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(document().getEleme
ntById("spanner")->layoutObject()), columnBox); | 150 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(getLayoutObjectByEl
ementId("spanner")), columnBox); |
157 columnBox = columnBox->nextSiblingMultiColumnBox(); | 151 columnBox = columnBox->nextSiblingMultiColumnBox(); |
158 EXPECT_EQ(flowThread->mapDescendantToColumnSet(document().getElementById("co
lumnContent")->layoutObject()), columnBox); | 152 EXPECT_EQ(flowThread->mapDescendantToColumnSet(getLayoutObjectByElementId("c
olumnContent")), columnBox); |
159 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(document().getEleme
ntById("columnContent")->layoutObject()), nullptr); | 153 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(getLayoutObjectByEl
ementId("columnContent")), nullptr); |
160 } | 154 } |
161 | 155 |
162 TEST_F(MultiColumnRenderingTest, ContentThenSpannerThenContent) | 156 TEST_F(MultiColumnRenderingTest, ContentThenSpannerThenContent) |
163 { | 157 { |
164 // With column content followed by a spanner followed by some column content
, we need a column | 158 // With column content followed by a spanner followed by some column content
, we need a column |
165 // set followed by a spanner set followed by a column set. | 159 // set followed by a spanner set followed by a column set. |
166 setMulticolHTML("<div id='mc'><div id='columnContentBefore'></div><div id='s
panner'></div><div id='columnContentAfter'></div></div>"); | 160 setMulticolHTML("<div id='mc'><div id='columnContentBefore'></div><div id='s
panner'></div><div id='columnContentAfter'></div></div>"); |
167 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); | 161 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); |
168 ASSERT_EQ(columnSetSignature(flowThread), "csc"); | 162 ASSERT_EQ(columnSetSignature(flowThread), "csc"); |
169 LayoutBox* columnBox = flowThread->firstMultiColumnSet(); | 163 LayoutBox* columnBox = flowThread->firstMultiColumnSet(); |
170 EXPECT_EQ(flowThread->mapDescendantToColumnSet(document().getElementById("co
lumnContentBefore")->layoutObject()), columnBox); | 164 EXPECT_EQ(flowThread->mapDescendantToColumnSet(getLayoutObjectByElementId("c
olumnContentBefore")), columnBox); |
171 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(document().getEleme
ntById("columnContentBefore")->layoutObject()), nullptr); | 165 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(getLayoutObjectByEl
ementId("columnContentBefore")), nullptr); |
172 columnBox = columnBox->nextSiblingMultiColumnBox(); | 166 columnBox = columnBox->nextSiblingMultiColumnBox(); |
173 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(document().getEleme
ntById("spanner")->layoutObject()), columnBox); | 167 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(getLayoutObjectByEl
ementId("spanner")), columnBox); |
174 columnBox = columnBox->nextSiblingMultiColumnBox(); | 168 columnBox = columnBox->nextSiblingMultiColumnBox(); |
175 EXPECT_EQ(flowThread->mapDescendantToColumnSet(document().getElementById("co
lumnContentAfter")->layoutObject()), columnBox); | 169 EXPECT_EQ(flowThread->mapDescendantToColumnSet(getLayoutObjectByElementId("c
olumnContentAfter")), columnBox); |
176 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(document().getEleme
ntById("columnContentAfter")->layoutObject()), nullptr); | 170 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(getLayoutObjectByEl
ementId("columnContentAfter")), nullptr); |
177 } | 171 } |
178 | 172 |
179 TEST_F(MultiColumnRenderingTest, TwoSpanners) | 173 TEST_F(MultiColumnRenderingTest, TwoSpanners) |
180 { | 174 { |
181 // With two spanners and no column content, we need two spanner sets. | 175 // With two spanners and no column content, we need two spanner sets. |
182 setMulticolHTML("<div id='mc'><div id='spanner1'></div><div id='spanner2'></
div></div>"); | 176 setMulticolHTML("<div id='mc'><div id='spanner1'></div><div id='spanner2'></
div></div>"); |
183 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); | 177 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); |
184 ASSERT_EQ(columnSetSignature(flowThread), "ss"); | 178 ASSERT_EQ(columnSetSignature(flowThread), "ss"); |
185 LayoutBox* columnBox = flowThread->firstMultiColumnBox(); | 179 LayoutBox* columnBox = flowThread->firstMultiColumnBox(); |
186 EXPECT_EQ(flowThread->firstMultiColumnSet(), nullptr); | 180 EXPECT_EQ(flowThread->firstMultiColumnSet(), nullptr); |
187 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(document().getEleme
ntById("spanner1")->layoutObject()), columnBox); | 181 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(getLayoutObjectByEl
ementId("spanner1")), columnBox); |
188 EXPECT_EQ(document().getElementById("spanner1")->layoutObject()->spannerPlac
eholder(), columnBox); | 182 EXPECT_EQ(getLayoutObjectByElementId("spanner1")->spannerPlaceholder(), colu
mnBox); |
189 columnBox = columnBox->nextSiblingMultiColumnBox(); | 183 columnBox = columnBox->nextSiblingMultiColumnBox(); |
190 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(document().getEleme
ntById("spanner2")->layoutObject()), columnBox); | 184 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(getLayoutObjectByEl
ementId("spanner2")), columnBox); |
191 EXPECT_EQ(document().getElementById("spanner2")->layoutObject()->spannerPlac
eholder(), columnBox); | 185 EXPECT_EQ(getLayoutObjectByElementId("spanner2")->spannerPlaceholder(), colu
mnBox); |
192 } | 186 } |
193 | 187 |
194 TEST_F(MultiColumnRenderingTest, SpannerThenContentThenSpanner) | 188 TEST_F(MultiColumnRenderingTest, SpannerThenContentThenSpanner) |
195 { | 189 { |
196 // With two spanners and some column content in-between, we need a spanner s
et, a column set and another spanner set. | 190 // With two spanners and some column content in-between, we need a spanner s
et, a column set and another spanner set. |
197 setMulticolHTML("<div id='mc'><div id='spanner1'></div><div id='columnConten
t'></div><div id='spanner2'></div></div>"); | 191 setMulticolHTML("<div id='mc'><div id='spanner1'></div><div id='columnConten
t'></div><div id='spanner2'></div></div>"); |
198 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); | 192 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); |
199 ASSERT_EQ(columnSetSignature(flowThread), "scs"); | 193 ASSERT_EQ(columnSetSignature(flowThread), "scs"); |
200 LayoutMultiColumnSet* columnSet = flowThread->firstMultiColumnSet(); | 194 LayoutMultiColumnSet* columnSet = flowThread->firstMultiColumnSet(); |
201 EXPECT_EQ(columnSet->nextSiblingMultiColumnSet(), nullptr); | 195 EXPECT_EQ(columnSet->nextSiblingMultiColumnSet(), nullptr); |
202 LayoutBox* columnBox = flowThread->firstMultiColumnBox(); | 196 LayoutBox* columnBox = flowThread->firstMultiColumnBox(); |
203 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(document().getEleme
ntById("spanner1")->layoutObject()), columnBox); | 197 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(getLayoutObjectByEl
ementId("spanner1")), columnBox); |
204 columnBox = columnBox->nextSiblingMultiColumnBox(); | 198 columnBox = columnBox->nextSiblingMultiColumnBox(); |
205 EXPECT_EQ(columnBox, columnSet); | 199 EXPECT_EQ(columnBox, columnSet); |
206 EXPECT_EQ(flowThread->mapDescendantToColumnSet(document().getElementById("co
lumnContent")->layoutObject()), columnSet); | 200 EXPECT_EQ(flowThread->mapDescendantToColumnSet(getLayoutObjectByElementId("c
olumnContent")), columnSet); |
207 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(document().getEleme
ntById("columnContent")->layoutObject()), nullptr); | 201 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(getLayoutObjectByEl
ementId("columnContent")), nullptr); |
208 columnBox = columnBox->nextSiblingMultiColumnBox(); | 202 columnBox = columnBox->nextSiblingMultiColumnBox(); |
209 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(document().getEleme
ntById("spanner2")->layoutObject()), columnBox); | 203 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(getLayoutObjectByEl
ementId("spanner2")), columnBox); |
210 } | 204 } |
211 | 205 |
212 TEST_F(MultiColumnRenderingTest, SpannerWithSpanner) | 206 TEST_F(MultiColumnRenderingTest, SpannerWithSpanner) |
213 { | 207 { |
214 // column-span:all on something inside column-span:all has no effect. | 208 // column-span:all on something inside column-span:all has no effect. |
215 setMulticolHTML("<div id='mc'><div id='spanner'><div id='invalidSpanner' cla
ss='s'></div></div></div>"); | 209 setMulticolHTML("<div id='mc'><div id='spanner'><div id='invalidSpanner' cla
ss='s'></div></div></div>"); |
216 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); | 210 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); |
217 ASSERT_EQ(columnSetSignature(flowThread), "s"); | 211 ASSERT_EQ(columnSetSignature(flowThread), "s"); |
218 LayoutBox* columnBox = flowThread->firstMultiColumnBox(); | 212 LayoutBox* columnBox = flowThread->firstMultiColumnBox(); |
219 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(document().getEleme
ntById("spanner")->layoutObject()), columnBox); | 213 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(getLayoutObjectByEl
ementId("spanner")), columnBox); |
220 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(document().getEleme
ntById("invalidSpanner")->layoutObject()), columnBox); | 214 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(getLayoutObjectByEl
ementId("invalidSpanner")), columnBox); |
221 EXPECT_EQ(toLayoutMultiColumnSpannerPlaceholder(columnBox)->layoutObjectInFl
owThread(), document().getElementById("spanner")->layoutObject()); | 215 EXPECT_EQ(toLayoutMultiColumnSpannerPlaceholder(columnBox)->layoutObjectInFl
owThread(), getLayoutObjectByElementId("spanner")); |
222 EXPECT_EQ(document().getElementById("spanner")->layoutObject()->spannerPlace
holder(), columnBox); | 216 EXPECT_EQ(getLayoutObjectByElementId("spanner")->spannerPlaceholder(), colum
nBox); |
223 EXPECT_EQ(document().getElementById("invalidSpanner")->layoutObject()->spann
erPlaceholder(), nullptr); | 217 EXPECT_EQ(getLayoutObjectByElementId("invalidSpanner")->spannerPlaceholder()
, nullptr); |
224 } | 218 } |
225 | 219 |
226 TEST_F(MultiColumnRenderingTest, SubtreeWithSpanner) | 220 TEST_F(MultiColumnRenderingTest, SubtreeWithSpanner) |
227 { | 221 { |
228 setMulticolHTML("<div id='mc'><div id='outer'><div id='block1'></div><div id
='spanner'></div><div id='block2'></div></div></div>"); | 222 setMulticolHTML("<div id='mc'><div id='outer'><div id='block1'></div><div id
='spanner'></div><div id='block2'></div></div></div>"); |
229 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); | 223 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); |
230 EXPECT_EQ(columnSetSignature(flowThread), "csc"); | 224 EXPECT_EQ(columnSetSignature(flowThread), "csc"); |
231 LayoutBox* columnBox = flowThread->firstMultiColumnBox(); | 225 LayoutBox* columnBox = flowThread->firstMultiColumnBox(); |
232 EXPECT_EQ(flowThread->mapDescendantToColumnSet(document().getElementById("ou
ter")->layoutObject()), columnBox); | 226 EXPECT_EQ(flowThread->mapDescendantToColumnSet(getLayoutObjectByElementId("o
uter")), columnBox); |
233 EXPECT_EQ(flowThread->mapDescendantToColumnSet(document().getElementById("bl
ock1")->layoutObject()), columnBox); | 227 EXPECT_EQ(flowThread->mapDescendantToColumnSet(getLayoutObjectByElementId("b
lock1")), columnBox); |
234 columnBox = columnBox->nextSiblingMultiColumnBox(); | 228 columnBox = columnBox->nextSiblingMultiColumnBox(); |
235 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(document().getEleme
ntById("spanner")->layoutObject()), columnBox); | 229 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(getLayoutObjectByEl
ementId("spanner")), columnBox); |
236 EXPECT_EQ(document().getElementById("spanner")->layoutObject()->spannerPlace
holder(), columnBox); | 230 EXPECT_EQ(getLayoutObjectByElementId("spanner")->spannerPlaceholder(), colum
nBox); |
237 EXPECT_EQ(toLayoutMultiColumnSpannerPlaceholder(columnBox)->layoutObjectInFl
owThread(), document().getElementById("spanner")->layoutObject()); | 231 EXPECT_EQ(toLayoutMultiColumnSpannerPlaceholder(columnBox)->layoutObjectInFl
owThread(), getLayoutObjectByElementId("spanner")); |
238 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(document().getEleme
ntById("outer")->layoutObject()), nullptr); | 232 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(getLayoutObjectByEl
ementId("outer")), nullptr); |
239 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(document().getEleme
ntById("block1")->layoutObject()), nullptr); | 233 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(getLayoutObjectByEl
ementId("block1")), nullptr); |
240 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(document().getEleme
ntById("block2")->layoutObject()), nullptr); | 234 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(getLayoutObjectByEl
ementId("block2")), nullptr); |
241 columnBox = columnBox->nextSiblingMultiColumnBox(); | 235 columnBox = columnBox->nextSiblingMultiColumnBox(); |
242 EXPECT_EQ(flowThread->mapDescendantToColumnSet(document().getElementById("bl
ock2")->layoutObject()), columnBox); | 236 EXPECT_EQ(flowThread->mapDescendantToColumnSet(getLayoutObjectByElementId("b
lock2")), columnBox); |
243 } | 237 } |
244 | 238 |
245 TEST_F(MultiColumnRenderingTest, SubtreeWithSpannerAfterSpanner) | 239 TEST_F(MultiColumnRenderingTest, SubtreeWithSpannerAfterSpanner) |
246 { | 240 { |
247 setMulticolHTML("<div id='mc'><div id='spanner1'></div><div id='outer'>text<
div id='spanner2'></div><div id='after'></div></div></div>"); | 241 setMulticolHTML("<div id='mc'><div id='spanner1'></div><div id='outer'>text<
div id='spanner2'></div><div id='after'></div></div></div>"); |
248 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); | 242 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); |
249 EXPECT_EQ(columnSetSignature(flowThread), "scsc"); | 243 EXPECT_EQ(columnSetSignature(flowThread), "scsc"); |
250 LayoutBox* columnBox = flowThread->firstMultiColumnBox(); | 244 LayoutBox* columnBox = flowThread->firstMultiColumnBox(); |
251 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(document().getEleme
ntById("spanner1")->layoutObject()), columnBox); | 245 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(getLayoutObjectByEl
ementId("spanner1")), columnBox); |
252 EXPECT_EQ(toLayoutMultiColumnSpannerPlaceholder(columnBox)->layoutObjectInFl
owThread(), document().getElementById("spanner1")->layoutObject()); | 246 EXPECT_EQ(toLayoutMultiColumnSpannerPlaceholder(columnBox)->layoutObjectInFl
owThread(), getLayoutObjectByElementId("spanner1")); |
253 EXPECT_EQ(document().getElementById("spanner1")->layoutObject()->spannerPlac
eholder(), columnBox); | 247 EXPECT_EQ(getLayoutObjectByElementId("spanner1")->spannerPlaceholder(), colu
mnBox); |
254 columnBox = columnBox->nextSiblingMultiColumnBox(); | 248 columnBox = columnBox->nextSiblingMultiColumnBox(); |
255 EXPECT_EQ(flowThread->mapDescendantToColumnSet(document().getElementById("ou
ter")->layoutObject()), columnBox); | 249 EXPECT_EQ(flowThread->mapDescendantToColumnSet(getLayoutObjectByElementId("o
uter")), columnBox); |
256 columnBox = columnBox->nextSiblingMultiColumnBox(); | 250 columnBox = columnBox->nextSiblingMultiColumnBox(); |
257 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(document().getEleme
ntById("spanner2")->layoutObject()), columnBox); | 251 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(getLayoutObjectByEl
ementId("spanner2")), columnBox); |
258 EXPECT_EQ(toLayoutMultiColumnSpannerPlaceholder(columnBox)->layoutObjectInFl
owThread(), document().getElementById("spanner2")->layoutObject()); | 252 EXPECT_EQ(toLayoutMultiColumnSpannerPlaceholder(columnBox)->layoutObjectInFl
owThread(), getLayoutObjectByElementId("spanner2")); |
259 EXPECT_EQ(document().getElementById("spanner2")->layoutObject()->spannerPlac
eholder(), columnBox); | 253 EXPECT_EQ(getLayoutObjectByElementId("spanner2")->spannerPlaceholder(), colu
mnBox); |
260 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(document().getEleme
ntById("outer")->layoutObject()), nullptr); | 254 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(getLayoutObjectByEl
ementId("outer")), nullptr); |
261 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(document().getEleme
ntById("after")->layoutObject()), nullptr); | 255 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(getLayoutObjectByEl
ementId("after")), nullptr); |
262 columnBox = columnBox->nextSiblingMultiColumnBox(); | 256 columnBox = columnBox->nextSiblingMultiColumnBox(); |
263 EXPECT_EQ(flowThread->mapDescendantToColumnSet(document().getElementById("af
ter")->layoutObject()), columnBox); | 257 EXPECT_EQ(flowThread->mapDescendantToColumnSet(getLayoutObjectByElementId("a
fter")), columnBox); |
264 } | 258 } |
265 | 259 |
266 TEST_F(MultiColumnRenderingTest, SubtreeWithSpannerBeforeSpanner) | 260 TEST_F(MultiColumnRenderingTest, SubtreeWithSpannerBeforeSpanner) |
267 { | 261 { |
268 setMulticolHTML("<div id='mc'><div id='outer'>text<div id='spanner1'></div>t
ext</div><div id='spanner2'></div></div>"); | 262 setMulticolHTML("<div id='mc'><div id='outer'>text<div id='spanner1'></div>t
ext</div><div id='spanner2'></div></div>"); |
269 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); | 263 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); |
270 EXPECT_EQ(columnSetSignature(flowThread), "cscs"); | 264 EXPECT_EQ(columnSetSignature(flowThread), "cscs"); |
271 LayoutBox* columnBox = flowThread->firstMultiColumnSet(); | 265 LayoutBox* columnBox = flowThread->firstMultiColumnSet(); |
272 EXPECT_EQ(flowThread->mapDescendantToColumnSet(document().getElementById("ou
ter")->layoutObject()), columnBox); | 266 EXPECT_EQ(flowThread->mapDescendantToColumnSet(getLayoutObjectByElementId("o
uter")), columnBox); |
273 columnBox = columnBox->nextSiblingMultiColumnBox(); | 267 columnBox = columnBox->nextSiblingMultiColumnBox(); |
274 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(document().getEleme
ntById("spanner1")->layoutObject()), columnBox); | 268 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(getLayoutObjectByEl
ementId("spanner1")), columnBox); |
275 EXPECT_EQ(document().getElementById("spanner1")->layoutObject()->spannerPlac
eholder(), columnBox); | 269 EXPECT_EQ(getLayoutObjectByElementId("spanner1")->spannerPlaceholder(), colu
mnBox); |
276 EXPECT_EQ(toLayoutMultiColumnSpannerPlaceholder(columnBox)->layoutObjectInFl
owThread(), document().getElementById("spanner1")->layoutObject()); | 270 EXPECT_EQ(toLayoutMultiColumnSpannerPlaceholder(columnBox)->layoutObjectInFl
owThread(), getLayoutObjectByElementId("spanner1")); |
277 columnBox = columnBox->nextSiblingMultiColumnBox()->nextSiblingMultiColumnBo
x(); | 271 columnBox = columnBox->nextSiblingMultiColumnBox()->nextSiblingMultiColumnBo
x(); |
278 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(document().getEleme
ntById("spanner2")->layoutObject()), columnBox); | 272 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(getLayoutObjectByEl
ementId("spanner2")), columnBox); |
279 EXPECT_EQ(document().getElementById("spanner2")->layoutObject()->spannerPlac
eholder(), columnBox); | 273 EXPECT_EQ(getLayoutObjectByElementId("spanner2")->spannerPlaceholder(), colu
mnBox); |
280 EXPECT_EQ(toLayoutMultiColumnSpannerPlaceholder(columnBox)->layoutObjectInFl
owThread(), document().getElementById("spanner2")->layoutObject()); | 274 EXPECT_EQ(toLayoutMultiColumnSpannerPlaceholder(columnBox)->layoutObjectInFl
owThread(), getLayoutObjectByElementId("spanner2")); |
281 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(document().getEleme
ntById("outer")->layoutObject()), nullptr); | 275 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder(getLayoutObjectByEl
ementId("outer")), nullptr); |
282 } | 276 } |
283 | 277 |
284 TEST_F(MultiColumnRenderingTest, columnSetAtBlockOffset) | 278 TEST_F(MultiColumnRenderingTest, columnSetAtBlockOffset) |
285 { | 279 { |
286 setMulticolHTML("<div id='mc' style='line-height:100px;'>text<br>text<br>tex
t<br>text<br>text<div id='spanner1'>spanner</div>text<br>text<div id='spanner2'>
text<br>text</div>text</div>"); | 280 setMulticolHTML("<div id='mc' style='line-height:100px;'>text<br>text<br>tex
t<br>text<br>text<div id='spanner1'>spanner</div>text<br>text<div id='spanner2'>
text<br>text</div>text</div>"); |
287 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); | 281 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); |
288 EXPECT_EQ(columnSetSignature(flowThread), "cscsc"); | 282 EXPECT_EQ(columnSetSignature(flowThread), "cscsc"); |
289 LayoutMultiColumnSet* firstRow = flowThread->firstMultiColumnSet(); | 283 LayoutMultiColumnSet* firstRow = flowThread->firstMultiColumnSet(); |
290 EXPECT_EQ(flowThread->columnSetAtBlockOffset(LayoutUnit(-10000)), firstRow);
// negative overflow | 284 EXPECT_EQ(flowThread->columnSetAtBlockOffset(LayoutUnit(-10000)), firstRow);
// negative overflow |
291 EXPECT_EQ(flowThread->columnSetAtBlockOffset(LayoutUnit()), firstRow); | 285 EXPECT_EQ(flowThread->columnSetAtBlockOffset(LayoutUnit()), firstRow); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 | 339 |
346 void MultiColumnTreeModifyingTest::setMulticolHTML(const char* html) | 340 void MultiColumnTreeModifyingTest::setMulticolHTML(const char* html) |
347 { | 341 { |
348 MultiColumnRenderingTest::setMulticolHTML(html); | 342 MultiColumnRenderingTest::setMulticolHTML(html); |
349 // Allow modifications to the layout tree structure, because that's what we
want to test. | 343 // Allow modifications to the layout tree structure, because that's what we
want to test. |
350 document().lifecycle().advanceTo(DocumentLifecycle::InStyleRecalc); | 344 document().lifecycle().advanceTo(DocumentLifecycle::InStyleRecalc); |
351 } | 345 } |
352 | 346 |
353 void MultiColumnTreeModifyingTest::reparentLayoutObject(const char* newParentId,
const char* childId, const char* insertBeforeId) | 347 void MultiColumnTreeModifyingTest::reparentLayoutObject(const char* newParentId,
const char* childId, const char* insertBeforeId) |
354 { | 348 { |
355 LayoutObject* newParent = document().getElementById(newParentId)->layoutObje
ct(); | 349 LayoutObject* newParent = getLayoutObjectByElementId(newParentId); |
356 LayoutObject* child = document().getElementById(childId)->layoutObject(); | 350 LayoutObject* child = getLayoutObjectByElementId(childId); |
357 LayoutObject* insertBefore = insertBeforeId ? document().getElementById(inse
rtBeforeId)->layoutObject() : nullptr; | 351 LayoutObject* insertBefore = insertBeforeId ? getLayoutObjectByElementId(ins
ertBeforeId) : nullptr; |
358 child->remove(); | 352 child->remove(); |
359 newParent->addChild(child, insertBefore); | 353 newParent->addChild(child, insertBefore); |
360 } | 354 } |
361 | 355 |
362 void MultiColumnTreeModifyingTest::destroyLayoutObject(LayoutObject* child) | 356 void MultiColumnTreeModifyingTest::destroyLayoutObject(LayoutObject* child) |
363 { | 357 { |
364 // Remove and destroy in separate steps, so that we get to test removal of s
ubtrees. | 358 // Remove and destroy in separate steps, so that we get to test removal of s
ubtrees. |
365 child->remove(); | 359 child->remove(); |
366 child->node()->detach(); | 360 child->node()->detach(); |
367 } | 361 } |
368 | 362 |
369 void MultiColumnTreeModifyingTest::destroyLayoutObject(const char* childId) | 363 void MultiColumnTreeModifyingTest::destroyLayoutObject(const char* childId) |
370 { | 364 { |
371 destroyLayoutObject(document().getElementById(childId)->layoutObject()); | 365 destroyLayoutObject(getLayoutObjectByElementId(childId)); |
372 } | 366 } |
373 | 367 |
374 TEST_F(MultiColumnTreeModifyingTest, InsertFirstContentAndRemove) | 368 TEST_F(MultiColumnTreeModifyingTest, InsertFirstContentAndRemove) |
375 { | 369 { |
376 setMulticolHTML("<div id='block'></div><div id='mc'></div>"); | 370 setMulticolHTML("<div id='block'></div><div id='mc'></div>"); |
377 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); | 371 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); |
378 LayoutBlockFlow* block = toLayoutBlockFlow(document().getElementById("block"
)->layoutObject()); | 372 LayoutBlockFlow* block = toLayoutBlockFlow(getLayoutObjectByElementId("block
")); |
379 LayoutBlockFlow* multicolContainer = toLayoutBlockFlow(document().getElement
ById("mc")->layoutObject()); | 373 LayoutBlockFlow* multicolContainer = toLayoutBlockFlow(getLayoutObjectByElem
entId("mc")); |
380 block->remove(); | 374 block->remove(); |
381 multicolContainer->addChild(block); | 375 multicolContainer->addChild(block); |
382 EXPECT_EQ(block->parent(), flowThread); | 376 EXPECT_EQ(block->parent(), flowThread); |
383 // A set should have appeared, now that the multicol container has content. | 377 // A set should have appeared, now that the multicol container has content. |
384 EXPECT_EQ(columnSetSignature(flowThread), "c"); | 378 EXPECT_EQ(columnSetSignature(flowThread), "c"); |
385 | 379 |
386 destroyLayoutObject(block); | 380 destroyLayoutObject(block); |
387 // The set should be gone again now, since there's nothing inside the multic
ol container anymore. | 381 // The set should be gone again now, since there's nothing inside the multic
ol container anymore. |
388 EXPECT_EQ(columnSetSignature("mc"), ""); | 382 EXPECT_EQ(columnSetSignature("mc"), ""); |
389 } | 383 } |
(...skipping 19 matching lines...) Expand all Loading... |
409 EXPECT_EQ(columnSetSignature("mc"), "c"); | 403 EXPECT_EQ(columnSetSignature("mc"), "c"); |
410 destroyLayoutObject("block"); | 404 destroyLayoutObject("block"); |
411 // There's still some content after the removal, so the set should remain. | 405 // There's still some content after the removal, so the set should remain. |
412 EXPECT_EQ(columnSetSignature("mc"), "c"); | 406 EXPECT_EQ(columnSetSignature("mc"), "c"); |
413 } | 407 } |
414 | 408 |
415 TEST_F(MultiColumnTreeModifyingTest, InsertSpannerAndRemove) | 409 TEST_F(MultiColumnTreeModifyingTest, InsertSpannerAndRemove) |
416 { | 410 { |
417 setMulticolHTML("<div id='spanner'></div><div id='mc'></div>"); | 411 setMulticolHTML("<div id='spanner'></div><div id='mc'></div>"); |
418 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); | 412 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); |
419 LayoutBlockFlow* spanner = toLayoutBlockFlow(document().getElementById("span
ner")->layoutObject()); | 413 LayoutBlockFlow* spanner = toLayoutBlockFlow(getLayoutObjectByElementId("spa
nner")); |
420 LayoutBlockFlow* multicolContainer = toLayoutBlockFlow(document().getElement
ById("mc")->layoutObject()); | 414 LayoutBlockFlow* multicolContainer = toLayoutBlockFlow(getLayoutObjectByElem
entId("mc")); |
421 spanner->remove(); | 415 spanner->remove(); |
422 multicolContainer->addChild(spanner); | 416 multicolContainer->addChild(spanner); |
423 EXPECT_EQ(spanner->parent(), flowThread); | 417 EXPECT_EQ(spanner->parent(), flowThread); |
424 // We should now have a spanner placeholder, since we just moved a spanner i
nto the multicol container. | 418 // We should now have a spanner placeholder, since we just moved a spanner i
nto the multicol container. |
425 EXPECT_EQ(columnSetSignature(flowThread), "s"); | 419 EXPECT_EQ(columnSetSignature(flowThread), "s"); |
426 destroyLayoutObject(spanner); | 420 destroyLayoutObject(spanner); |
427 EXPECT_EQ(columnSetSignature(flowThread), ""); | 421 EXPECT_EQ(columnSetSignature(flowThread), ""); |
428 } | 422 } |
429 | 423 |
430 TEST_F(MultiColumnTreeModifyingTest, InsertTwoSpannersAndRemove) | 424 TEST_F(MultiColumnTreeModifyingTest, InsertTwoSpannersAndRemove) |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 { | 785 { |
792 setMulticolHTML("<div id='mc'>text<div id='spanner'><div class='s'></div></d
iv>text</div>"); | 786 setMulticolHTML("<div id='mc'>text<div id='spanner'><div class='s'></div></d
iv>text</div>"); |
793 EXPECT_EQ(columnSetSignature("mc"), "csc"); | 787 EXPECT_EQ(columnSetSignature("mc"), "csc"); |
794 destroyLayoutObject("spanner"); | 788 destroyLayoutObject("spanner"); |
795 EXPECT_EQ(columnSetSignature("mc"), "c"); | 789 EXPECT_EQ(columnSetSignature("mc"), "c"); |
796 } | 790 } |
797 | 791 |
798 } // anonymous namespace | 792 } // anonymous namespace |
799 | 793 |
800 } // namespace blink | 794 } // namespace blink |
OLD | NEW |