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

Side by Side 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, 3 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
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"
8
7 namespace blink { 9 namespace blink {
8 10
9 TEST_F(PaintLayerScrollableAreaTest, OpaqueLayersPromoted) 11 TEST_F(PaintLayerScrollableAreaTest, OpaqueLayersPromoted)
10 { 12 {
11 RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true); 13 RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true);
12 14
13 setBodyInnerHTML( 15 setBodyInnerHTML(
14 "<style>" 16 "<style>"
15 "#scroller { overflow: scroll; height: 300px; width: 300px; background-c olor: rgb(0,128,0); }" 17 "#scroller { overflow: scroll; height: 200px; width: 200px; background: white local content-box; border: 10px solid rgba(0, 255, 0, 0.5); }"
16 "#scrolled { height: 1000px; width: 250px; }" 18 "#scrolled { height: 300px; }"
17 "</style>" 19 "</style>"
18 "<div id=\"scroller\"><div id=\"scrolled\"></div></div>"); 20 "<div id=\"scroller\"><div id=\"scrolled\"></div></div>");
19 document().view()->updateAllLifecyclePhases(); 21 document().view()->updateAllLifecyclePhases();
20 22
21 ASSERT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled()); 23 ASSERT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled());
22 Element* scroller = document().getElementById("scroller"); 24 Element* scroller = document().getElementById("scroller");
23 PaintLayer* paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->l ayer(); 25 PaintLayer* paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->l ayer();
24 ASSERT_TRUE(paintLayer); 26 ASSERT_TRUE(paintLayer);
25 ASSERT_TRUE(paintLayer->needsCompositedScrolling()); 27 ASSERT_TRUE(paintLayer->needsCompositedScrolling());
28 ASSERT_TRUE(paintLayer->graphicsLayerBacking());
29 ASSERT_TRUE(paintLayer->graphicsLayerBackingForScrolling());
30 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
26 } 31 }
27 32
28 TEST_F(PaintLayerScrollableAreaTest, TransparentLayersNotPromoted) 33 TEST_F(PaintLayerScrollableAreaTest, TransparentLayersNotPromoted)
29 { 34 {
30 RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true); 35 RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true);
31 36
32 setBodyInnerHTML( 37 setBodyInnerHTML(
33 "<style>" 38 "<style>"
34 "#scroller { overflow: scroll; height: 300px; width: 300px; background-c olor: rgba(0,128,0,0.5); }" 39 "#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); }"
35 "#scrolled { height: 1000px; width: 250px; }" 40 "#scrolled { height: 300px; }"
36 "</style>" 41 "</style>"
37 "<div id=\"scroller\"><div id=\"scrolled\"></div></div>"); 42 "<div id=\"scroller\"><div id=\"scrolled\"></div></div>");
38 document().view()->updateAllLifecyclePhases(); 43 document().view()->updateAllLifecyclePhases();
44
45 ASSERT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled());
46 Element* scroller = document().getElementById("scroller");
47 PaintLayer* paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->l ayer();
48 ASSERT_TRUE(paintLayer);
49 ASSERT_TRUE(!paintLayer->needsCompositedScrolling());
flackr 2016/08/26 18:24:23 this and following: EXPECT_FALSE
50 ASSERT_TRUE(!paintLayer->graphicsLayerBacking());
51 ASSERT_TRUE(!paintLayer->graphicsLayerBackingForScrolling());
52 }
53
54 TEST_F(PaintLayerScrollableAreaTest, OpaqueLayersDepromotedOnStyleChange)
55 {
56 RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true);
57
58 setBodyInnerHTML(
59 "<style>"
60 "#scroller { overflow: scroll; height: 200px; width: 200px; background: white local content-box; border: 10px solid rgba(0, 255, 0, 0.5); }"
61 "#scrolled { height: 300px; }"
62 "</style>"
63 "<div id=\"scroller\"><div id=\"scrolled\"></div></div>");
64 document().view()->updateAllLifecyclePhases();
65
66 ASSERT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled());
67 Element* scroller = document().getElementById("scroller");
68 PaintLayer* paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->l ayer();
69 ASSERT_TRUE(paintLayer);
70 ASSERT_TRUE(paintLayer->needsCompositedScrolling());
71
72 // Change the background to transparent
73 scroller->setAttribute(HTMLNames::styleAttr, "background: rgba(255,255,255,0 .5) local content-box;");
74 document().view()->updateAllLifecyclePhases();
75 paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer();
76 ASSERT_TRUE(paintLayer);
77 ASSERT_TRUE(!paintLayer->needsCompositedScrolling());
78 ASSERT_TRUE(!paintLayer->graphicsLayerBacking());
79 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.
80 }
81
82 TEST_F(PaintLayerScrollableAreaTest, OpaqueLayersPromotedOnStyleChange)
83 {
84 RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true);
85
86 setBodyInnerHTML(
87 "<style>"
88 "#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) ; }"
89 "#scrolled { height: 300px; }"
90 "</style>"
91 "<div id=\"scroller\"><div id=\"scrolled\"></div></div>");
92 document().view()->updateAllLifecyclePhases();
39 93
40 ASSERT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled()); 94 ASSERT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled());
41 Element* scroller = document().getElementById("scroller"); 95 Element* scroller = document().getElementById("scroller");
42 PaintLayer* paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->l ayer(); 96 PaintLayer* paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->l ayer();
43 ASSERT_TRUE(paintLayer); 97 ASSERT_TRUE(paintLayer);
44 ASSERT_TRUE(!paintLayer->needsCompositedScrolling()); 98 ASSERT_TRUE(!paintLayer->needsCompositedScrolling());
99
100 // Change the background to transparent
101 scroller->setAttribute(HTMLNames::styleAttr, "background: white local conten t-box;");
102 document().view()->updateAllLifecyclePhases();
103 paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer();
104 ASSERT_TRUE(paintLayer);
105 ASSERT_TRUE(paintLayer->needsCompositedScrolling());
106 ASSERT_TRUE(paintLayer->graphicsLayerBacking());
107 ASSERT_TRUE(paintLayer->graphicsLayerBackingForScrolling());
108 ASSERT_TRUE(paintLayer->graphicsLayerBackingForScrolling()->contentsOpaque() );
45 } 109 }
46 110
111
47 } 112 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698