Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(974)

Unified Diff: third_party/WebKit/Source/core/paint/PaintLayerPainterTest.cpp

Issue 1900263002: Update PaintLayer::needsPaintPhase flags when layer self-painting status changes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/paint/PaintLayerPainterTest.cpp
diff --git a/third_party/WebKit/Source/core/paint/PaintLayerPainterTest.cpp b/third_party/WebKit/Source/core/paint/PaintLayerPainterTest.cpp
index 3ff56a1a50d338d786a12badc5b414b429f3e855..299dd4735000ec3145d0fec3763d6523ca2edd62 100644
--- a/third_party/WebKit/Source/core/paint/PaintLayerPainterTest.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintLayerPainterTest.cpp
@@ -420,4 +420,59 @@ TEST_P(PaintLayerPainterTest, PaintPhasesUpdateOnLayerAddition)
EXPECT_TRUE(layer.needsPaintPhaseDescendantBlockBackgrounds());
}
+TEST_P(PaintLayerPainterTest, PaintPhasesUpdateOnBecomingSelfPainting)
+{
+ setBodyInnerHTML(
+ "<div id='will-be-self-painting' style='height: 100px; overflow: hidden'>"
+ " <div style='height: 200px; outline: 1px solid red; background-color: green'>outline and background</div>"
+ " <div style='float: left; height: 80px; width: 50px'>float</div>"
+ "</div>");
+
+ LayoutBlock& layerDiv = *toLayoutBlock(document().getElementById("will-be-self-painting")->layoutObject());
+ ASSERT_TRUE(layerDiv.hasLayer());
+ EXPECT_FALSE(layerDiv.layer()->isSelfPaintingLayer());
+
+ PaintLayer& htmlLayer = *toLayoutBlock(document().documentElement()->layoutObject())->layer();
+ EXPECT_TRUE(htmlLayer.needsPaintPhaseDescendantOutlines());
+ EXPECT_TRUE(htmlLayer.needsPaintPhaseFloat());
+ EXPECT_TRUE(htmlLayer.needsPaintPhaseDescendantBlockBackgrounds());
+
+ toHTMLElement(layerDiv.node())->setAttribute(HTMLNames::styleAttr, "height: 100px; overflow: hidden; position: relative");
+ document().view()->updateAllLifecyclePhases();
+ PaintLayer& layer = *layerDiv.layer();
+ ASSERT_TRUE(layer.isSelfPaintingLayer());
+ EXPECT_TRUE(layer.needsPaintPhaseDescendantOutlines());
+ EXPECT_TRUE(layer.needsPaintPhaseFloat());
+ EXPECT_TRUE(layer.needsPaintPhaseDescendantBlockBackgrounds());
+}
+
+TEST_P(PaintLayerPainterTest, PaintPhasesUpdateOnBecomingNonSelfPainting)
+{
+ setBodyInnerHTML(
+ "<div id='will-be-non-self-painting' style='height: 100px; overflow: hidden; position: relative'>"
+ " <div style='height: 200px; outline: 1px solid red; background-color: green'>outline and background</div>"
+ " <div style='float: left; height: 80px; width: 50px'>float</div>"
+ "</div>");
+
+ LayoutBlock& layerDiv = *toLayoutBlock(document().getElementById("will-be-non-self-painting")->layoutObject());
+ ASSERT_TRUE(layerDiv.hasLayer());
+ PaintLayer& layer = *layerDiv.layer();
+ EXPECT_TRUE(layer.isSelfPaintingLayer());
+ EXPECT_TRUE(layer.needsPaintPhaseDescendantOutlines());
+ EXPECT_TRUE(layer.needsPaintPhaseFloat());
+ EXPECT_TRUE(layer.needsPaintPhaseDescendantBlockBackgrounds());
+
+ PaintLayer& htmlLayer = *toLayoutBlock(document().documentElement()->layoutObject())->layer();
+ EXPECT_FALSE(htmlLayer.needsPaintPhaseDescendantOutlines());
+ EXPECT_FALSE(htmlLayer.needsPaintPhaseFloat());
+ EXPECT_FALSE(htmlLayer.needsPaintPhaseDescendantBlockBackgrounds());
+
+ toHTMLElement(layerDiv.node())->setAttribute(HTMLNames::styleAttr, "height: 100px; overflow: hidden");
+ document().view()->updateAllLifecyclePhases();
+ EXPECT_FALSE(layer.isSelfPaintingLayer());
+ EXPECT_TRUE(htmlLayer.needsPaintPhaseDescendantOutlines());
+ EXPECT_TRUE(htmlLayer.needsPaintPhaseFloat());
+ EXPECT_TRUE(htmlLayer.needsPaintPhaseDescendantBlockBackgrounds());
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698