Index: third_party/WebKit/Source/core/paint/PaintInvalidationTest.cpp |
diff --git a/third_party/WebKit/Source/core/paint/PaintInvalidationTest.cpp b/third_party/WebKit/Source/core/paint/PaintInvalidationTest.cpp |
index 324131bdaa23627b2b0a615d0ab29786c4256c25..9ee783cdc4f08ddabd513c80f20101fc9e42d092 100644 |
--- a/third_party/WebKit/Source/core/paint/PaintInvalidationTest.cpp |
+++ b/third_party/WebKit/Source/core/paint/PaintInvalidationTest.cpp |
@@ -6,6 +6,8 @@ |
#include "core/layout/LayoutTestHelper.h" |
#include "core/layout/LayoutView.h" |
#include "core/paint/PaintLayer.h" |
+#include "platform/graphics/GraphicsLayer.h" |
+#include "platform/graphics/paint/RasterInvalidationTracking.h" |
#include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -20,6 +22,15 @@ class PaintInvalidationTest : public ::testing::WithParamInterface<bool>, |
PaintInvalidationTest() |
: ScopedRootLayerScrollingForTest(GetParam()), |
RenderingTest(SingleChildLocalFrameClient::Create()) {} |
+ |
+ protected: |
+ const RasterInvalidationTracking* GetRasterInvalidationTracking() const { |
+ // TODO(wangxianzhu): Test SPv2. |
+ return GetLayoutView() |
+ .Layer() |
+ ->GraphicsLayerBacking() |
+ ->GetRasterInvalidationTracking(); |
+ } |
}; |
INSTANTIATE_TEST_CASE_P(All, PaintInvalidationTest, ::testing::Bool()); |
@@ -153,6 +164,43 @@ TEST_P(PaintInvalidationTest, InvisibleTransformUnderFixedOnScroll) { |
GetDocument().View()->UpdateAllLifecyclePhases(); |
} |
+TEST_P(PaintInvalidationTest, DelayedFullPaintInvalidation) { |
+ EnableCompositing(); |
+ SetBodyInnerHTML( |
+ "<style>body { margin: 0 }</style>" |
+ "<div style='height: 4000px'></div>" |
+ "<div id='target' style='width: 100px; height: 100px; background: blue'>" |
+ "</div>"); |
+ |
+ auto* target = GetLayoutObjectByElementId("target"); |
+ target->SetShouldDoFullPaintInvalidationWithoutGeometryChange( |
+ kPaintInvalidationDelayedFull); |
+ EXPECT_EQ(kPaintInvalidationDelayedFull, |
+ target->FullPaintInvalidationReason()); |
+ EXPECT_FALSE(target->NeedsPaintOffsetAndVisualRectUpdate()); |
+ |
+ GetDocument().View()->SetTracksPaintInvalidations(true); |
+ GetDocument().View()->UpdateAllLifecyclePhases(); |
+ EXPECT_EQ(nullptr, GetRasterInvalidationTracking()); |
+ EXPECT_EQ(kPaintInvalidationDelayedFull, |
+ target->FullPaintInvalidationReason()); |
+ EXPECT_FALSE(target->NeedsPaintOffsetAndVisualRectUpdate()); |
+ GetDocument().View()->SetTracksPaintInvalidations(false); |
+ |
+ GetDocument().View()->SetTracksPaintInvalidations(true); |
+ // Scroll target into view. |
+ GetDocument().domWindow()->scrollTo(0, 4000); |
+ GetDocument().View()->UpdateAllLifecyclePhases(); |
+ const auto& raster_invalidations = |
+ GetRasterInvalidationTracking()->tracked_raster_invalidations; |
+ ASSERT_EQ(1u, raster_invalidations.size()); |
+ EXPECT_EQ(kPaintInvalidationNone, target->FullPaintInvalidationReason()); |
+ EXPECT_EQ(IntRect(0, 4000, 100, 100), raster_invalidations[0].rect); |
+ EXPECT_EQ(kPaintInvalidationFull, raster_invalidations[0].reason); |
+ EXPECT_FALSE(target->NeedsPaintOffsetAndVisualRectUpdate()); |
+ GetDocument().View()->SetTracksPaintInvalidations(false); |
+}; |
+ |
} // namespace |
} // namespace blink |