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

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

Issue 2259493004: Fix Compositing of Opaque Scrolling Layers and Add Tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert unnecessary change. Created 4 years, 4 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/PaintLayerScrollableAreaTest.cpp
diff --git a/third_party/WebKit/Source/core/paint/PaintLayerScrollableAreaTest.cpp b/third_party/WebKit/Source/core/paint/PaintLayerScrollableAreaTest.cpp
index f11b78585bf5bbf4aa33df3d6d844357746ec8e4..5eee12feee745df12848beb4dd4d41c97a8b1736 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,8 +14,8 @@ 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();
@@ -23,6 +25,9 @@ TEST_F(PaintLayerScrollableAreaTest, OpaqueLayersPromoted)
PaintLayer* paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer();
ASSERT_TRUE(paintLayer);
ASSERT_TRUE(paintLayer->needsCompositedScrolling());
+ ASSERT_TRUE(paintLayer->graphicsLayerBacking());
+ ASSERT_TRUE(paintLayer->graphicsLayerBackingForScrolling());
+ ASSERT_TRUE(paintLayer->graphicsLayerBackingForScrolling()->contentsOpaque());
flackr 2016/08/26 18:24:23 nit: This should probably be EXPECT_TRUE
Stephen Chennney 2016/08/26 18:42:08 Shows how often I've written unit tests. I'll fix
}
TEST_F(PaintLayerScrollableAreaTest, TransparentLayersNotPromoted)
@@ -31,8 +36,57 @@ 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();
+
+ ASSERT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled());
+ Element* scroller = document().getElementById("scroller");
+ PaintLayer* paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer();
+ ASSERT_TRUE(paintLayer);
+ ASSERT_TRUE(!paintLayer->needsCompositedScrolling());
flackr 2016/08/26 18:24:23 this and following: EXPECT_FALSE
+ ASSERT_TRUE(!paintLayer->graphicsLayerBacking());
+ ASSERT_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();
+
+ ASSERT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled());
+ Element* scroller = document().getElementById("scroller");
+ PaintLayer* paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer();
+ ASSERT_TRUE(paintLayer);
+ ASSERT_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);
+ ASSERT_TRUE(!paintLayer->needsCompositedScrolling());
+ ASSERT_TRUE(!paintLayer->graphicsLayerBacking());
+ ASSERT_TRUE(!paintLayer->graphicsLayerBackingForScrolling());
flackr 2016/08/26 18:24:23 I feel like we should have layouttests for these c
Stephen Chennney 2016/08/26 18:42:08 That's a good point. I'll create such things.
+}
+
+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();
@@ -42,6 +96,17 @@ TEST_F(PaintLayerScrollableAreaTest, TransparentLayersNotPromoted)
PaintLayer* paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer();
ASSERT_TRUE(paintLayer);
ASSERT_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);
+ ASSERT_TRUE(paintLayer->needsCompositedScrolling());
+ ASSERT_TRUE(paintLayer->graphicsLayerBacking());
+ ASSERT_TRUE(paintLayer->graphicsLayerBackingForScrolling());
+ ASSERT_TRUE(paintLayer->graphicsLayerBackingForScrolling()->contentsOpaque());
}
+
}

Powered by Google App Engine
This is Rietveld 408576698