| 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 // Resize the content. | 231 // Resize the content. |
| 232 document().view()->setTracksPaintInvalidations(true); | 232 document().view()->setTracksPaintInvalidations(true); |
| 233 target->setAttribute(HTMLNames::styleAttr, "height: 3000px"); | 233 target->setAttribute(HTMLNames::styleAttr, "height: 3000px"); |
| 234 document().view()->updateAllLifecyclePhases(); | 234 document().view()->updateAllLifecyclePhases(); |
| 235 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 235 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 236 // For now in RootLayerScrolling mode root background is invalidated and | 236 // For now in RootLayerScrolling mode root background is invalidated and |
| 237 // painted on the container layer. No invalidation because the changed part | 237 // painted on the container layer. No invalidation because the changed part |
| 238 // is clipped. | 238 // is clipped. |
| 239 // TODO(skobes): Treat LayoutView in the same way as normal objects having | 239 // TODO(skobes): Treat LayoutView in the same way as normal objects having |
| 240 // background-attachment: local. crbug.com/568847. | 240 // background-attachment: local. crbug.com/568847. |
| 241 EXPECT_FALSE(layoutView() | 241 // TODO(wangxianzhu): Temporary for crbug.com/680745. |
| 242 .layer() | 242 // EXPECT_FALSE(layoutView() |
| 243 ->graphicsLayerBacking() | 243 // .layer() |
| 244 ->getRasterInvalidationTracking()); | 244 // ->graphicsLayerBacking() |
| 245 // ->getRasterInvalidationTracking()); |
| 246 EXPECT_EQ(1u, layoutView() |
| 247 .layer() |
| 248 ->graphicsLayerBacking() |
| 249 ->getRasterInvalidationTracking() |
| 250 ->trackedRasterInvalidations.size()); |
| 245 } else { | 251 } else { |
| 246 const auto& rasterInvalidations = | 252 const auto& rasterInvalidations = |
| 247 getRasterInvalidationTracking()->trackedRasterInvalidations; | 253 getRasterInvalidationTracking()->trackedRasterInvalidations; |
| 248 ASSERT_EQ(1u, rasterInvalidations.size()); | 254 // TODO(wangxianzhu): Temporary for crbug.com/680745. |
| 255 // ASSERT_EQ(1u, rasterInvalidations.size()); |
| 256 ASSERT_EQ(2u, rasterInvalidations.size()); |
| 249 EXPECT_EQ(IntRect(0, 2000, 800, 1000), rasterInvalidations[0].rect); | 257 EXPECT_EQ(IntRect(0, 2000, 800, 1000), rasterInvalidations[0].rect); |
| 250 EXPECT_EQ(static_cast<const DisplayItemClient*>(&layoutView()), | 258 EXPECT_EQ(static_cast<const DisplayItemClient*>(&layoutView()), |
| 251 rasterInvalidations[0].client); | 259 rasterInvalidations[0].client); |
| 252 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason); | 260 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason); |
| 253 } | 261 } |
| 254 document().view()->setTracksPaintInvalidations(false); | 262 document().view()->setTracksPaintInvalidations(false); |
| 255 | 263 |
| 256 // Resize the viewport. No paint invalidation. | 264 // Resize the viewport. No paint invalidation. |
| 257 document().view()->setTracksPaintInvalidations(true); | 265 document().view()->setTracksPaintInvalidations(true); |
| 258 document().view()->resize(800, 1000); | 266 document().view()->resize(800, 1000); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 285 ->trackedRasterInvalidations; | 293 ->trackedRasterInvalidations; |
| 286 ASSERT_EQ(1u, rasterInvalidations.size()); | 294 ASSERT_EQ(1u, rasterInvalidations.size()); |
| 287 EXPECT_EQ(IntRect(0, 0, 800, 600), rasterInvalidations[0].rect); | 295 EXPECT_EQ(IntRect(0, 0, 800, 600), rasterInvalidations[0].rect); |
| 288 EXPECT_EQ(static_cast<const DisplayItemClient*>(&layoutView()), | 296 EXPECT_EQ(static_cast<const DisplayItemClient*>(&layoutView()), |
| 289 rasterInvalidations[0].client); | 297 rasterInvalidations[0].client); |
| 290 EXPECT_EQ(PaintInvalidationLayoutOverflowBoxChange, | 298 EXPECT_EQ(PaintInvalidationLayoutOverflowBoxChange, |
| 291 rasterInvalidations[0].reason); | 299 rasterInvalidations[0].reason); |
| 292 } else { | 300 } else { |
| 293 const auto& rasterInvalidations = | 301 const auto& rasterInvalidations = |
| 294 getRasterInvalidationTracking()->trackedRasterInvalidations; | 302 getRasterInvalidationTracking()->trackedRasterInvalidations; |
| 295 ASSERT_EQ(1u, rasterInvalidations.size()); | 303 // TODO(wangxianzhu): Temporary for crbug.com/680745. |
| 304 // ASSERT_EQ(1u, rasterInvalidations.size()); |
| 305 ASSERT_EQ(2u, rasterInvalidations.size()); |
| 296 EXPECT_EQ(IntRect(0, 0, 800, 3000), rasterInvalidations[0].rect); | 306 EXPECT_EQ(IntRect(0, 0, 800, 3000), rasterInvalidations[0].rect); |
| 297 EXPECT_EQ(static_cast<const DisplayItemClient*>(&layoutView()), | 307 EXPECT_EQ(static_cast<const DisplayItemClient*>(&layoutView()), |
| 298 rasterInvalidations[0].client); | 308 rasterInvalidations[0].client); |
| 299 EXPECT_EQ(PaintInvalidationLayoutOverflowBoxChange, | 309 EXPECT_EQ(PaintInvalidationLayoutOverflowBoxChange, |
| 300 rasterInvalidations[0].reason); | 310 rasterInvalidations[0].reason); |
| 301 } | 311 } |
| 302 document().view()->setTracksPaintInvalidations(false); | 312 document().view()->setTracksPaintInvalidations(false); |
| 303 | 313 |
| 304 // Resize the viewport. No paint invalidation. | 314 // Resize the viewport. No paint invalidation. |
| 305 document().view()->setTracksPaintInvalidations(true); | 315 document().view()->setTracksPaintInvalidations(true); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 326 Element* iframe = document().getElementById("iframe"); | 336 Element* iframe = document().getElementById("iframe"); |
| 327 Element* content = childDocument().getElementById("content"); | 337 Element* content = childDocument().getElementById("content"); |
| 328 EXPECT_EQ(layoutView(), | 338 EXPECT_EQ(layoutView(), |
| 329 content->layoutObject()->containerForPaintInvalidation()); | 339 content->layoutObject()->containerForPaintInvalidation()); |
| 330 | 340 |
| 331 // Resize the content. | 341 // Resize the content. |
| 332 document().view()->setTracksPaintInvalidations(true); | 342 document().view()->setTracksPaintInvalidations(true); |
| 333 content->setAttribute(HTMLNames::styleAttr, "height: 500px"); | 343 content->setAttribute(HTMLNames::styleAttr, "height: 500px"); |
| 334 document().view()->updateAllLifecyclePhases(); | 344 document().view()->updateAllLifecyclePhases(); |
| 335 // No invalidation because the changed part of layout overflow is clipped. | 345 // No invalidation because the changed part of layout overflow is clipped. |
| 336 EXPECT_FALSE(getRasterInvalidationTracking()); | 346 // TODO(wangxianzhu): Temporary for crbug.com/680745. |
| 347 // EXPECT_FALSE(getRasterInvalidationTracking()); |
| 348 EXPECT_EQ(1u, |
| 349 getRasterInvalidationTracking()->trackedRasterInvalidations.size()); |
| 337 document().view()->setTracksPaintInvalidations(false); | 350 document().view()->setTracksPaintInvalidations(false); |
| 338 | 351 |
| 339 // Resize the iframe. | 352 // Resize the iframe. |
| 340 document().view()->setTracksPaintInvalidations(true); | 353 document().view()->setTracksPaintInvalidations(true); |
| 341 iframe->setAttribute(HTMLNames::styleAttr, "height: 200px"); | 354 iframe->setAttribute(HTMLNames::styleAttr, "height: 200px"); |
| 342 document().view()->updateAllLifecyclePhases(); | 355 document().view()->updateAllLifecyclePhases(); |
| 343 const auto& rasterInvalidations = | 356 const auto& rasterInvalidations = |
| 344 getRasterInvalidationTracking()->trackedRasterInvalidations; | 357 getRasterInvalidationTracking()->trackedRasterInvalidations; |
| 345 ASSERT_EQ(2u, rasterInvalidations.size()); | 358 ASSERT_EQ(2u, rasterInvalidations.size()); |
| 346 EXPECT_EQ(IntRect(0, 100, 100, 100), rasterInvalidations[0].rect); | 359 EXPECT_EQ(IntRect(0, 100, 100, 100), rasterInvalidations[0].rect); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 LayoutView* frameLayoutView = content->layoutObject()->view(); | 398 LayoutView* frameLayoutView = content->layoutObject()->view(); |
| 386 EXPECT_EQ(layoutView(), | 399 EXPECT_EQ(layoutView(), |
| 387 content->layoutObject()->containerForPaintInvalidation()); | 400 content->layoutObject()->containerForPaintInvalidation()); |
| 388 | 401 |
| 389 // Resize the content. | 402 // Resize the content. |
| 390 document().view()->setTracksPaintInvalidations(true); | 403 document().view()->setTracksPaintInvalidations(true); |
| 391 content->setAttribute(HTMLNames::styleAttr, "height: 500px"); | 404 content->setAttribute(HTMLNames::styleAttr, "height: 500px"); |
| 392 document().view()->updateAllLifecyclePhases(); | 405 document().view()->updateAllLifecyclePhases(); |
| 393 const auto* rasterInvalidations = | 406 const auto* rasterInvalidations = |
| 394 &getRasterInvalidationTracking()->trackedRasterInvalidations; | 407 &getRasterInvalidationTracking()->trackedRasterInvalidations; |
| 395 ASSERT_EQ(1u, rasterInvalidations->size()); | 408 // TODO(wangxianzhu): Temporary for crbug.com/680745. |
| 409 // ASSERT_EQ(1u, rasterInvalidations->size()); |
| 410 ASSERT_EQ(2u, rasterInvalidations->size()); |
| 396 EXPECT_EQ(IntRect(0, 0, 100, 100), (*rasterInvalidations)[0].rect); | 411 EXPECT_EQ(IntRect(0, 0, 100, 100), (*rasterInvalidations)[0].rect); |
| 397 EXPECT_EQ(static_cast<const DisplayItemClient*>(frameLayoutView), | 412 EXPECT_EQ(static_cast<const DisplayItemClient*>(frameLayoutView), |
| 398 (*rasterInvalidations)[0].client); | 413 (*rasterInvalidations)[0].client); |
| 399 EXPECT_EQ(PaintInvalidationLayoutOverflowBoxChange, | 414 EXPECT_EQ(PaintInvalidationLayoutOverflowBoxChange, |
| 400 (*rasterInvalidations)[0].reason); | 415 (*rasterInvalidations)[0].reason); |
| 401 document().view()->setTracksPaintInvalidations(false); | 416 document().view()->setTracksPaintInvalidations(false); |
| 402 | 417 |
| 403 // Resize the iframe. | 418 // Resize the iframe. |
| 404 document().view()->setTracksPaintInvalidations(true); | 419 document().view()->setTracksPaintInvalidations(true); |
| 405 iframe->setAttribute(HTMLNames::styleAttr, "height: 200px"); | 420 iframe->setAttribute(HTMLNames::styleAttr, "height: 200px"); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 getRasterInvalidationTracking()->trackedRasterInvalidations; | 578 getRasterInvalidationTracking()->trackedRasterInvalidations; |
| 564 ASSERT_EQ(1u, rasterInvalidations.size()); | 579 ASSERT_EQ(1u, rasterInvalidations.size()); |
| 565 EXPECT_EQ(IntRect(0, 120, 70, 120), rasterInvalidations[0].rect); | 580 EXPECT_EQ(IntRect(0, 120, 70, 120), rasterInvalidations[0].rect); |
| 566 EXPECT_EQ(static_cast<const DisplayItemClient*>(target->layoutObject()), | 581 EXPECT_EQ(static_cast<const DisplayItemClient*>(target->layoutObject()), |
| 567 rasterInvalidations[0].client); | 582 rasterInvalidations[0].client); |
| 568 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason); | 583 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason); |
| 569 document().view()->setTracksPaintInvalidations(false); | 584 document().view()->setTracksPaintInvalidations(false); |
| 570 } | 585 } |
| 571 | 586 |
| 572 } // namespace blink | 587 } // namespace blink |
| OLD | NEW |