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 "config.h" | 5 #include "config.h" |
6 #include "platform/graphics/paint/DisplayItemList.h" | 6 #include "platform/graphics/paint/DisplayItemList.h" |
7 | 7 |
8 #include "core/layout/LayoutTestHelper.h" | 8 #include "core/layout/LayoutTestHelper.h" |
9 #include "core/layout/LayoutText.h" | 9 #include "core/layout/LayoutText.h" |
10 #include "core/layout/LayoutView.h" | 10 #include "core/layout/LayoutView.h" |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(Pa
intPhaseForeground)), | 214 TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(Pa
intPhaseForeground)), |
215 TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseForeground))); | 215 TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseForeground))); |
216 } | 216 } |
217 | 217 |
218 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, FullDocumentPaintingWithCaret
) | 218 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, FullDocumentPaintingWithCaret
) |
219 { | 219 { |
220 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'>
XYZ</div>"); | 220 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'>
XYZ</div>"); |
221 document().page()->focusController().setActive(true); | 221 document().page()->focusController().setActive(true); |
222 document().page()->focusController().setFocused(true); | 222 document().page()->focusController().setFocused(true); |
223 LayoutView& layoutView = *document().layoutView(); | 223 LayoutView& layoutView = *document().layoutView(); |
224 LayoutObject& html = *document().documentElement()->layoutObject(); | 224 DeprecatedPaintLayer& htmlLayer = *toLayoutBoxModelObject(document().documen
tElement()->layoutObject())->layer(); |
225 Element& div = *toElement(document().body()->firstChild()); | 225 Element& div = *toElement(document().body()->firstChild()); |
226 LayoutObject& divLayoutObject = *document().body()->firstChild()->layoutObje
ct(); | 226 LayoutObject& divLayoutObject = *document().body()->firstChild()->layoutObje
ct(); |
227 InlineTextBox& textInlineBox = *toLayoutText(div.firstChild()->layoutObject(
))->firstTextBox(); | 227 InlineTextBox& textInlineBox = *toLayoutText(div.firstChild()->layoutObject(
))->firstTextBox(); |
228 | 228 |
229 document().view()->updateAllLifecyclePhases(); | 229 document().view()->updateAllLifecyclePhases(); |
230 | 230 |
231 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem
s(), 4, | 231 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem
s(), 4, |
232 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), | 232 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), |
233 TestDisplayItem(html, DisplayItem::BeginSubsequence), | 233 TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence), |
234 TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseForeground)), | 234 TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseForeground)), |
235 TestDisplayItem(html, DisplayItem::EndSubsequence)); | 235 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence)); |
236 | 236 |
237 div.focus(); | 237 div.focus(); |
238 document().view()->updateAllLifecyclePhases(); | 238 document().view()->updateAllLifecyclePhases(); |
239 | 239 |
240 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem
s(), 5, | 240 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem
s(), 5, |
241 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), | 241 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), |
242 TestDisplayItem(html, DisplayItem::BeginSubsequence), | 242 TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence), |
243 TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseForeground)), | 243 TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseForeground)), |
244 TestDisplayItem(divLayoutObject, DisplayItem::Caret), // New! | 244 TestDisplayItem(divLayoutObject, DisplayItem::Caret), // New! |
245 TestDisplayItem(html, DisplayItem::EndSubsequence)); | 245 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence)); |
246 } | 246 } |
247 | 247 |
248 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, InlineRelayout) | 248 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, InlineRelayout) |
249 { | 249 { |
250 setBodyInnerHTML("<div id='div' style='width:100px; height: 200px'>AAAAAAAAA
A BBBBBBBBBB</div>"); | 250 setBodyInnerHTML("<div id='div' style='width:100px; height: 200px'>AAAAAAAAA
A BBBBBBBBBB</div>"); |
251 LayoutView& layoutView = *document().layoutView(); | 251 LayoutView& layoutView = *document().layoutView(); |
252 LayoutObject& html = *document().documentElement()->layoutObject(); | 252 DeprecatedPaintLayer& htmlLayer = *toLayoutBoxModelObject(document().documen
tElement()->layoutObject())->layer(); |
253 Element& div = *toElement(document().body()->firstChild()); | 253 Element& div = *toElement(document().body()->firstChild()); |
254 LayoutBlock& divBlock = *toLayoutBlock(document().body()->firstChild()->layo
utObject()); | 254 LayoutBlock& divBlock = *toLayoutBlock(document().body()->firstChild()->layo
utObject()); |
255 LayoutText& text = *toLayoutText(divBlock.firstChild()); | 255 LayoutText& text = *toLayoutText(divBlock.firstChild()); |
256 InlineTextBox& firstTextBox = *text.firstTextBox(); | 256 InlineTextBox& firstTextBox = *text.firstTextBox(); |
257 | 257 |
258 document().view()->updateAllLifecyclePhases(); | 258 document().view()->updateAllLifecyclePhases(); |
259 | 259 |
260 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem
s(), 4, | 260 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem
s(), 4, |
261 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), | 261 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), |
262 TestDisplayItem(html, DisplayItem::BeginSubsequence), | 262 TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence), |
263 TestDisplayItem(firstTextBox, DisplayItem::paintPhaseToDrawingType(Paint
PhaseForeground)), | 263 TestDisplayItem(firstTextBox, DisplayItem::paintPhaseToDrawingType(Paint
PhaseForeground)), |
264 TestDisplayItem(html, DisplayItem::EndSubsequence)); | 264 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence)); |
265 | 265 |
266 div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px"); | 266 div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px"); |
267 document().view()->updateAllLifecyclePhases(); | 267 document().view()->updateAllLifecyclePhases(); |
268 | 268 |
269 LayoutText& newText = *toLayoutText(divBlock.firstChild()); | 269 LayoutText& newText = *toLayoutText(divBlock.firstChild()); |
270 InlineTextBox& newFirstTextBox = *newText.firstTextBox(); | 270 InlineTextBox& newFirstTextBox = *newText.firstTextBox(); |
271 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox(); | 271 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox(); |
272 | 272 |
273 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem
s(), 5, | 273 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem
s(), 5, |
274 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), | 274 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), |
275 TestDisplayItem(html, DisplayItem::BeginSubsequence), | 275 TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence), |
276 TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(Pa
intPhaseForeground)), | 276 TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(Pa
intPhaseForeground)), |
277 TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseForeground)), | 277 TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseForeground)), |
278 TestDisplayItem(html, DisplayItem::EndSubsequence)); | 278 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence)); |
279 } | 279 } |
280 | 280 |
281 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, CachedSubsequence) | 281 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, CachedSubsequence) |
282 { | 282 { |
283 setBodyInnerHTML( | 283 setBodyInnerHTML( |
284 "<div id='container1' style='position: relative; width: 200px; height: 2
00px; background-color: blue'>" | 284 "<div id='container1' style='position: relative; width: 200px; height: 2
00px; background-color: blue'>" |
285 " <div id='content1' style='width: 100px; height: 100px; background-col
or: red'></div>" | 285 " <div id='content1' style='width: 100px; height: 100px; background-col
or: red'></div>" |
286 "</div>" | 286 "</div>" |
287 "<div id='container2' style='position: relative; width: 200px; height: 2
00px; background-color: blue'>" | 287 "<div id='container2' style='position: relative; width: 200px; height: 2
00px; background-color: blue'>" |
288 " <div id='content2' style='width: 100px; height: 100px; background-col
or: green'></div>" | 288 " <div id='content2' style='width: 100px; height: 100px; background-col
or: green'></div>" |
289 "</div>"); | 289 "</div>"); |
290 document().view()->updateAllLifecyclePhases(); | 290 document().view()->updateAllLifecyclePhases(); |
291 | 291 |
292 LayoutView& layoutView = *document().layoutView(); | 292 LayoutView& layoutView = *document().layoutView(); |
293 LayoutObject& html = *document().documentElement()->layoutObject(); | 293 DeprecatedPaintLayer& htmlLayer = *toLayoutBoxModelObject(document().documen
tElement()->layoutObject())->layer(); |
294 LayoutObject& container1 = *document().getElementById("container1")->layoutO
bject(); | 294 LayoutObject& container1 = *document().getElementById("container1")->layoutO
bject(); |
| 295 DeprecatedPaintLayer& container1Layer = *toLayoutBoxModelObject(container1).
layer(); |
295 LayoutObject& content1 = *document().getElementById("content1")->layoutObjec
t(); | 296 LayoutObject& content1 = *document().getElementById("content1")->layoutObjec
t(); |
296 LayoutObject& container2 = *document().getElementById("container2")->layoutO
bject(); | 297 LayoutObject& container2 = *document().getElementById("container2")->layoutO
bject(); |
| 298 DeprecatedPaintLayer& container2Layer = *toLayoutBoxModelObject(container2).
layer(); |
297 LayoutObject& content2 = *document().getElementById("content2")->layoutObjec
t(); | 299 LayoutObject& content2 = *document().getElementById("content2")->layoutObjec
t(); |
298 | 300 |
299 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem
s(), 11, | 301 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem
s(), 11, |
300 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), | 302 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), |
301 TestDisplayItem(html, DisplayItem::BeginSubsequence), | 303 TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence), |
302 TestDisplayItem(container1, DisplayItem::BeginSubsequence), | 304 TestDisplayItem(container1Layer, DisplayItem::BeginSubsequence), |
303 TestDisplayItem(container1, DisplayItem::BoxDecorationBackground), | 305 TestDisplayItem(container1, DisplayItem::BoxDecorationBackground), |
304 TestDisplayItem(content1, DisplayItem::BoxDecorationBackground), | 306 TestDisplayItem(content1, DisplayItem::BoxDecorationBackground), |
305 TestDisplayItem(container1, DisplayItem::EndSubsequence), | 307 TestDisplayItem(container1Layer, DisplayItem::EndSubsequence), |
306 TestDisplayItem(container2, DisplayItem::BeginSubsequence), | 308 TestDisplayItem(container2Layer, DisplayItem::BeginSubsequence), |
307 TestDisplayItem(container2, DisplayItem::BoxDecorationBackground), | 309 TestDisplayItem(container2, DisplayItem::BoxDecorationBackground), |
308 TestDisplayItem(content2, DisplayItem::BoxDecorationBackground), | 310 TestDisplayItem(content2, DisplayItem::BoxDecorationBackground), |
309 TestDisplayItem(container2, DisplayItem::EndSubsequence), | 311 TestDisplayItem(container2Layer, DisplayItem::EndSubsequence), |
310 TestDisplayItem(html, DisplayItem::EndSubsequence)); | 312 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence)); |
311 | 313 |
312 toHTMLElement(content1.node())->setAttribute(HTMLNames::styleAttr, "width: 1
00px; height: 100px; background-color: green"); | 314 toHTMLElement(content1.node())->setAttribute(HTMLNames::styleAttr, "width: 1
00px; height: 100px; background-color: green"); |
313 updateLifecyclePhasesToPaintForSlimmingPaintV2Clean(); | 315 updateLifecyclePhasesToPaintForSlimmingPaintV2Clean(); |
314 | 316 |
315 EXPECT_DISPLAY_LIST_WITH_CACHED_RED_FILL_IN_DEBUG(newDisplayItemsBeforeUpdat
e(), 8, | 317 EXPECT_DISPLAY_LIST_WITH_CACHED_RED_FILL_IN_DEBUG(newDisplayItemsBeforeUpdat
e(), 8, |
316 TestDisplayItem(layoutView, DisplayItem::drawingTypeToCachedDrawingType(
DisplayItem::BoxDecorationBackground)), | 318 TestDisplayItem(layoutView, DisplayItem::drawingTypeToCachedDrawingType(
DisplayItem::BoxDecorationBackground)), |
317 TestDisplayItem(html, DisplayItem::BeginSubsequence), | 319 TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence), |
318 TestDisplayItem(container1, DisplayItem::BeginSubsequence), | 320 TestDisplayItem(container1Layer, DisplayItem::BeginSubsequence), |
319 TestDisplayItem(container1, DisplayItem::drawingTypeToCachedDrawingType(
DisplayItem::BoxDecorationBackground)), | 321 TestDisplayItem(container1, DisplayItem::drawingTypeToCachedDrawingType(
DisplayItem::BoxDecorationBackground)), |
320 TestDisplayItem(content1, DisplayItem::BoxDecorationBackground), | 322 TestDisplayItem(content1, DisplayItem::BoxDecorationBackground), |
321 TestDisplayItem(container1, DisplayItem::EndSubsequence), | 323 TestDisplayItem(container1Layer, DisplayItem::EndSubsequence), |
322 TestDisplayItem(container2, DisplayItem::CachedSubsequence), | 324 TestDisplayItem(container2Layer, DisplayItem::CachedSubsequence), |
323 TestDisplayItem(html, DisplayItem::EndSubsequence)); | 325 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence)); |
324 | 326 |
325 compositeForSlimmingPaintV2(); | 327 compositeForSlimmingPaintV2(); |
326 | 328 |
327 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem
s(), 11, | 329 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem
s(), 11, |
328 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), | 330 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), |
329 TestDisplayItem(html, DisplayItem::BeginSubsequence), | 331 TestDisplayItem(htmlLayer, DisplayItem::BeginSubsequence), |
330 TestDisplayItem(container1, DisplayItem::BeginSubsequence), | 332 TestDisplayItem(container1Layer, DisplayItem::BeginSubsequence), |
331 TestDisplayItem(container1, DisplayItem::BoxDecorationBackground), | 333 TestDisplayItem(container1, DisplayItem::BoxDecorationBackground), |
332 TestDisplayItem(content1, DisplayItem::BoxDecorationBackground), | 334 TestDisplayItem(content1, DisplayItem::BoxDecorationBackground), |
333 TestDisplayItem(container1, DisplayItem::EndSubsequence), | 335 TestDisplayItem(container1Layer, DisplayItem::EndSubsequence), |
334 TestDisplayItem(container2, DisplayItem::BeginSubsequence), | 336 TestDisplayItem(container2Layer, DisplayItem::BeginSubsequence), |
335 TestDisplayItem(container2, DisplayItem::BoxDecorationBackground), | 337 TestDisplayItem(container2, DisplayItem::BoxDecorationBackground), |
336 TestDisplayItem(content2, DisplayItem::BoxDecorationBackground), | 338 TestDisplayItem(content2, DisplayItem::BoxDecorationBackground), |
337 TestDisplayItem(container2, DisplayItem::EndSubsequence), | 339 TestDisplayItem(container2Layer, DisplayItem::EndSubsequence), |
338 TestDisplayItem(html, DisplayItem::EndSubsequence)); | 340 TestDisplayItem(htmlLayer, DisplayItem::EndSubsequence)); |
339 } | 341 } |
340 | 342 |
341 } // namespace blink | 343 } // namespace blink |
OLD | NEW |