Index: third_party/WebKit/Source/core/paint/PaintLayerScrollableAreaTest.cpp |
diff --git a/third_party/WebKit/Source/core/paint/PaintLayerScrollableAreaTest.cpp b/third_party/WebKit/Source/core/paint/PaintLayerScrollableAreaTest.cpp |
index f11b78585bf5bbf4aa33df3d6d844357746ec8e4..488df2e9ba631eed60fa1ea9e0e26446319a4fc5 100644 |
--- a/third_party/WebKit/Source/core/paint/PaintLayerScrollableAreaTest.cpp |
+++ b/third_party/WebKit/Source/core/paint/PaintLayerScrollableAreaTest.cpp |
@@ -4,6 +4,8 @@ |
#include "core/paint/PaintLayerScrollableAreaTest.h" |
+#include "platform/graphics/GraphicsLayer.h" |
+ |
namespace blink { |
TEST_F(PaintLayerScrollableAreaTest, OpaqueLayersPromoted) |
@@ -12,17 +14,20 @@ TEST_F(PaintLayerScrollableAreaTest, OpaqueLayersPromoted) |
setBodyInnerHTML( |
"<style>" |
- "#scroller { overflow: scroll; height: 300px; width: 300px; background-color: rgb(0,128,0); }" |
- "#scrolled { height: 1000px; width: 250px; }" |
+ "#scroller { overflow: scroll; height: 200px; width: 200px; background: white local content-box; border: 10px solid rgba(0, 255, 0, 0.5); }" |
+ "#scrolled { height: 300px; }" |
"</style>" |
"<div id=\"scroller\"><div id=\"scrolled\"></div></div>"); |
document().view()->updateAllLifecyclePhases(); |
- ASSERT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled()); |
+ EXPECT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled()); |
Element* scroller = document().getElementById("scroller"); |
PaintLayer* paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer(); |
ASSERT_TRUE(paintLayer); |
- ASSERT_TRUE(paintLayer->needsCompositedScrolling()); |
+ EXPECT_TRUE(paintLayer->needsCompositedScrolling()); |
+ EXPECT_TRUE(paintLayer->graphicsLayerBacking()); |
+ ASSERT_TRUE(paintLayer->graphicsLayerBackingForScrolling()); |
+ EXPECT_TRUE(paintLayer->graphicsLayerBackingForScrolling()->contentsOpaque()); |
} |
TEST_F(PaintLayerScrollableAreaTest, TransparentLayersNotPromoted) |
@@ -31,17 +36,77 @@ TEST_F(PaintLayerScrollableAreaTest, TransparentLayersNotPromoted) |
setBodyInnerHTML( |
"<style>" |
- "#scroller { overflow: scroll; height: 300px; width: 300px; background-color: rgba(0,128,0,0.5); }" |
- "#scrolled { height: 1000px; width: 250px; }" |
+ "#scroller { overflow: scroll; height: 200px; width: 200px; background: rgba(0, 255, 0, 0.5) local content-box; border: 10px solid rgba(0, 255, 0, 0.5); }" |
+ "#scrolled { height: 300px; }" |
+ "</style>" |
+ "<div id=\"scroller\"><div id=\"scrolled\"></div></div>"); |
+ document().view()->updateAllLifecyclePhases(); |
+ |
+ EXPECT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled()); |
+ Element* scroller = document().getElementById("scroller"); |
+ PaintLayer* paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer(); |
+ ASSERT_TRUE(paintLayer); |
+ EXPECT_TRUE(!paintLayer->needsCompositedScrolling()); |
+ EXPECT_TRUE(!paintLayer->graphicsLayerBacking()); |
+ EXPECT_TRUE(!paintLayer->graphicsLayerBackingForScrolling()); |
+} |
+ |
+TEST_F(PaintLayerScrollableAreaTest, OpaqueLayersDepromotedOnStyleChange) |
+{ |
+ RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true); |
+ |
+ setBodyInnerHTML( |
+ "<style>" |
+ "#scroller { overflow: scroll; height: 200px; width: 200px; background: white local content-box; border: 10px solid rgba(0, 255, 0, 0.5); }" |
+ "#scrolled { height: 300px; }" |
+ "</style>" |
+ "<div id=\"scroller\"><div id=\"scrolled\"></div></div>"); |
+ document().view()->updateAllLifecyclePhases(); |
+ |
+ EXPECT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled()); |
+ Element* scroller = document().getElementById("scroller"); |
+ PaintLayer* paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer(); |
+ ASSERT_TRUE(paintLayer); |
+ EXPECT_TRUE(paintLayer->needsCompositedScrolling()); |
+ |
+ // Change the background to transparent |
+ scroller->setAttribute(HTMLNames::styleAttr, "background: rgba(255,255,255,0.5) local content-box;"); |
+ document().view()->updateAllLifecyclePhases(); |
+ paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer(); |
+ ASSERT_TRUE(paintLayer); |
+ EXPECT_TRUE(!paintLayer->needsCompositedScrolling()); |
+ EXPECT_TRUE(!paintLayer->graphicsLayerBacking()); |
+ EXPECT_TRUE(!paintLayer->graphicsLayerBackingForScrolling()); |
+} |
+ |
+TEST_F(PaintLayerScrollableAreaTest, OpaqueLayersPromotedOnStyleChange) |
+{ |
+ RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true); |
+ |
+ setBodyInnerHTML( |
+ "<style>" |
+ "#scroller { overflow: scroll; height: 200px; width: 200px; background: rgba(255,255,255,0.5) local content-box; border: 10px solid rgba(0, 255, 0, 0.5); }" |
+ "#scrolled { height: 300px; }" |
"</style>" |
"<div id=\"scroller\"><div id=\"scrolled\"></div></div>"); |
document().view()->updateAllLifecyclePhases(); |
- ASSERT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled()); |
+ EXPECT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled()); |
Element* scroller = document().getElementById("scroller"); |
PaintLayer* paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer(); |
ASSERT_TRUE(paintLayer); |
- ASSERT_TRUE(!paintLayer->needsCompositedScrolling()); |
+ EXPECT_TRUE(!paintLayer->needsCompositedScrolling()); |
+ |
+ // Change the background to transparent |
+ scroller->setAttribute(HTMLNames::styleAttr, "background: white local content-box;"); |
+ document().view()->updateAllLifecyclePhases(); |
+ paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer(); |
+ ASSERT_TRUE(paintLayer); |
+ EXPECT_TRUE(paintLayer->needsCompositedScrolling()); |
+ EXPECT_TRUE(paintLayer->graphicsLayerBacking()); |
+ ASSERT_TRUE(paintLayer->graphicsLayerBackingForScrolling()); |
+ EXPECT_TRUE(paintLayer->graphicsLayerBackingForScrolling()->contentsOpaque()); |
} |
+ |
} |