Chromium Code Reviews| 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 enableCompositing(); | 225 enableCompositing(); |
| 226 Element* target = document().getElementById("target"); | 226 Element* target = document().getElementById("target"); |
| 227 target->setAttribute(HTMLNames::classAttr, ""); | 227 target->setAttribute(HTMLNames::classAttr, ""); |
| 228 target->setAttribute(HTMLNames::styleAttr, "height: 2000px"); | 228 target->setAttribute(HTMLNames::styleAttr, "height: 2000px"); |
| 229 document().view()->updateAllLifecyclePhases(); | 229 document().view()->updateAllLifecyclePhases(); |
| 230 | 230 |
| 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 const auto& rasterInvalidations = |
| 236 // For now in RootLayerScrolling mode root background is invalidated and | 236 getRasterInvalidationTracking()->trackedRasterInvalidations; |
| 237 // painted on the container layer. No invalidation because the changed part | 237 // TODO(wangxianzhu): Temporary for crbug.com/680745. |
| 238 // is clipped. | 238 // ASSERT_EQ(1u, rasterInvalidations.size()); |
| 239 // TODO(skobes): Treat LayoutView in the same way as normal objects having | 239 ASSERT_EQ(2u, rasterInvalidations.size()); |
| 240 // background-attachment: local. crbug.com/568847. | 240 EXPECT_EQ(IntRect(0, 2000, 800, 1000), rasterInvalidations[0].rect); |
| 241 // TODO(wangxianzhu): Temporary for crbug.com/680745. | 241 EXPECT_EQ(static_cast<const DisplayItemClient*>(&layoutView()), |
| 242 // EXPECT_FALSE(layoutView() | 242 rasterInvalidations[0].client); |
| 243 // .layer() | 243 EXPECT_EQ(PaintInvalidationBackgroundOnScrollingContentsLayer, |
|
chrishtr
2017/02/15 02:08:34
Isn't this only for cases when --root-layer-scroll
| |
| 244 // ->graphicsLayerBacking() | 244 rasterInvalidations[0].reason); |
| 245 // ->getRasterInvalidationTracking()); | 245 |
| 246 EXPECT_EQ(1u, layoutView() | |
| 247 .layer() | |
| 248 ->graphicsLayerBacking() | |
| 249 ->getRasterInvalidationTracking() | |
| 250 ->trackedRasterInvalidations.size()); | |
| 251 } else { | |
| 252 const auto& rasterInvalidations = | |
| 253 getRasterInvalidationTracking()->trackedRasterInvalidations; | |
| 254 // TODO(wangxianzhu): Temporary for crbug.com/680745. | |
| 255 // ASSERT_EQ(1u, rasterInvalidations.size()); | |
| 256 ASSERT_EQ(2u, rasterInvalidations.size()); | |
| 257 EXPECT_EQ(IntRect(0, 2000, 800, 1000), rasterInvalidations[0].rect); | |
| 258 EXPECT_EQ(static_cast<const DisplayItemClient*>(&layoutView()), | |
| 259 rasterInvalidations[0].client); | |
| 260 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason); | |
| 261 } | |
| 262 document().view()->setTracksPaintInvalidations(false); | 246 document().view()->setTracksPaintInvalidations(false); |
| 263 | 247 |
| 264 // Resize the viewport. No paint invalidation. | 248 // Resize the viewport. No paint invalidation. |
| 265 document().view()->setTracksPaintInvalidations(true); | 249 document().view()->setTracksPaintInvalidations(true); |
| 266 document().view()->resize(800, 1000); | 250 document().view()->resize(800, 1000); |
| 267 document().view()->updateAllLifecyclePhases(); | 251 document().view()->updateAllLifecyclePhases(); |
| 268 EXPECT_FALSE(getRasterInvalidationTracking()); | 252 EXPECT_FALSE(getRasterInvalidationTracking()); |
| 269 document().view()->setTracksPaintInvalidations(false); | 253 document().view()->setTracksPaintInvalidations(false); |
| 270 } | 254 } |
| 271 | 255 |
| 272 TEST_P(BoxPaintInvalidatorTest, CompositedLayoutViewGradientResize) { | 256 TEST_P(BoxPaintInvalidatorTest, CompositedLayoutViewGradientResize) { |
| 273 enableCompositing(); | 257 enableCompositing(); |
| 274 document().body()->setAttribute(HTMLNames::classAttr, "gradient"); | 258 document().body()->setAttribute(HTMLNames::classAttr, "gradient"); |
| 275 Element* target = document().getElementById("target"); | 259 Element* target = document().getElementById("target"); |
| 276 target->setAttribute(HTMLNames::classAttr, ""); | 260 target->setAttribute(HTMLNames::classAttr, ""); |
| 277 target->setAttribute(HTMLNames::styleAttr, "height: 2000px"); | 261 target->setAttribute(HTMLNames::styleAttr, "height: 2000px"); |
| 278 document().view()->updateAllLifecyclePhases(); | 262 document().view()->updateAllLifecyclePhases(); |
| 279 | 263 |
| 280 // Resize the content. | 264 // Resize the content. |
| 281 document().view()->setTracksPaintInvalidations(true); | 265 document().view()->setTracksPaintInvalidations(true); |
| 282 target->setAttribute(HTMLNames::styleAttr, "height: 3000px"); | 266 target->setAttribute(HTMLNames::styleAttr, "height: 3000px"); |
| 283 document().view()->updateAllLifecyclePhases(); | 267 document().view()->updateAllLifecyclePhases(); |
| 284 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 268 |
| 285 // For now in RootLayerScrolling mode root background is invalidated and | 269 const auto& rasterInvalidations = |
| 286 // painted on the container layer. | 270 getRasterInvalidationTracking()->trackedRasterInvalidations; |
| 287 // TODO(skobes): Treat LayoutView in the same way as normal objects having | 271 // TODO(wangxianzhu): Temporary for crbug.com/680745. |
| 288 // background-attachment: local. crbug.com/568847. | 272 // ASSERT_EQ(1u, rasterInvalidations.size()); |
| 289 const auto& rasterInvalidations = layoutView() | 273 ASSERT_EQ(2u, rasterInvalidations.size()); |
| 290 .layer() | 274 EXPECT_EQ(IntRect(0, 0, 800, 3000), rasterInvalidations[0].rect); |
| 291 ->graphicsLayerBacking(&layoutView()) | 275 EXPECT_EQ(static_cast<const DisplayItemClient*>(&layoutView()), |
| 292 ->getRasterInvalidationTracking() | 276 rasterInvalidations[0].client); |
| 293 ->trackedRasterInvalidations; | 277 EXPECT_EQ(PaintInvalidationBackgroundOnScrollingContentsLayer, |
| 294 ASSERT_EQ(1u, rasterInvalidations.size()); | 278 rasterInvalidations[0].reason); |
| 295 EXPECT_EQ(IntRect(0, 0, 800, 600), rasterInvalidations[0].rect); | 279 |
| 296 EXPECT_EQ(static_cast<const DisplayItemClient*>(&layoutView()), | |
| 297 rasterInvalidations[0].client); | |
| 298 EXPECT_EQ(PaintInvalidationLayoutOverflowBoxChange, | |
| 299 rasterInvalidations[0].reason); | |
| 300 } else { | |
| 301 const auto& rasterInvalidations = | |
| 302 getRasterInvalidationTracking()->trackedRasterInvalidations; | |
| 303 // TODO(wangxianzhu): Temporary for crbug.com/680745. | |
| 304 // ASSERT_EQ(1u, rasterInvalidations.size()); | |
| 305 ASSERT_EQ(2u, rasterInvalidations.size()); | |
| 306 EXPECT_EQ(IntRect(0, 0, 800, 3000), rasterInvalidations[0].rect); | |
| 307 EXPECT_EQ(static_cast<const DisplayItemClient*>(&layoutView()), | |
| 308 rasterInvalidations[0].client); | |
| 309 EXPECT_EQ(PaintInvalidationLayoutOverflowBoxChange, | |
| 310 rasterInvalidations[0].reason); | |
| 311 } | |
| 312 document().view()->setTracksPaintInvalidations(false); | 280 document().view()->setTracksPaintInvalidations(false); |
| 313 | 281 |
| 314 // Resize the viewport. No paint invalidation. | 282 // Resize the viewport. No paint invalidation. |
| 315 document().view()->setTracksPaintInvalidations(true); | 283 document().view()->setTracksPaintInvalidations(true); |
| 316 document().view()->resize(800, 1000); | 284 document().view()->resize(800, 1000); |
| 317 document().view()->updateAllLifecyclePhases(); | 285 document().view()->updateAllLifecyclePhases(); |
| 318 EXPECT_FALSE(getRasterInvalidationTracking()); | 286 EXPECT_FALSE(getRasterInvalidationTracking()); |
| 319 document().view()->setTracksPaintInvalidations(false); | 287 document().view()->setTracksPaintInvalidations(false); |
| 320 } | 288 } |
| 321 | 289 |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 578 getRasterInvalidationTracking()->trackedRasterInvalidations; | 546 getRasterInvalidationTracking()->trackedRasterInvalidations; |
| 579 ASSERT_EQ(1u, rasterInvalidations.size()); | 547 ASSERT_EQ(1u, rasterInvalidations.size()); |
| 580 EXPECT_EQ(IntRect(0, 120, 70, 120), rasterInvalidations[0].rect); | 548 EXPECT_EQ(IntRect(0, 120, 70, 120), rasterInvalidations[0].rect); |
| 581 EXPECT_EQ(static_cast<const DisplayItemClient*>(target->layoutObject()), | 549 EXPECT_EQ(static_cast<const DisplayItemClient*>(target->layoutObject()), |
| 582 rasterInvalidations[0].client); | 550 rasterInvalidations[0].client); |
| 583 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason); | 551 EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason); |
| 584 document().view()->setTracksPaintInvalidations(false); | 552 document().view()->setTracksPaintInvalidations(false); |
| 585 } | 553 } |
| 586 | 554 |
| 587 } // namespace blink | 555 } // namespace blink |
| OLD | NEW |