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

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

Issue 2434443005: Only automatically promote scrollers which are untransformed and opaque. (Closed)
Patch Set: Force compositing to test scrolling contents background painting Created 4 years, 2 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 91ff02538bda68c7db4f954e7139b0a17cd2e738..b9fe02182f478a7614f78809e94ead253a199668 100644
--- a/third_party/WebKit/Source/core/paint/PaintLayerScrollableAreaTest.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintLayerScrollableAreaTest.cpp
@@ -5,6 +5,7 @@
#include "core/paint/PaintLayerScrollableAreaTest.h"
#include "platform/graphics/GraphicsLayer.h"
+#include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
namespace blink {
@@ -238,4 +239,113 @@ TEST_F(PaintLayerScrollableAreaTest, OpaqueLayersPromotedOnStyleChange) {
ASSERT_TRUE(paintLayer->graphicsLayerBackingForScrolling());
EXPECT_TRUE(paintLayer->graphicsLayerBackingForScrolling()->contentsOpaque());
}
+
+// Tests that a transform on the scroller or an ancestor will prevent promotion
+// TODO(flackr): Allow integer transforms as long as all of the ancestor
+// transforms are also integer.
+TEST_F(PaintLayerScrollableAreaTest, OnlyNonTransformedOpaqueLayersPromoted) {
+ ScopedCompositeOpaqueScrollersForTest compositeOpaqueScrollers(true);
+
+ setBodyInnerHTML(
+ "<style>"
+ "#scroller { overflow: scroll; height: 200px; width: 200px; background: "
+ "white local content-box; }"
+ "#scrolled { height: 300px; }"
+ "</style>"
+ "<div id=\"parent\">"
+ " <div id=\"scroller\"><div id=\"scrolled\"></div></div>"
+ "</div>");
+ document().view()->updateAllLifecyclePhases();
+
+ EXPECT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled());
+ Element* parent = document().getElementById("parent");
+ Element* scroller = document().getElementById("scroller");
+ PaintLayer* 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());
+
+ // Change the parent to have a transform.
+ parent->setAttribute(HTMLNames::styleAttr, "transform: translate(1px, 0);");
+ document().view()->updateAllLifecyclePhases();
+ paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer();
+ ASSERT_TRUE(paintLayer);
+ EXPECT_FALSE(paintLayer->needsCompositedScrolling());
+ EXPECT_FALSE(paintLayer->graphicsLayerBacking());
+
+ // Change the parent to have no transform again.
+ parent->removeAttribute(HTMLNames::styleAttr);
+ 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());
+
+ // Apply a transform to the scroller directly.
+ scroller->setAttribute(HTMLNames::styleAttr, "transform: translate(1px, 0);");
+ document().view()->updateAllLifecyclePhases();
+ paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer();
+ ASSERT_TRUE(paintLayer);
+ EXPECT_FALSE(paintLayer->needsCompositedScrolling());
+ EXPECT_FALSE(paintLayer->graphicsLayerBacking());
+}
+
+// Test that opacity applied to the scroller or an ancestor will cause the
+// scrolling contents layer to not be promoted.
+TEST_F(PaintLayerScrollableAreaTest, OnlyOpaqueLayersPromoted) {
+ ScopedCompositeOpaqueScrollersForTest compositeOpaqueScrollers(true);
+
+ setBodyInnerHTML(
+ "<style>"
+ "#scroller { overflow: scroll; height: 200px; width: 200px; background: "
+ "white local content-box; }"
+ "#scrolled { height: 300px; }"
+ "</style>"
+ "<div id=\"parent\">"
+ " <div id=\"scroller\"><div id=\"scrolled\"></div></div>"
+ "</div>");
+ document().view()->updateAllLifecyclePhases();
+
+ EXPECT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled());
+ Element* parent = document().getElementById("parent");
+ Element* scroller = document().getElementById("scroller");
+ PaintLayer* 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());
+
+ // Change the parent to be partially translucent.
+ parent->setAttribute(HTMLNames::styleAttr, "opacity: 0.5;");
+ document().view()->updateAllLifecyclePhases();
+ paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer();
+ ASSERT_TRUE(paintLayer);
+ EXPECT_FALSE(paintLayer->needsCompositedScrolling());
+ EXPECT_FALSE(paintLayer->graphicsLayerBacking());
+
+ // Change the parent to be opaque again.
+ parent->setAttribute(HTMLNames::styleAttr, "opacity: 1;");
+ 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());
+
+ // Make the scroller translucent.
+ scroller->setAttribute(HTMLNames::styleAttr, "opacity: 0.5");
+ document().view()->updateAllLifecyclePhases();
+ paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer();
+ ASSERT_TRUE(paintLayer);
+ EXPECT_FALSE(paintLayer->needsCompositedScrolling());
+ EXPECT_FALSE(paintLayer->graphicsLayerBacking());
+}
}

Powered by Google App Engine
This is Rietveld 408576698