Index: third_party/WebKit/Source/core/paint/BoxPaintInvalidatorTest.cpp |
diff --git a/third_party/WebKit/Source/core/paint/BoxPaintInvalidatorTest.cpp b/third_party/WebKit/Source/core/paint/BoxPaintInvalidatorTest.cpp |
index b200d66ab0fe4491a7d43d6b9f1b9c9fffd11a19..5ff11925faa05504b284679c8fb438041db1d338 100644 |
--- a/third_party/WebKit/Source/core/paint/BoxPaintInvalidatorTest.cpp |
+++ b/third_party/WebKit/Source/core/paint/BoxPaintInvalidatorTest.cpp |
@@ -13,13 +13,20 @@ |
namespace blink { |
-class BoxPaintInvalidatorTest : public RenderingTest { |
+class BoxPaintInvalidatorTest : public ::testing::WithParamInterface<bool>, |
+ private ScopedRootLayerScrollingForTest, |
+ public RenderingTest { |
+ public: |
+ BoxPaintInvalidatorTest() |
+ : ScopedRootLayerScrollingForTest(GetParam()), |
+ RenderingTest(SingleChildFrameLoaderClient::create()) {} |
+ |
protected: |
const RasterInvalidationTracking* getRasterInvalidationTracking() const { |
// TODO(wangxianzhu): Test SPv2. |
return layoutView() |
.layer() |
- ->graphicsLayerBacking() |
+ ->graphicsLayerBackingForScrolling() |
->getRasterInvalidationTracking(); |
} |
@@ -29,28 +36,43 @@ class BoxPaintInvalidatorTest : public RenderingTest { |
enableCompositing(); |
setBodyInnerHTML( |
"<style>" |
- " body { margin: 0 }" |
+ " body {" |
+ " margin: 0;" |
+ " height: 0;" |
+ " }" |
+ " ::-webkit-scrollbar { display: none }" |
" #target {" |
" width: 50px;" |
" height: 100px;" |
+ " transform-origin: 0 0;" |
+ " }" |
+ " .border {" |
" border-width: 20px 10px;" |
" border-style: solid;" |
" border-color: red;" |
- " transform-origin: 0 0" |
+ " }" |
+ " .local-background {" |
+ " background-attachment: local;" |
+ " overflow: scroll;" |
+ " }" |
+ " .gradient {" |
+ " background-image: linear-gradient(blue, yellow)" |
" }" |
"</style>" |
- "<div id='target'></div>"); |
+ "<div id='target' class='border'></div>"); |
} |
}; |
-TEST_F(BoxPaintInvalidatorTest, IncrementalInvalidationExpand) { |
+INSTANTIATE_TEST_CASE_P(All, BoxPaintInvalidatorTest, ::testing::Bool()); |
+ |
+TEST_P(BoxPaintInvalidatorTest, IncrementalInvalidationExpand) { |
document().view()->setTracksPaintInvalidations(true); |
Element* target = document().getElementById("target"); |
target->setAttribute(HTMLNames::styleAttr, "width: 100px; height: 200px"); |
document().view()->updateAllLifecyclePhases(); |
const auto& rasterInvalidations = |
getRasterInvalidationTracking()->trackedRasterInvalidations; |
- EXPECT_EQ(2u, rasterInvalidations.size()); |
+ ASSERT_EQ(2u, rasterInvalidations.size()); |
EXPECT_EQ(IntRect(60, 0, 60, 240), rasterInvalidations[0].rect); |
EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason); |
EXPECT_EQ(IntRect(0, 120, 120, 120), rasterInvalidations[1].rect); |
@@ -58,14 +80,14 @@ TEST_F(BoxPaintInvalidatorTest, IncrementalInvalidationExpand) { |
document().view()->setTracksPaintInvalidations(false); |
} |
-TEST_F(BoxPaintInvalidatorTest, IncrementalInvalidationShrink) { |
+TEST_P(BoxPaintInvalidatorTest, IncrementalInvalidationShrink) { |
document().view()->setTracksPaintInvalidations(true); |
Element* target = document().getElementById("target"); |
target->setAttribute(HTMLNames::styleAttr, "width: 20px; height: 80px"); |
document().view()->updateAllLifecyclePhases(); |
const auto& rasterInvalidations = |
getRasterInvalidationTracking()->trackedRasterInvalidations; |
- EXPECT_EQ(2u, rasterInvalidations.size()); |
+ ASSERT_EQ(2u, rasterInvalidations.size()); |
EXPECT_EQ(IntRect(30, 0, 40, 140), rasterInvalidations[0].rect); |
EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason); |
EXPECT_EQ(IntRect(0, 100, 70, 40), rasterInvalidations[1].rect); |
@@ -73,14 +95,14 @@ TEST_F(BoxPaintInvalidatorTest, IncrementalInvalidationShrink) { |
document().view()->setTracksPaintInvalidations(false); |
} |
-TEST_F(BoxPaintInvalidatorTest, IncrementalInvalidationMixed) { |
+TEST_P(BoxPaintInvalidatorTest, IncrementalInvalidationMixed) { |
document().view()->setTracksPaintInvalidations(true); |
Element* target = document().getElementById("target"); |
target->setAttribute(HTMLNames::styleAttr, "width: 100px; height: 80px"); |
document().view()->updateAllLifecyclePhases(); |
const auto& rasterInvalidations = |
getRasterInvalidationTracking()->trackedRasterInvalidations; |
- EXPECT_EQ(2u, rasterInvalidations.size()); |
+ ASSERT_EQ(2u, rasterInvalidations.size()); |
EXPECT_EQ(IntRect(60, 0, 60, 120), rasterInvalidations[0].rect); |
EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason); |
EXPECT_EQ(IntRect(0, 100, 70, 40), rasterInvalidations[1].rect); |
@@ -88,7 +110,7 @@ TEST_F(BoxPaintInvalidatorTest, IncrementalInvalidationMixed) { |
document().view()->setTracksPaintInvalidations(false); |
} |
-TEST_F(BoxPaintInvalidatorTest, SubpixelVisualRectChagne) { |
+TEST_P(BoxPaintInvalidatorTest, SubpixelVisualRectChagne) { |
ScopedSlimmingPaintInvalidationForTest scopedSlimmingPaintInvalidation(true); |
Element* target = document().getElementById("target"); |
@@ -99,7 +121,7 @@ TEST_F(BoxPaintInvalidatorTest, SubpixelVisualRectChagne) { |
document().view()->updateAllLifecyclePhases(); |
const auto* rasterInvalidations = |
&getRasterInvalidationTracking()->trackedRasterInvalidations; |
- EXPECT_EQ(2u, rasterInvalidations->size()); |
+ ASSERT_EQ(2u, rasterInvalidations->size()); |
EXPECT_EQ(IntRect(0, 0, 70, 140), (*rasterInvalidations)[0].rect); |
EXPECT_EQ(PaintInvalidationBorderBoxChange, (*rasterInvalidations)[0].reason); |
EXPECT_EQ(IntRect(0, 0, 121, 111), (*rasterInvalidations)[1].rect); |
@@ -112,7 +134,7 @@ TEST_F(BoxPaintInvalidatorTest, SubpixelVisualRectChagne) { |
document().view()->updateAllLifecyclePhases(); |
rasterInvalidations = |
&getRasterInvalidationTracking()->trackedRasterInvalidations; |
- EXPECT_EQ(2u, rasterInvalidations->size()); |
+ ASSERT_EQ(2u, rasterInvalidations->size()); |
EXPECT_EQ(IntRect(0, 0, 121, 111), (*rasterInvalidations)[0].rect); |
EXPECT_EQ(PaintInvalidationBorderBoxChange, (*rasterInvalidations)[0].reason); |
EXPECT_EQ(IntRect(0, 0, 70, 140), (*rasterInvalidations)[1].rect); |
@@ -120,7 +142,7 @@ TEST_F(BoxPaintInvalidatorTest, SubpixelVisualRectChagne) { |
document().view()->setTracksPaintInvalidations(false); |
} |
-TEST_F(BoxPaintInvalidatorTest, SubpixelChangeWithoutVisualRectChange) { |
+TEST_P(BoxPaintInvalidatorTest, SubpixelChangeWithoutVisualRectChange) { |
ScopedSlimmingPaintInvalidationForTest scopedSlimmingPaintInvalidation(true); |
Element* target = document().getElementById("target"); |
@@ -136,7 +158,7 @@ TEST_F(BoxPaintInvalidatorTest, SubpixelChangeWithoutVisualRectChange) { |
EXPECT_EQ(LayoutRect(0, 0, 70, 140), targetObject->previousVisualRect()); |
const auto* rasterInvalidations = |
&getRasterInvalidationTracking()->trackedRasterInvalidations; |
- EXPECT_EQ(1u, rasterInvalidations->size()); |
+ ASSERT_EQ(1u, rasterInvalidations->size()); |
EXPECT_EQ(IntRect(0, 0, 70, 140), (*rasterInvalidations)[0].rect); |
EXPECT_EQ(PaintInvalidationLocationChange, (*rasterInvalidations)[0].reason); |
document().view()->setTracksPaintInvalidations(false); |
@@ -148,13 +170,13 @@ TEST_F(BoxPaintInvalidatorTest, SubpixelChangeWithoutVisualRectChange) { |
EXPECT_EQ(LayoutRect(0, 0, 70, 140), targetObject->previousVisualRect()); |
rasterInvalidations = |
&getRasterInvalidationTracking()->trackedRasterInvalidations; |
- EXPECT_EQ(1u, rasterInvalidations->size()); |
+ ASSERT_EQ(1u, rasterInvalidations->size()); |
EXPECT_EQ(IntRect(0, 0, 70, 140), (*rasterInvalidations)[0].rect); |
EXPECT_EQ(PaintInvalidationBorderBoxChange, (*rasterInvalidations)[0].reason); |
document().view()->setTracksPaintInvalidations(false); |
} |
-TEST_F(BoxPaintInvalidatorTest, ResizeRotated) { |
+TEST_P(BoxPaintInvalidatorTest, ResizeRotated) { |
ScopedSlimmingPaintInvalidationForTest scopedSlimmingPaintInvalidation(true); |
Element* target = document().getElementById("target"); |
@@ -168,13 +190,13 @@ TEST_F(BoxPaintInvalidatorTest, ResizeRotated) { |
document().view()->updateAllLifecyclePhases(); |
const auto* rasterInvalidations = |
&getRasterInvalidationTracking()->trackedRasterInvalidations; |
- EXPECT_EQ(1u, rasterInvalidations->size()); |
+ ASSERT_EQ(1u, rasterInvalidations->size()); |
EXPECT_EQ(IntRect(-99, 0, 255, 255), (*rasterInvalidations)[0].rect); |
EXPECT_EQ(PaintInvalidationBorderBoxChange, (*rasterInvalidations)[0].reason); |
document().view()->setTracksPaintInvalidations(false); |
} |
-TEST_F(BoxPaintInvalidatorTest, ResizeRotatedChild) { |
+TEST_P(BoxPaintInvalidatorTest, ResizeRotatedChild) { |
ScopedSlimmingPaintInvalidationForTest scopedSlimmingPaintInvalidation(true); |
Element* target = document().getElementById("target"); |
@@ -193,10 +215,362 @@ TEST_F(BoxPaintInvalidatorTest, ResizeRotatedChild) { |
document().view()->updateAllLifecyclePhases(); |
const auto* rasterInvalidations = |
&getRasterInvalidationTracking()->trackedRasterInvalidations; |
- EXPECT_EQ(1u, rasterInvalidations->size()); |
+ ASSERT_EQ(1u, rasterInvalidations->size()); |
EXPECT_EQ(IntRect(-43, 21, 107, 107), (*rasterInvalidations)[0].rect); |
EXPECT_EQ(PaintInvalidationBorderBoxChange, (*rasterInvalidations)[0].reason); |
document().view()->setTracksPaintInvalidations(false); |
} |
+TEST_P(BoxPaintInvalidatorTest, CompositedLayoutViewResize) { |
+ enableCompositing(); |
+ Element* target = document().getElementById("target"); |
+ target->setAttribute(HTMLNames::classAttr, ""); |
+ target->setAttribute(HTMLNames::styleAttr, "height: 2000px"); |
+ document().view()->updateAllLifecyclePhases(); |
+ |
+ // Resize the content. |
+ document().view()->setTracksPaintInvalidations(true); |
+ target->setAttribute(HTMLNames::styleAttr, "height: 3000px"); |
+ document().view()->updateAllLifecyclePhases(); |
+ if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
+ // For now in RootLayerScrolling mode root background is invalidated and |
+ // painted on the container layer. No invalidation because the changed part |
+ // is clipped. |
+ // TODO(skobes): Treat LayoutView in the same way as normal objects having |
+ // background-attachment: local. crbug.com/568847. |
+ EXPECT_FALSE(layoutView() |
+ .layer() |
+ ->graphicsLayerBacking() |
+ ->getRasterInvalidationTracking()); |
+ } else { |
+ const auto& rasterInvalidations = |
+ getRasterInvalidationTracking()->trackedRasterInvalidations; |
+ ASSERT_EQ(1u, rasterInvalidations.size()); |
+ EXPECT_EQ(IntRect(0, 2000, 800, 1000), rasterInvalidations[0].rect); |
+ EXPECT_EQ(static_cast<const DisplayItemClient*>(&layoutView()), |
+ rasterInvalidations[0].client); |
+ EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason); |
+ } |
+ document().view()->setTracksPaintInvalidations(false); |
+ |
+ // Resize the viewport. No paint invalidation. |
+ document().view()->setTracksPaintInvalidations(true); |
+ document().view()->resize(800, 1000); |
+ document().view()->updateAllLifecyclePhases(); |
+ EXPECT_FALSE(getRasterInvalidationTracking()); |
+ document().view()->setTracksPaintInvalidations(false); |
+} |
+ |
+TEST_P(BoxPaintInvalidatorTest, CompositedLayoutViewGradientResize) { |
+ enableCompositing(); |
+ document().body()->setAttribute(HTMLNames::classAttr, "gradient"); |
+ Element* target = document().getElementById("target"); |
+ target->setAttribute(HTMLNames::classAttr, ""); |
+ target->setAttribute(HTMLNames::styleAttr, "height: 2000px"); |
+ document().view()->updateAllLifecyclePhases(); |
+ |
+ // Resize the content. |
+ document().view()->setTracksPaintInvalidations(true); |
+ target->setAttribute(HTMLNames::styleAttr, "height: 3000px"); |
+ document().view()->updateAllLifecyclePhases(); |
+ if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
+ // For now in RootLayerScrolling mode root background is invalidated and |
+ // painted on the container layer. |
+ // TODO(skobes): Treat LayoutView in the same way as normal objects having |
+ // background-attachment: local. crbug.com/568847. |
+ const auto& rasterInvalidations = layoutView() |
+ .layer() |
+ ->graphicsLayerBacking() |
+ ->getRasterInvalidationTracking() |
+ ->trackedRasterInvalidations; |
+ ASSERT_EQ(1u, rasterInvalidations.size()); |
+ EXPECT_EQ(IntRect(0, 0, 800, 600), rasterInvalidations[0].rect); |
+ EXPECT_EQ(static_cast<const DisplayItemClient*>(&layoutView()), |
+ rasterInvalidations[0].client); |
+ EXPECT_EQ(PaintInvalidationLayoutOverflowBoxChange, |
+ rasterInvalidations[0].reason); |
+ } else { |
+ const auto& rasterInvalidations = |
+ getRasterInvalidationTracking()->trackedRasterInvalidations; |
+ ASSERT_EQ(1u, rasterInvalidations.size()); |
+ EXPECT_EQ(IntRect(0, 0, 800, 3000), rasterInvalidations[0].rect); |
+ EXPECT_EQ(static_cast<const DisplayItemClient*>(&layoutView()), |
+ rasterInvalidations[0].client); |
+ EXPECT_EQ(PaintInvalidationLayoutOverflowBoxChange, |
+ rasterInvalidations[0].reason); |
+ } |
+ document().view()->setTracksPaintInvalidations(false); |
+ |
+ // Resize the viewport. No paint invalidation. |
+ document().view()->setTracksPaintInvalidations(true); |
+ document().view()->resize(800, 1000); |
+ document().view()->updateAllLifecyclePhases(); |
+ EXPECT_FALSE(getRasterInvalidationTracking()); |
+ document().view()->setTracksPaintInvalidations(false); |
+} |
+ |
+TEST_P(BoxPaintInvalidatorTest, NonCompositedLayoutViewResize) { |
+ setBodyInnerHTML( |
+ "<style>" |
+ " body { margin: 0 }" |
+ " iframe { display: block; width: 100px; height: 100px; border: none; }" |
+ "</style>" |
+ "<iframe id='iframe'></iframe>"); |
+ Document& frameDocument = setupChildIframe( |
+ "iframe", |
+ "<style>" |
+ " ::-webkit-scrollbar { display: none }" |
+ " body { margin: 0; background: green; height: 0 }" |
+ "</style>" |
+ "<div id='content' style='width: 200px; height: 200px'></div>"); |
+ document().view()->updateAllLifecyclePhases(); |
+ Element* iframe = document().getElementById("iframe"); |
+ Element* content = frameDocument.getElementById("content"); |
+ EXPECT_EQ(layoutView(), |
+ content->layoutObject()->containerForPaintInvalidation()); |
+ |
+ // Resize the content. |
+ document().view()->setTracksPaintInvalidations(true); |
+ content->setAttribute(HTMLNames::styleAttr, "height: 500px"); |
+ document().view()->updateAllLifecyclePhases(); |
+ // No invalidation because the changed part of layout overflow is clipped. |
+ EXPECT_FALSE(getRasterInvalidationTracking()); |
+ document().view()->setTracksPaintInvalidations(false); |
+ |
+ // Resize the iframe. |
+ document().view()->setTracksPaintInvalidations(true); |
+ iframe->setAttribute(HTMLNames::styleAttr, "height: 200px"); |
+ document().view()->updateAllLifecyclePhases(); |
+ const auto& rasterInvalidations = |
+ getRasterInvalidationTracking()->trackedRasterInvalidations; |
+ ASSERT_EQ(2u, rasterInvalidations.size()); |
+ EXPECT_EQ(IntRect(0, 100, 100, 100), rasterInvalidations[0].rect); |
+ EXPECT_EQ(static_cast<const DisplayItemClient*>(iframe->layoutObject()), |
+ rasterInvalidations[0].client); |
+ EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason); |
+ EXPECT_EQ( |
+ static_cast<const DisplayItemClient*>(content->layoutObject()->view()), |
+ rasterInvalidations[1].client); |
+ if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
+ // TODO(skobes): Treat LayoutView in the same way as normal objects having |
+ // background-attachment: local. crbug.com/568847. |
+ EXPECT_EQ(IntRect(0, 0, 100, 200), rasterInvalidations[1].rect); |
+ EXPECT_EQ(PaintInvalidationFull, rasterInvalidations[1].reason); |
+ } else { |
+ EXPECT_EQ(IntRect(0, 100, 100, 100), rasterInvalidations[1].rect); |
+ EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[1].reason); |
+ } |
+ document().view()->setTracksPaintInvalidations(false); |
+} |
+ |
+TEST_P(BoxPaintInvalidatorTest, NonCompositedLayoutViewGradientResize) { |
+ setBodyInnerHTML( |
+ "<style>" |
+ " body { margin: 0 }" |
+ " iframe { display: block; width: 100px; height: 100px; border: none; }" |
+ "</style>" |
+ "<iframe id='iframe'></iframe>"); |
+ Document& frameDocument = setupChildIframe( |
+ "iframe", |
+ "<style>" |
+ " ::-webkit-scrollbar { display: none }" |
+ " body {" |
+ " margin: 0;" |
+ " height: 0;" |
+ " background-image: linear-gradient(blue, yellow);" |
+ " }" |
+ "</style>" |
+ "<div id='content' style='width: 200px; height: 200px'></div>"); |
+ document().view()->updateAllLifecyclePhases(); |
+ Element* iframe = document().getElementById("iframe"); |
+ Element* content = frameDocument.getElementById("content"); |
+ LayoutView* frameLayoutView = content->layoutObject()->view(); |
+ EXPECT_EQ(layoutView(), |
+ content->layoutObject()->containerForPaintInvalidation()); |
+ |
+ // Resize the content. |
+ document().view()->setTracksPaintInvalidations(true); |
+ content->setAttribute(HTMLNames::styleAttr, "height: 500px"); |
+ document().view()->updateAllLifecyclePhases(); |
+ const auto* rasterInvalidations = |
+ &getRasterInvalidationTracking()->trackedRasterInvalidations; |
+ ASSERT_EQ(1u, rasterInvalidations->size()); |
+ EXPECT_EQ(IntRect(0, 0, 100, 100), (*rasterInvalidations)[0].rect); |
+ EXPECT_EQ(static_cast<const DisplayItemClient*>(frameLayoutView), |
+ (*rasterInvalidations)[0].client); |
+ EXPECT_EQ(PaintInvalidationLayoutOverflowBoxChange, |
+ (*rasterInvalidations)[0].reason); |
+ document().view()->setTracksPaintInvalidations(false); |
+ |
+ // Resize the iframe. |
+ document().view()->setTracksPaintInvalidations(true); |
+ iframe->setAttribute(HTMLNames::styleAttr, "height: 200px"); |
+ document().view()->updateAllLifecyclePhases(); |
+ rasterInvalidations = |
+ &getRasterInvalidationTracking()->trackedRasterInvalidations; |
+ ASSERT_EQ(2u, rasterInvalidations->size()); |
+ EXPECT_EQ(IntRect(0, 100, 100, 100), (*rasterInvalidations)[0].rect); |
+ EXPECT_EQ(static_cast<const DisplayItemClient*>(iframe->layoutObject()), |
+ (*rasterInvalidations)[0].client); |
+ EXPECT_EQ(PaintInvalidationIncremental, (*rasterInvalidations)[0].reason); |
+ EXPECT_EQ(static_cast<const DisplayItemClient*>(frameLayoutView), |
+ (*rasterInvalidations)[1].client); |
+ EXPECT_EQ(IntRect(0, 0, 100, 200), (*rasterInvalidations)[1].rect); |
+ if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
+ // TODO(skobes): Treat LayoutView in the same way as normal objects having |
+ // background-attachment: local. crbug.com/568847. |
+ EXPECT_EQ(PaintInvalidationFull, (*rasterInvalidations)[1].reason); |
+ } else { |
+ EXPECT_EQ(PaintInvalidationBorderBoxChange, |
+ (*rasterInvalidations)[1].reason); |
+ } |
+ document().view()->setTracksPaintInvalidations(false); |
+} |
+ |
+TEST_P(BoxPaintInvalidatorTest, CompositedBackgroundAttachmentLocalResize) { |
+ enableCompositing(); |
+ |
+ Element* target = document().getElementById("target"); |
+ target->setAttribute(HTMLNames::classAttr, "border local-background"); |
+ target->setAttribute(HTMLNames::styleAttr, "will-change: transform"); |
+ target->setInnerHTML( |
+ "<div id=child style='width: 500px; height: 500px'></div>", |
+ ASSERT_NO_EXCEPTION); |
+ Element* child = document().getElementById("child"); |
+ document().view()->updateAllLifecyclePhases(); |
+ |
+ // Resize the content. |
+ document().view()->setTracksPaintInvalidations(true); |
+ child->setAttribute(HTMLNames::styleAttr, "width: 500px; height: 1000px"); |
+ document().view()->updateAllLifecyclePhases(); |
+ GraphicsLayer* containerLayer = toLayoutBoxModelObject(target->layoutObject()) |
+ ->layer() |
+ ->graphicsLayerBacking(); |
+ GraphicsLayer* contentsLayer = toLayoutBoxModelObject(target->layoutObject()) |
+ ->layer() |
+ ->graphicsLayerBackingForScrolling(); |
+ // No invalidation on the container layer. |
+ EXPECT_FALSE(containerLayer->getRasterInvalidationTracking()); |
+ // Incremental invalidation of background on contents layer. |
+ const auto& contentsRasterInvalidations = |
+ contentsLayer->getRasterInvalidationTracking() |
+ ->trackedRasterInvalidations; |
+ ASSERT_EQ(1u, contentsRasterInvalidations.size()); |
+ EXPECT_EQ(IntRect(0, 500, 500, 500), contentsRasterInvalidations[0].rect); |
+ EXPECT_EQ(static_cast<const DisplayItemClient*>(target->layoutObject()), |
+ contentsRasterInvalidations[0].client); |
+ EXPECT_EQ(PaintInvalidationBackgroundOnScrollingContentsLayer, |
+ contentsRasterInvalidations[0].reason); |
+ document().view()->setTracksPaintInvalidations(false); |
+ |
+ // Resize the container. |
+ document().view()->setTracksPaintInvalidations(true); |
+ target->setAttribute(HTMLNames::styleAttr, |
+ "will-change: transform; height: 200px"); |
+ document().view()->updateAllLifecyclePhases(); |
+ // No invalidation on the contents layer. |
+ EXPECT_FALSE(contentsLayer->getRasterInvalidationTracking()); |
+ // Incremental invalidation on the container layer. |
+ const auto& containerRasterInvalidations = |
+ containerLayer->getRasterInvalidationTracking() |
+ ->trackedRasterInvalidations; |
+ ASSERT_EQ(1u, containerRasterInvalidations.size()); |
+ EXPECT_EQ(IntRect(0, 120, 70, 120), containerRasterInvalidations[0].rect); |
+ EXPECT_EQ(static_cast<const DisplayItemClient*>(target->layoutObject()), |
+ containerRasterInvalidations[0].client); |
+ EXPECT_EQ(PaintInvalidationIncremental, |
+ containerRasterInvalidations[0].reason); |
+ document().view()->setTracksPaintInvalidations(false); |
+} |
+ |
+TEST_P(BoxPaintInvalidatorTest, |
+ CompositedBackgroundAttachmentLocalGradientResize) { |
+ enableCompositing(); |
+ |
+ Element* target = document().getElementById("target"); |
+ target->setAttribute(HTMLNames::classAttr, |
+ "border local-background gradient"); |
+ target->setAttribute(HTMLNames::styleAttr, "will-change: transform"); |
+ target->setInnerHTML( |
+ "<div id='child' style='width: 500px; height: 500px'></div>", |
+ ASSERT_NO_EXCEPTION); |
+ Element* child = document().getElementById("child"); |
+ document().view()->updateAllLifecyclePhases(); |
+ |
+ // Resize the content. |
+ document().view()->setTracksPaintInvalidations(true); |
+ child->setAttribute(HTMLNames::styleAttr, "width: 500px; height: 1000px"); |
+ document().view()->updateAllLifecyclePhases(); |
+ GraphicsLayer* containerLayer = toLayoutBoxModelObject(target->layoutObject()) |
+ ->layer() |
+ ->graphicsLayerBacking(); |
+ GraphicsLayer* contentsLayer = toLayoutBoxModelObject(target->layoutObject()) |
+ ->layer() |
+ ->graphicsLayerBackingForScrolling(); |
+ // No invalidation on the container layer. |
+ EXPECT_FALSE(containerLayer->getRasterInvalidationTracking()); |
+ // Full invalidation of background on contents layer because the gradient |
+ // background is resized. |
+ const auto& contentsRasterInvalidations = |
+ contentsLayer->getRasterInvalidationTracking() |
+ ->trackedRasterInvalidations; |
+ ASSERT_EQ(1u, contentsRasterInvalidations.size()); |
+ EXPECT_EQ(IntRect(0, 0, 500, 1000), contentsRasterInvalidations[0].rect); |
+ EXPECT_EQ(static_cast<const DisplayItemClient*>(target->layoutObject()), |
+ contentsRasterInvalidations[0].client); |
+ EXPECT_EQ(PaintInvalidationBackgroundOnScrollingContentsLayer, |
+ contentsRasterInvalidations[0].reason); |
+ document().view()->setTracksPaintInvalidations(false); |
+ |
+ // Resize the container. |
+ document().view()->setTracksPaintInvalidations(true); |
+ target->setAttribute(HTMLNames::styleAttr, |
+ "will-change: transform; height: 200px"); |
+ document().view()->updateAllLifecyclePhases(); |
+ EXPECT_FALSE(contentsLayer->getRasterInvalidationTracking()); |
+ // Full invalidation on the container layer. |
+ const auto& containerRasterInvalidations = |
+ containerLayer->getRasterInvalidationTracking() |
+ ->trackedRasterInvalidations; |
+ ASSERT_EQ(1u, containerRasterInvalidations.size()); |
+ EXPECT_EQ(IntRect(0, 0, 70, 240), containerRasterInvalidations[0].rect); |
+ EXPECT_EQ(static_cast<const DisplayItemClient*>(target->layoutObject()), |
+ containerRasterInvalidations[0].client); |
+ EXPECT_EQ(PaintInvalidationBorderBoxChange, |
+ containerRasterInvalidations[0].reason); |
+ document().view()->setTracksPaintInvalidations(false); |
+} |
+ |
+TEST_P(BoxPaintInvalidatorTest, NonCompositedBackgroundAttachmentLocalResize) { |
+ Element* target = document().getElementById("target"); |
+ target->setAttribute(HTMLNames::classAttr, "border local-background"); |
+ target->setInnerHTML( |
+ "<div id=child style='width: 500px; height: 500px'></div>", |
+ ASSERT_NO_EXCEPTION); |
+ Element* child = document().getElementById("child"); |
+ document().view()->updateAllLifecyclePhases(); |
+ EXPECT_EQ(&layoutView(), |
+ &target->layoutObject()->containerForPaintInvalidation()); |
+ |
+ // Resize the content. |
+ document().view()->setTracksPaintInvalidations(true); |
+ child->setAttribute(HTMLNames::styleAttr, "width: 500px; height: 1000px"); |
+ document().view()->updateAllLifecyclePhases(); |
+ // No invalidation because the changed part is invisible. |
+ EXPECT_FALSE(getRasterInvalidationTracking()); |
+ |
+ // Resize the container. |
+ document().view()->setTracksPaintInvalidations(true); |
+ target->setAttribute(HTMLNames::styleAttr, "height: 200px"); |
+ document().view()->updateAllLifecyclePhases(); |
+ const auto& rasterInvalidations = |
+ getRasterInvalidationTracking()->trackedRasterInvalidations; |
+ ASSERT_EQ(1u, rasterInvalidations.size()); |
+ EXPECT_EQ(IntRect(0, 120, 70, 120), rasterInvalidations[0].rect); |
+ EXPECT_EQ(static_cast<const DisplayItemClient*>(target->layoutObject()), |
+ rasterInvalidations[0].client); |
+ EXPECT_EQ(PaintInvalidationIncremental, rasterInvalidations[0].reason); |
+ document().view()->setTracksPaintInvalidations(false); |
+} |
+ |
} // namespace blink |