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

Side by Side Diff: Source/core/paint/DisplayItemListPaintTest.cpp

Issue 1284203004: Generate scroll/clip display item hierarchy for SPv2 (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix failing test. Update test expectation. Created 5 years, 3 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 | Annotate | Revision Log
OLDNEW
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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 LayoutObject& html = *document().documentElement()->layoutObject();
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(), 5,
232 TestDisplayItem(layoutView, DisplayItem::FixedPositionContainer),
232 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), 233 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground),
233 TestDisplayItem(html, DisplayItem::BeginSubsequence), 234 TestDisplayItem(html, DisplayItem::BeginSubsequence),
234 TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground)), 235 TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground)),
235 TestDisplayItem(html, DisplayItem::EndSubsequence)); 236 TestDisplayItem(html, DisplayItem::EndSubsequence));
236 237
237 div.focus(); 238 div.focus();
238 document().view()->updateAllLifecyclePhases(); 239 document().view()->updateAllLifecyclePhases();
239 240
240 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 5, 241 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 6,
242 TestDisplayItem(layoutView, DisplayItem::FixedPositionContainer),
241 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), 243 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground),
242 TestDisplayItem(html, DisplayItem::BeginSubsequence), 244 TestDisplayItem(html, DisplayItem::BeginSubsequence),
243 TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground)), 245 TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground)),
244 TestDisplayItem(divLayoutObject, DisplayItem::Caret), // New! 246 TestDisplayItem(divLayoutObject, DisplayItem::Caret), // New!
245 TestDisplayItem(html, DisplayItem::EndSubsequence)); 247 TestDisplayItem(html, DisplayItem::EndSubsequence));
246 } 248 }
247 249
248 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, InlineRelayout) 250 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, InlineRelayout)
249 { 251 {
250 setBodyInnerHTML("<div id='div' style='width:100px; height: 200px'>AAAAAAAAA A BBBBBBBBBB</div>"); 252 setBodyInnerHTML("<div id='div' style='width:100px; height: 200px'>AAAAAAAAA A BBBBBBBBBB</div>");
251 LayoutView& layoutView = *document().layoutView(); 253 LayoutView& layoutView = *document().layoutView();
252 LayoutObject& html = *document().documentElement()->layoutObject(); 254 LayoutObject& html = *document().documentElement()->layoutObject();
253 Element& div = *toElement(document().body()->firstChild()); 255 Element& div = *toElement(document().body()->firstChild());
254 LayoutBlock& divBlock = *toLayoutBlock(document().body()->firstChild()->layo utObject()); 256 LayoutBlock& divBlock = *toLayoutBlock(document().body()->firstChild()->layo utObject());
255 LayoutText& text = *toLayoutText(divBlock.firstChild()); 257 LayoutText& text = *toLayoutText(divBlock.firstChild());
256 InlineTextBox& firstTextBox = *text.firstTextBox(); 258 InlineTextBox& firstTextBox = *text.firstTextBox();
257 259
258 document().view()->updateAllLifecyclePhases(); 260 document().view()->updateAllLifecyclePhases();
259 261
260 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 4, 262 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 5,
263 TestDisplayItem(layoutView, DisplayItem::FixedPositionContainer),
261 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), 264 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground),
262 TestDisplayItem(html, DisplayItem::BeginSubsequence), 265 TestDisplayItem(html, DisplayItem::BeginSubsequence),
263 TestDisplayItem(firstTextBox, DisplayItem::paintPhaseToDrawingType(Paint PhaseForeground)), 266 TestDisplayItem(firstTextBox, DisplayItem::paintPhaseToDrawingType(Paint PhaseForeground)),
264 TestDisplayItem(html, DisplayItem::EndSubsequence)); 267 TestDisplayItem(html, DisplayItem::EndSubsequence));
265 268
266 div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px"); 269 div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px");
267 document().view()->updateAllLifecyclePhases(); 270 document().view()->updateAllLifecyclePhases();
268 271
269 LayoutText& newText = *toLayoutText(divBlock.firstChild()); 272 LayoutText& newText = *toLayoutText(divBlock.firstChild());
270 InlineTextBox& newFirstTextBox = *newText.firstTextBox(); 273 InlineTextBox& newFirstTextBox = *newText.firstTextBox();
271 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox(); 274 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox();
272 275
273 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 5, 276 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 6,
277 TestDisplayItem(layoutView, DisplayItem::FixedPositionContainer),
274 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), 278 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground),
275 TestDisplayItem(html, DisplayItem::BeginSubsequence), 279 TestDisplayItem(html, DisplayItem::BeginSubsequence),
276 TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(Pa intPhaseForeground)), 280 TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(Pa intPhaseForeground)),
277 TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground)), 281 TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground)),
278 TestDisplayItem(html, DisplayItem::EndSubsequence)); 282 TestDisplayItem(html, DisplayItem::EndSubsequence));
279 } 283 }
280 284
281 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, CachedSubsequence) 285 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, CachedSubsequence)
282 { 286 {
283 setBodyInnerHTML( 287 setBodyInnerHTML(
284 "<div id='container1' style='position: relative; width: 200px; height: 2 00px; background-color: blue'>" 288 "<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>" 289 " <div id='content1' style='width: 100px; height: 100px; background-col or: red'></div>"
286 "</div>" 290 "</div>"
287 "<div id='container2' style='position: relative; width: 200px; height: 2 00px; background-color: blue'>" 291 "<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>" 292 " <div id='content2' style='width: 100px; height: 100px; background-col or: green'></div>"
289 "</div>"); 293 "</div>");
290 document().view()->updateAllLifecyclePhases(); 294 document().view()->updateAllLifecyclePhases();
291 295
292 LayoutView& layoutView = *document().layoutView(); 296 LayoutView& layoutView = *document().layoutView();
293 LayoutObject& html = *document().documentElement()->layoutObject(); 297 LayoutObject& html = *document().documentElement()->layoutObject();
294 LayoutObject& container1 = *document().getElementById("container1")->layoutO bject(); 298 LayoutObject& container1 = *document().getElementById("container1")->layoutO bject();
295 LayoutObject& content1 = *document().getElementById("content1")->layoutObjec t(); 299 LayoutObject& content1 = *document().getElementById("content1")->layoutObjec t();
296 LayoutObject& container2 = *document().getElementById("container2")->layoutO bject(); 300 LayoutObject& container2 = *document().getElementById("container2")->layoutO bject();
297 LayoutObject& content2 = *document().getElementById("content2")->layoutObjec t(); 301 LayoutObject& content2 = *document().getElementById("content2")->layoutObjec t();
298 302
299 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 11, 303 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 12,
304 TestDisplayItem(layoutView, DisplayItem::FixedPositionContainer),
300 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), 305 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground),
301 TestDisplayItem(html, DisplayItem::BeginSubsequence), 306 TestDisplayItem(html, DisplayItem::BeginSubsequence),
302 TestDisplayItem(container1, DisplayItem::BeginSubsequence), 307 TestDisplayItem(container1, DisplayItem::BeginSubsequence),
303 TestDisplayItem(container1, DisplayItem::BoxDecorationBackground), 308 TestDisplayItem(container1, DisplayItem::BoxDecorationBackground),
304 TestDisplayItem(content1, DisplayItem::BoxDecorationBackground), 309 TestDisplayItem(content1, DisplayItem::BoxDecorationBackground),
305 TestDisplayItem(container1, DisplayItem::EndSubsequence), 310 TestDisplayItem(container1, DisplayItem::EndSubsequence),
306 TestDisplayItem(container2, DisplayItem::BeginSubsequence), 311 TestDisplayItem(container2, DisplayItem::BeginSubsequence),
307 TestDisplayItem(container2, DisplayItem::BoxDecorationBackground), 312 TestDisplayItem(container2, DisplayItem::BoxDecorationBackground),
308 TestDisplayItem(content2, DisplayItem::BoxDecorationBackground), 313 TestDisplayItem(content2, DisplayItem::BoxDecorationBackground),
309 TestDisplayItem(container2, DisplayItem::EndSubsequence), 314 TestDisplayItem(container2, DisplayItem::EndSubsequence),
310 TestDisplayItem(html, DisplayItem::EndSubsequence)); 315 TestDisplayItem(html, DisplayItem::EndSubsequence));
311 316
312 toHTMLElement(content1.node())->setAttribute(HTMLNames::styleAttr, "width: 1 00px; height: 100px; background-color: green"); 317 toHTMLElement(content1.node())->setAttribute(HTMLNames::styleAttr, "width: 1 00px; height: 100px; background-color: green");
313 updateLifecyclePhasesToPaintForSlimmingPaintV2Clean(); 318 updateLifecyclePhasesToPaintForSlimmingPaintV2Clean();
314 319
315 EXPECT_DISPLAY_LIST_WITH_CACHED_RED_FILL_IN_DEBUG(newDisplayItemsBeforeUpdat e(), 8, 320 EXPECT_DISPLAY_LIST_WITH_CACHED_RED_FILL_IN_DEBUG(newDisplayItemsBeforeUpdat e(), 9,
321 TestDisplayItem(layoutView, DisplayItem::FixedPositionContainer),
316 TestDisplayItem(layoutView, DisplayItem::drawingTypeToCachedDrawingType( DisplayItem::BoxDecorationBackground)), 322 TestDisplayItem(layoutView, DisplayItem::drawingTypeToCachedDrawingType( DisplayItem::BoxDecorationBackground)),
317 TestDisplayItem(html, DisplayItem::BeginSubsequence), 323 TestDisplayItem(html, DisplayItem::BeginSubsequence),
318 TestDisplayItem(container1, DisplayItem::BeginSubsequence), 324 TestDisplayItem(container1, DisplayItem::BeginSubsequence),
319 TestDisplayItem(container1, DisplayItem::drawingTypeToCachedDrawingType( DisplayItem::BoxDecorationBackground)), 325 TestDisplayItem(container1, DisplayItem::drawingTypeToCachedDrawingType( DisplayItem::BoxDecorationBackground)),
320 TestDisplayItem(content1, DisplayItem::BoxDecorationBackground), 326 TestDisplayItem(content1, DisplayItem::BoxDecorationBackground),
321 TestDisplayItem(container1, DisplayItem::EndSubsequence), 327 TestDisplayItem(container1, DisplayItem::EndSubsequence),
322 TestDisplayItem(container2, DisplayItem::CachedSubsequence), 328 TestDisplayItem(container2, DisplayItem::CachedSubsequence),
323 TestDisplayItem(html, DisplayItem::EndSubsequence)); 329 TestDisplayItem(html, DisplayItem::EndSubsequence));
324 330
325 compositeForSlimmingPaintV2(); 331 compositeForSlimmingPaintV2();
326 332
327 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 11, 333 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 12,
334 TestDisplayItem(layoutView, DisplayItem::FixedPositionContainer),
328 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), 335 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground),
329 TestDisplayItem(html, DisplayItem::BeginSubsequence), 336 TestDisplayItem(html, DisplayItem::BeginSubsequence),
330 TestDisplayItem(container1, DisplayItem::BeginSubsequence), 337 TestDisplayItem(container1, DisplayItem::BeginSubsequence),
331 TestDisplayItem(container1, DisplayItem::BoxDecorationBackground), 338 TestDisplayItem(container1, DisplayItem::BoxDecorationBackground),
332 TestDisplayItem(content1, DisplayItem::BoxDecorationBackground), 339 TestDisplayItem(content1, DisplayItem::BoxDecorationBackground),
333 TestDisplayItem(container1, DisplayItem::EndSubsequence), 340 TestDisplayItem(container1, DisplayItem::EndSubsequence),
334 TestDisplayItem(container2, DisplayItem::BeginSubsequence), 341 TestDisplayItem(container2, DisplayItem::BeginSubsequence),
335 TestDisplayItem(container2, DisplayItem::BoxDecorationBackground), 342 TestDisplayItem(container2, DisplayItem::BoxDecorationBackground),
336 TestDisplayItem(content2, DisplayItem::BoxDecorationBackground), 343 TestDisplayItem(content2, DisplayItem::BoxDecorationBackground),
337 TestDisplayItem(container2, DisplayItem::EndSubsequence), 344 TestDisplayItem(container2, DisplayItem::EndSubsequence),
338 TestDisplayItem(html, DisplayItem::EndSubsequence)); 345 TestDisplayItem(html, DisplayItem::EndSubsequence));
339 } 346 }
340 347
348 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, OverflowClipHierarchy)
349 {
350 setBodyInnerHTML(
351 "<div id='scroller1' style='overflow: hidden; width: 100px; height: 100p x;'>"
352 " <div id='scroller2' style='overflow: hidden; width: 200px; height: 20 0px;'>"
353 " normal flow"
354 " <div id='positioned' style='position:relative; z-index: -1; width: 300px; height: 300px; border: 1px dotted black;'></div>"
pdr. 2015/09/03 06:16:59 Is z-index: -1 needed here?
trchen 2015/09/04 06:10:15 Not important. Removal done.
355 " </div>"
356 "</div>");
357 document().view()->updateAllLifecyclePhases();
pdr. 2015/09/03 06:16:59 This isn't necessary as setBodyInnerHTML (confusin
trchen 2015/09/04 06:10:15 Done.
358
359 LayoutView& layoutView = *document().layoutView();
360 LayoutObject& html = *document().documentElement()->layoutObject();
361 LayoutObject& scroller1 = *document().getElementById("scroller1")->layoutObj ect();
362 LayoutObject& scroller2 = *document().getElementById("scroller2")->layoutObj ect();
363 InlineTextBox& normalFlow = *static_cast<LayoutText*>(scroller2.slowFirstChi ld()->slowFirstChild())->firstTextBox();
364 LayoutObject& positioned = *document().getElementById("positioned")->layoutO bject();
365
366 static_cast<LayoutBox&>(scroller1).scrollToOffset(DoubleSize(12, 34));
367 static_cast<LayoutBox&>(scroller2).scrollToOffset(DoubleSize(56, 78));
368 document().view()->updateAllLifecyclePhases();
369
370 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 32,
371 TestDisplayItem(layoutView, DisplayItem::FixedPositionContainer),
372 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground),
373 TestDisplayItem(html, DisplayItem::BeginSubsequence),
374
375 TestDisplayItem(scroller1, DisplayItem::ClipDescendantStackingContex t),
376 TestDisplayItem(scroller1, DisplayItem::paintPhaseToScrollType(P aintPhaseBlockBackground)),
377 TestDisplayItem(scroller2, DisplayItem::ClipDescendantStacki ngContext),
378 TestDisplayItem(scroller2, DisplayItem::paintPhaseToScro llType(PaintPhaseBlockBackground)),
379 TestDisplayItem(positioned, DisplayItem::BeginSubseq uence),
380 TestDisplayItem(positioned, DisplayItem::BoxDeco rationBackground),
381 TestDisplayItem(positioned, DisplayItem::EndSubseque nce),
382 TestDisplayItem(scroller2, DisplayItem::scrollTypeToEndS crollType(DisplayItem::paintPhaseToScrollType(PaintPhaseBlockBackground))),
383 TestDisplayItem(scroller2, DisplayItem::clipTypeToEndClipTyp e(DisplayItem::ClipDescendantStackingContext)),
384 TestDisplayItem(scroller1, DisplayItem::scrollTypeToEndScrollTyp e(DisplayItem::paintPhaseToScrollType(PaintPhaseBlockBackground))),
385 TestDisplayItem(scroller1, DisplayItem::clipTypeToEndClipType(Displa yItem::ClipDescendantStackingContext)),
386
387 TestDisplayItem(scroller1, DisplayItem::paintPhaseToClipBoxType(Pain tPhaseForeground)),
388 TestDisplayItem(scroller1, DisplayItem::paintPhaseToScrollType(P aintPhaseForeground)),
389 TestDisplayItem(scroller2, DisplayItem::paintPhaseToClipBoxT ype(PaintPhaseForeground)),
390 TestDisplayItem(scroller2, DisplayItem::paintPhaseToScro llType(PaintPhaseForeground)),
391 TestDisplayItem(normalFlow, DisplayItem::paintPhaseT oDrawingType(PaintPhaseForeground)),
392 TestDisplayItem(scroller2, DisplayItem::scrollTypeToEndS crollType(DisplayItem::paintPhaseToScrollType(PaintPhaseForeground))),
393 TestDisplayItem(scroller2, DisplayItem::clipTypeToEndClipTyp e(DisplayItem::paintPhaseToClipBoxType(PaintPhaseForeground))),
394 TestDisplayItem(scroller1, DisplayItem::scrollTypeToEndScrollTyp e(DisplayItem::paintPhaseToScrollType(PaintPhaseForeground))),
395 TestDisplayItem(scroller1, DisplayItem::clipTypeToEndClipType(Displa yItem::paintPhaseToClipBoxType(PaintPhaseForeground))),
396
397 TestDisplayItem(scroller1, DisplayItem::BeginSubsequence),
398 TestDisplayItem(scroller1, DisplayItem::ClipDescendantStackingCo ntext),
399 TestDisplayItem(scroller1, DisplayItem::paintPhaseToScrollTy pe(PaintPhaseBlockBackground)),
400 TestDisplayItem(scroller2, DisplayItem::BeginSubsequence ),
401 TestDisplayItem(scroller2, DisplayItem::EndSubsequence),
402 TestDisplayItem(scroller1, DisplayItem::scrollTypeToEndScrol lType(DisplayItem::paintPhaseToScrollType(PaintPhaseBlockBackground))),
403 TestDisplayItem(scroller1, DisplayItem::clipTypeToEndClipType(Di splayItem::ClipDescendantStackingContext)),
404 TestDisplayItem(scroller1, DisplayItem::EndSubsequence),
405
406 TestDisplayItem(html, DisplayItem::EndSubsequence));
407 }
408
pdr. 2015/09/03 06:16:59 Can you add a second test of the following scenari
trchen 2015/09/04 06:10:15 I ran your test case locally, the drawing display
341 } // namespace blink 409 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698