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

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

Issue 2434443005: Only automatically promote scrollers which are untransformed and opaque. (Closed)
Patch Set: 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
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..7b28248fdb9d4ea6057c0cf4d38549998710d650 100644
--- a/third_party/WebKit/Source/core/paint/PaintLayerScrollableAreaTest.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintLayerScrollableAreaTest.cpp
@@ -238,4 +238,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) {
+ RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true);
chrishtr 2016/10/19 22:29:45 Use the auto-resetter pattern.
flackr 2016/10/19 23:01:54 Done.
+
+ 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) {
+ RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(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());
+}
}
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698