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/HTMLNames.h" | 5 #include "core/HTMLNames.h" |
6 #include "core/frame/FrameView.h" | 6 #include "core/frame/FrameView.h" |
7 #include "core/layout/LayoutTestHelper.h" | 7 #include "core/layout/LayoutTestHelper.h" |
8 #include "core/layout/LayoutView.h" | 8 #include "core/layout/LayoutView.h" |
9 #include "core/paint/PaintLayer.h" | 9 #include "core/paint/PaintLayer.h" |
10 #include "platform/graphics/GraphicsLayer.h" | 10 #include "platform/graphics/GraphicsLayer.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 // TODO(wangxianzhu): Test SPv2. | 26 // TODO(wangxianzhu): Test SPv2. |
27 return layoutView() | 27 return layoutView() |
28 .layer() | 28 .layer() |
29 ->graphicsLayerBacking() | 29 ->graphicsLayerBacking() |
30 ->getRasterInvalidationTracking(); | 30 ->getRasterInvalidationTracking(); |
31 } | 31 } |
32 | 32 |
33 private: | 33 private: |
34 void SetUp() override { | 34 void SetUp() override { |
35 RenderingTest::SetUp(); | 35 RenderingTest::SetUp(); |
| 36 document().setCompatibilityMode(Document::NoQuirksMode); |
36 enableCompositing(); | 37 enableCompositing(); |
37 setBodyInnerHTML( | 38 setBodyInnerHTML( |
38 "<style>" | 39 "<style>" |
39 " body {" | 40 " body {" |
40 " margin: 0;" | 41 " margin: 0;" |
41 " height: 0;" | 42 " height: 0;" |
42 " }" | 43 " }" |
43 " ::-webkit-scrollbar { display: none }" | 44 " ::-webkit-scrollbar { display: none }" |
44 " #target {" | 45 " #target {" |
45 " width: 50px;" | 46 " width: 50px;" |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 target->setAttribute(HTMLNames::classAttr, ""); | 228 target->setAttribute(HTMLNames::classAttr, ""); |
228 target->setAttribute(HTMLNames::styleAttr, "height: 2000px"); | 229 target->setAttribute(HTMLNames::styleAttr, "height: 2000px"); |
229 document().view()->updateAllLifecyclePhases(); | 230 document().view()->updateAllLifecyclePhases(); |
230 | 231 |
231 // Resize the content. | 232 // Resize the content. |
232 document().view()->setTracksPaintInvalidations(true); | 233 document().view()->setTracksPaintInvalidations(true); |
233 target->setAttribute(HTMLNames::styleAttr, "height: 3000px"); | 234 target->setAttribute(HTMLNames::styleAttr, "height: 3000px"); |
234 document().view()->updateAllLifecyclePhases(); | 235 document().view()->updateAllLifecyclePhases(); |
235 const auto& rasterInvalidations = | 236 const auto& rasterInvalidations = |
236 getRasterInvalidationTracking()->trackedRasterInvalidations; | 237 getRasterInvalidationTracking()->trackedRasterInvalidations; |
237 // TODO(wangxianzhu): Temporary for crbug.com/680745. | 238 ASSERT_EQ(1u, rasterInvalidations.size()); |
238 // ASSERT_EQ(1u, rasterInvalidations.size()); | |
239 ASSERT_EQ(2u, rasterInvalidations.size()); | |
240 EXPECT_EQ(IntRect(0, 2000, 800, 1000), rasterInvalidations[0].rect); | 239 EXPECT_EQ(IntRect(0, 2000, 800, 1000), rasterInvalidations[0].rect); |
241 EXPECT_EQ(static_cast<const DisplayItemClient*>(&layoutView()), | 240 EXPECT_EQ(static_cast<const DisplayItemClient*>(&layoutView()), |
242 rasterInvalidations[0].client); | 241 rasterInvalidations[0].client); |
243 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 242 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
244 EXPECT_EQ(PaintInvalidationBackgroundOnScrollingContentsLayer, | 243 EXPECT_EQ(PaintInvalidationBackgroundOnScrollingContentsLayer, |
245 rasterInvalidations[0].reason); | 244 rasterInvalidations[0].reason); |
246 } else { | 245 } else { |
247 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason); | 246 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason); |
248 } | 247 } |
249 | 248 |
(...skipping 15 matching lines...) Expand all Loading... |
265 target->setAttribute(HTMLNames::styleAttr, "height: 2000px"); | 264 target->setAttribute(HTMLNames::styleAttr, "height: 2000px"); |
266 document().view()->updateAllLifecyclePhases(); | 265 document().view()->updateAllLifecyclePhases(); |
267 | 266 |
268 // Resize the content. | 267 // Resize the content. |
269 document().view()->setTracksPaintInvalidations(true); | 268 document().view()->setTracksPaintInvalidations(true); |
270 target->setAttribute(HTMLNames::styleAttr, "height: 3000px"); | 269 target->setAttribute(HTMLNames::styleAttr, "height: 3000px"); |
271 document().view()->updateAllLifecyclePhases(); | 270 document().view()->updateAllLifecyclePhases(); |
272 | 271 |
273 const auto& rasterInvalidations = | 272 const auto& rasterInvalidations = |
274 getRasterInvalidationTracking()->trackedRasterInvalidations; | 273 getRasterInvalidationTracking()->trackedRasterInvalidations; |
275 // TODO(wangxianzhu): Temporary for crbug.com/680745. | 274 ASSERT_EQ(1u, rasterInvalidations.size()); |
276 // ASSERT_EQ(1u, rasterInvalidations.size()); | |
277 ASSERT_EQ(2u, rasterInvalidations.size()); | |
278 EXPECT_EQ(IntRect(0, 0, 800, 3000), rasterInvalidations[0].rect); | 275 EXPECT_EQ(IntRect(0, 0, 800, 3000), rasterInvalidations[0].rect); |
279 EXPECT_EQ(static_cast<const DisplayItemClient*>(&layoutView()), | 276 EXPECT_EQ(static_cast<const DisplayItemClient*>(&layoutView()), |
280 rasterInvalidations[0].client); | 277 rasterInvalidations[0].client); |
281 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 278 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
282 EXPECT_EQ(PaintInvalidationBackgroundOnScrollingContentsLayer, | 279 EXPECT_EQ(PaintInvalidationBackgroundOnScrollingContentsLayer, |
283 rasterInvalidations[0].reason); | 280 rasterInvalidations[0].reason); |
284 } else { | 281 } else { |
285 EXPECT_EQ(PaintInvalidationLayoutOverflowBoxChange, | 282 EXPECT_EQ(PaintInvalidationLayoutOverflowBoxChange, |
286 rasterInvalidations[0].reason); | 283 rasterInvalidations[0].reason); |
287 } | 284 } |
(...skipping 25 matching lines...) Expand all Loading... |
313 Element* iframe = document().getElementById("iframe"); | 310 Element* iframe = document().getElementById("iframe"); |
314 Element* content = childDocument().getElementById("content"); | 311 Element* content = childDocument().getElementById("content"); |
315 EXPECT_EQ(layoutView(), | 312 EXPECT_EQ(layoutView(), |
316 content->layoutObject()->containerForPaintInvalidation()); | 313 content->layoutObject()->containerForPaintInvalidation()); |
317 | 314 |
318 // Resize the content. | 315 // Resize the content. |
319 document().view()->setTracksPaintInvalidations(true); | 316 document().view()->setTracksPaintInvalidations(true); |
320 content->setAttribute(HTMLNames::styleAttr, "height: 500px"); | 317 content->setAttribute(HTMLNames::styleAttr, "height: 500px"); |
321 document().view()->updateAllLifecyclePhases(); | 318 document().view()->updateAllLifecyclePhases(); |
322 // No invalidation because the changed part of layout overflow is clipped. | 319 // No invalidation because the changed part of layout overflow is clipped. |
323 // TODO(wangxianzhu): Temporary for crbug.com/680745. | 320 EXPECT_FALSE(getRasterInvalidationTracking()); |
324 // EXPECT_FALSE(getRasterInvalidationTracking()); | |
325 EXPECT_EQ(1u, | |
326 getRasterInvalidationTracking()->trackedRasterInvalidations.size()); | |
327 document().view()->setTracksPaintInvalidations(false); | 321 document().view()->setTracksPaintInvalidations(false); |
328 | 322 |
329 // Resize the iframe. | 323 // Resize the iframe. |
330 document().view()->setTracksPaintInvalidations(true); | 324 document().view()->setTracksPaintInvalidations(true); |
331 iframe->setAttribute(HTMLNames::styleAttr, "height: 200px"); | 325 iframe->setAttribute(HTMLNames::styleAttr, "height: 200px"); |
332 document().view()->updateAllLifecyclePhases(); | 326 document().view()->updateAllLifecyclePhases(); |
333 const auto& rasterInvalidations = | 327 const auto& rasterInvalidations = |
334 getRasterInvalidationTracking()->trackedRasterInvalidations; | 328 getRasterInvalidationTracking()->trackedRasterInvalidations; |
335 ASSERT_EQ(2u, rasterInvalidations.size()); | 329 ASSERT_EQ(2u, rasterInvalidations.size()); |
336 EXPECT_EQ(IntRect(0, 100, 100, 100), rasterInvalidations[0].rect); | 330 EXPECT_EQ(IntRect(0, 100, 100, 100), rasterInvalidations[0].rect); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 LayoutView* frameLayoutView = content->layoutObject()->view(); | 369 LayoutView* frameLayoutView = content->layoutObject()->view(); |
376 EXPECT_EQ(layoutView(), | 370 EXPECT_EQ(layoutView(), |
377 content->layoutObject()->containerForPaintInvalidation()); | 371 content->layoutObject()->containerForPaintInvalidation()); |
378 | 372 |
379 // Resize the content. | 373 // Resize the content. |
380 document().view()->setTracksPaintInvalidations(true); | 374 document().view()->setTracksPaintInvalidations(true); |
381 content->setAttribute(HTMLNames::styleAttr, "height: 500px"); | 375 content->setAttribute(HTMLNames::styleAttr, "height: 500px"); |
382 document().view()->updateAllLifecyclePhases(); | 376 document().view()->updateAllLifecyclePhases(); |
383 const auto* rasterInvalidations = | 377 const auto* rasterInvalidations = |
384 &getRasterInvalidationTracking()->trackedRasterInvalidations; | 378 &getRasterInvalidationTracking()->trackedRasterInvalidations; |
385 // TODO(wangxianzhu): Temporary for crbug.com/680745. | 379 ASSERT_EQ(1u, rasterInvalidations->size()); |
386 // ASSERT_EQ(1u, rasterInvalidations->size()); | |
387 ASSERT_EQ(2u, rasterInvalidations->size()); | |
388 EXPECT_EQ(IntRect(0, 0, 100, 100), (*rasterInvalidations)[0].rect); | 380 EXPECT_EQ(IntRect(0, 0, 100, 100), (*rasterInvalidations)[0].rect); |
389 EXPECT_EQ(static_cast<const DisplayItemClient*>(frameLayoutView), | 381 EXPECT_EQ(static_cast<const DisplayItemClient*>(frameLayoutView), |
390 (*rasterInvalidations)[0].client); | 382 (*rasterInvalidations)[0].client); |
391 EXPECT_EQ(PaintInvalidationLayoutOverflowBoxChange, | 383 EXPECT_EQ(PaintInvalidationLayoutOverflowBoxChange, |
392 (*rasterInvalidations)[0].reason); | 384 (*rasterInvalidations)[0].reason); |
393 document().view()->setTracksPaintInvalidations(false); | 385 document().view()->setTracksPaintInvalidations(false); |
394 | 386 |
395 // Resize the iframe. | 387 // Resize the iframe. |
396 document().view()->setTracksPaintInvalidations(true); | 388 document().view()->setTracksPaintInvalidations(true); |
397 iframe->setAttribute(HTMLNames::styleAttr, "height: 200px"); | 389 iframe->setAttribute(HTMLNames::styleAttr, "height: 200px"); |
398 document().view()->updateAllLifecyclePhases(); | 390 document().view()->updateAllLifecyclePhases(); |
399 rasterInvalidations = | 391 rasterInvalidations = |
400 &getRasterInvalidationTracking()->trackedRasterInvalidations; | 392 &getRasterInvalidationTracking()->trackedRasterInvalidations; |
401 ASSERT_EQ(2u, rasterInvalidations->size()); | 393 ASSERT_EQ(2u, rasterInvalidations->size()); |
402 EXPECT_EQ(IntRect(0, 100, 100, 100), (*rasterInvalidations)[0].rect); | 394 EXPECT_EQ(IntRect(0, 100, 100, 100), (*rasterInvalidations)[0].rect); |
403 EXPECT_EQ(static_cast<const DisplayItemClient*>(iframe->layoutObject()), | 395 EXPECT_EQ(static_cast<const DisplayItemClient*>(iframe->layoutObject()), |
404 (*rasterInvalidations)[0].client); | 396 (*rasterInvalidations)[0].client); |
405 EXPECT_EQ(PaintInvalidationIncremental, (*rasterInvalidations)[0].reason); | 397 EXPECT_EQ(PaintInvalidationIncremental, (*rasterInvalidations)[0].reason); |
406 EXPECT_EQ(static_cast<const DisplayItemClient*>(frameLayoutView), | 398 EXPECT_EQ(static_cast<const DisplayItemClient*>(frameLayoutView), |
407 (*rasterInvalidations)[1].client); | 399 (*rasterInvalidations)[1].client); |
408 EXPECT_EQ(IntRect(0, 0, 100, 200), (*rasterInvalidations)[1].rect); | 400 EXPECT_EQ(IntRect(0, 0, 100, 200), (*rasterInvalidations)[1].rect); |
409 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 401 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
410 // TODO(skobes): Treat LayoutView in the same way as normal objects having | 402 // TODO(skobes): Treat LayoutView in the same way as normal objects having |
411 // background-attachment: local. crbug.com/568847. | 403 // background-attachment: local. crbug.com/568847. |
412 EXPECT_EQ(PaintInvalidationFull, (*rasterInvalidations)[1].reason); | 404 EXPECT_EQ(PaintInvalidationFull, (*rasterInvalidations)[1].reason); |
413 } else { | 405 } else { |
414 EXPECT_EQ(PaintInvalidationBorderBoxChange, | 406 EXPECT_EQ(PaintInvalidationViewBackground, |
415 (*rasterInvalidations)[1].reason); | 407 (*rasterInvalidations)[1].reason); |
416 } | 408 } |
417 document().view()->setTracksPaintInvalidations(false); | 409 document().view()->setTracksPaintInvalidations(false); |
418 } | 410 } |
419 | 411 |
420 TEST_P(BoxPaintInvalidatorTest, CompositedBackgroundAttachmentLocalResize) { | 412 TEST_P(BoxPaintInvalidatorTest, CompositedBackgroundAttachmentLocalResize) { |
421 enableCompositing(); | 413 enableCompositing(); |
422 | 414 |
423 Element* target = document().getElementById("target"); | 415 Element* target = document().getElementById("target"); |
424 target->setAttribute(HTMLNames::classAttr, "border local-background"); | 416 target->setAttribute(HTMLNames::classAttr, "border local-background"); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 getRasterInvalidationTracking()->trackedRasterInvalidations; | 547 getRasterInvalidationTracking()->trackedRasterInvalidations; |
556 ASSERT_EQ(1u, rasterInvalidations.size()); | 548 ASSERT_EQ(1u, rasterInvalidations.size()); |
557 EXPECT_EQ(IntRect(0, 120, 70, 120), rasterInvalidations[0].rect); | 549 EXPECT_EQ(IntRect(0, 120, 70, 120), rasterInvalidations[0].rect); |
558 EXPECT_EQ(static_cast<const DisplayItemClient*>(target->layoutObject()), | 550 EXPECT_EQ(static_cast<const DisplayItemClient*>(target->layoutObject()), |
559 rasterInvalidations[0].client); | 551 rasterInvalidations[0].client); |
560 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason); | 552 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason); |
561 document().view()->setTracksPaintInvalidations(false); | 553 document().view()->setTracksPaintInvalidations(false); |
562 } | 554 } |
563 | 555 |
564 } // namespace blink | 556 } // namespace blink |
OLD | NEW |