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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/paint/PaintLayerScrollableAreaTest.h" 5 #include "core/paint/PaintLayerScrollableAreaTest.h"
6 6
7 #include "platform/graphics/GraphicsLayer.h" 7 #include "platform/graphics/GraphicsLayer.h"
8 8
9 namespace blink { 9 namespace blink {
10 10
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 scroller->setAttribute(HTMLNames::styleAttr, 231 scroller->setAttribute(HTMLNames::styleAttr,
232 "background: white local content-box;"); 232 "background: white local content-box;");
233 document().view()->updateAllLifecyclePhases(); 233 document().view()->updateAllLifecyclePhases();
234 paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer(); 234 paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer();
235 ASSERT_TRUE(paintLayer); 235 ASSERT_TRUE(paintLayer);
236 EXPECT_TRUE(paintLayer->needsCompositedScrolling()); 236 EXPECT_TRUE(paintLayer->needsCompositedScrolling());
237 EXPECT_TRUE(paintLayer->graphicsLayerBacking()); 237 EXPECT_TRUE(paintLayer->graphicsLayerBacking());
238 ASSERT_TRUE(paintLayer->graphicsLayerBackingForScrolling()); 238 ASSERT_TRUE(paintLayer->graphicsLayerBackingForScrolling());
239 EXPECT_TRUE(paintLayer->graphicsLayerBackingForScrolling()->contentsOpaque()); 239 EXPECT_TRUE(paintLayer->graphicsLayerBackingForScrolling()->contentsOpaque());
240 } 240 }
241
242 // Tests that a transform on the scroller or an ancestor will prevent promotion
243 // TODO(flackr): Allow integer transforms as long as all of the ancestor
244 // transforms are also integer.
245 TEST_F(PaintLayerScrollableAreaTest, OnlyNonTransformedOpaqueLayersPromoted) {
246 RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true);
chrishtr 2016/10/19 22:29:45 Use the auto-resetter pattern.
flackr 2016/10/19 23:01:54 Done.
247
248 setBodyInnerHTML(
249 "<style>"
250 "#scroller { overflow: scroll; height: 200px; width: 200px; background: "
251 "white local content-box; }"
252 "#scrolled { height: 300px; }"
253 "</style>"
254 "<div id=\"parent\">"
255 " <div id=\"scroller\"><div id=\"scrolled\"></div></div>"
256 "</div>");
257 document().view()->updateAllLifecyclePhases();
258
259 EXPECT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled());
260 Element* parent = document().getElementById("parent");
261 Element* scroller = document().getElementById("scroller");
262 PaintLayer* paintLayer =
263 toLayoutBoxModelObject(scroller->layoutObject())->layer();
264 ASSERT_TRUE(paintLayer);
265 EXPECT_TRUE(paintLayer->needsCompositedScrolling());
266 EXPECT_TRUE(paintLayer->graphicsLayerBacking());
267 ASSERT_TRUE(paintLayer->graphicsLayerBackingForScrolling());
268 EXPECT_TRUE(paintLayer->graphicsLayerBackingForScrolling()->contentsOpaque());
269
270 // Change the parent to have a transform.
271 parent->setAttribute(HTMLNames::styleAttr, "transform: translate(1px, 0);");
272 document().view()->updateAllLifecyclePhases();
273 paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer();
274 ASSERT_TRUE(paintLayer);
275 EXPECT_FALSE(paintLayer->needsCompositedScrolling());
276 EXPECT_FALSE(paintLayer->graphicsLayerBacking());
277
278 // Change the parent to have no transform again.
279 parent->removeAttribute(HTMLNames::styleAttr);
280 document().view()->updateAllLifecyclePhases();
281 paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer();
282 ASSERT_TRUE(paintLayer);
283 EXPECT_TRUE(paintLayer->needsCompositedScrolling());
284 EXPECT_TRUE(paintLayer->graphicsLayerBacking());
285 ASSERT_TRUE(paintLayer->graphicsLayerBackingForScrolling());
286 EXPECT_TRUE(paintLayer->graphicsLayerBackingForScrolling()->contentsOpaque());
287
288 // Apply a transform to the scroller directly.
289 scroller->setAttribute(HTMLNames::styleAttr, "transform: translate(1px, 0);");
290 document().view()->updateAllLifecyclePhases();
291 paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer();
292 ASSERT_TRUE(paintLayer);
293 EXPECT_FALSE(paintLayer->needsCompositedScrolling());
294 EXPECT_FALSE(paintLayer->graphicsLayerBacking());
241 } 295 }
296
297 // Test that opacity applied to the scroller or an ancestor will cause the
298 // scrolling contents layer to not be promoted.
299 TEST_F(PaintLayerScrollableAreaTest, OnlyOpaqueLayersPromoted) {
300 RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true);
301
302 setBodyInnerHTML(
303 "<style>"
304 "#scroller { overflow: scroll; height: 200px; width: 200px; background: "
305 "white local content-box; }"
306 "#scrolled { height: 300px; }"
307 "</style>"
308 "<div id=\"parent\">"
309 " <div id=\"scroller\"><div id=\"scrolled\"></div></div>"
310 "</div>");
311 document().view()->updateAllLifecyclePhases();
312
313 EXPECT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled());
314 Element* parent = document().getElementById("parent");
315 Element* scroller = document().getElementById("scroller");
316 PaintLayer* paintLayer =
317 toLayoutBoxModelObject(scroller->layoutObject())->layer();
318 ASSERT_TRUE(paintLayer);
319 EXPECT_TRUE(paintLayer->needsCompositedScrolling());
320 EXPECT_TRUE(paintLayer->graphicsLayerBacking());
321 ASSERT_TRUE(paintLayer->graphicsLayerBackingForScrolling());
322 EXPECT_TRUE(paintLayer->graphicsLayerBackingForScrolling()->contentsOpaque());
323
324 // Change the parent to be partially translucent.
325 parent->setAttribute(HTMLNames::styleAttr, "opacity: 0.5;");
326 document().view()->updateAllLifecyclePhases();
327 paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer();
328 ASSERT_TRUE(paintLayer);
329 EXPECT_FALSE(paintLayer->needsCompositedScrolling());
330 EXPECT_FALSE(paintLayer->graphicsLayerBacking());
331
332 // Change the parent to be opaque again.
333 parent->setAttribute(HTMLNames::styleAttr, "opacity: 1;");
334 document().view()->updateAllLifecyclePhases();
335 paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer();
336 ASSERT_TRUE(paintLayer);
337 EXPECT_TRUE(paintLayer->needsCompositedScrolling());
338 EXPECT_TRUE(paintLayer->graphicsLayerBacking());
339 ASSERT_TRUE(paintLayer->graphicsLayerBackingForScrolling());
340 EXPECT_TRUE(paintLayer->graphicsLayerBackingForScrolling()->contentsOpaque());
341
342 // Make the scroller translucent.
343 scroller->setAttribute(HTMLNames::styleAttr, "opacity: 0.5");
344 document().view()->updateAllLifecyclePhases();
345 paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer();
346 ASSERT_TRUE(paintLayer);
347 EXPECT_FALSE(paintLayer->needsCompositedScrolling());
348 EXPECT_FALSE(paintLayer->graphicsLayerBacking());
349 }
350 }
OLDNEW
« 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