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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayerScrollableAreaTest.cpp

Issue 2346883003: Only paint the background onto the scrolling contents layer if we have a scrolling contents layer. (Closed)
Patch Set: Remove obsolete border-radius test. 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" 7 #include "platform/graphics/GraphicsLayer.h"
8 8
9 namespace blink { 9 namespace blink {
10 10
11 TEST_F(PaintLayerScrollableAreaTest, ShouldPaintBackgroundOntoScrollingContentsL ayer) 11 TEST_F(PaintLayerScrollableAreaTest, CanPaintBackgroundOntoScrollingContentsLaye r)
12 { 12 {
13 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); 13 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true);
14 setBodyInnerHTML( 14 setBodyInnerHTML(
15 "<style>" 15 "<style>"
16 ".scroller { overflow: scroll; will-change: transform; width: 300px; hei ght: 300px;} .spacer { height: 1000px; }" 16 ".scroller { overflow: scroll; will-change: transform; width: 300px; hei ght: 300px;} .spacer { height: 1000px; }"
17 "#scroller13::-webkit-scrollbar { width: 13px; height: 13px;}" 17 "#scroller13::-webkit-scrollbar { width: 13px; height: 13px;}"
18 "</style>" 18 "</style>"
19 "<div id='scroller1' class='scroller' style='background: white local;'>" 19 "<div id='scroller1' class='scroller' style='background: white local;'>"
20 " <div id='negative-composited-child' style='background-color: red; w idth: 1px; height: 1px; position: absolute; backface-visibility: hidden; z-index : -1'></div>" 20 " <div id='negative-composited-child' style='background-color: red; w idth: 1px; height: 1px; position: absolute; backface-visibility: hidden; z-index : -1'></div>"
21 " <div class='spacer'></div>" 21 " <div class='spacer'></div>"
22 "</div>" 22 "</div>"
23 "<div id='scroller2' class='scroller' style='background: white content-b ox; padding: 10px;'><div class='spacer'></div></div>" 23 "<div id='scroller2' class='scroller' style='background: white content-b ox; padding: 10px;'><div class='spacer'></div></div>"
24 "<div id='scroller3' class='scroller' style='background: white local con tent-box; padding: 10px;'><div class='spacer'></div></div>" 24 "<div id='scroller3' class='scroller' style='background: white local con tent-box; padding: 10px;'><div class='spacer'></div></div>"
25 "<div id='scroller4' class='scroller' style='background: url(data:image/ png;base64,iVBORw0KGgoAAAANSUhEUg), white local;'><div class='spacer'></div></di v>" 25 "<div id='scroller4' class='scroller' style='background: url(data:image/ png;base64,iVBORw0KGgoAAAANSUhEUg), white local;'><div class='spacer'></div></di v>"
26 "<div id='scroller5' class='scroller' style='background: url(data:image/ png;base64,iVBORw0KGgoAAAANSUhEUg) local, white local;'><div class='spacer'></di v></div>" 26 "<div id='scroller5' class='scroller' style='background: url(data:image/ png;base64,iVBORw0KGgoAAAANSUhEUg) local, white local;'><div class='spacer'></di v></div>"
27 "<div id='scroller6' class='scroller' style='background: url(data:image/ png;base64,iVBORw0KGgoAAAANSUhEUg) local, white padding-box; padding: 10px;'><di v class='spacer'></div></div>" 27 "<div id='scroller6' class='scroller' style='background: url(data:image/ png;base64,iVBORw0KGgoAAAANSUhEUg) local, white padding-box; padding: 10px;'><di v class='spacer'></div></div>"
28 "<div id='scroller7' class='scroller' style='background: url(data:image/ png;base64,iVBORw0KGgoAAAANSUhEUg) local, white content-box; padding: 10px;'><di v class='spacer'></div></div>" 28 "<div id='scroller7' class='scroller' style='background: url(data:image/ png;base64,iVBORw0KGgoAAAANSUhEUg) local, white content-box; padding: 10px;'><di v class='spacer'></div></div>"
29 "<div id='scroller8' class='scroller' style='background: white border-bo x;'><div class='spacer'></div></div>" 29 "<div id='scroller8' class='scroller' style='background: white border-bo x;'><div class='spacer'></div></div>"
30 "<div id='scroller9' class='scroller' style='background: white border-bo x; border: 10px solid black;'><div class='spacer'></div></div>" 30 "<div id='scroller9' class='scroller' style='background: white border-bo x; border: 10px solid black;'><div class='spacer'></div></div>"
31 "<div id='scroller10' class='scroller' style='background: white border-b ox; border: 10px solid rgba(0, 0, 0, 0.5);'><div class='spacer'></div></div>" 31 "<div id='scroller10' class='scroller' style='background: white border-b ox; border: 10px solid rgba(0, 0, 0, 0.5);'><div class='spacer'></div></div>"
32 "<div id='scroller11' class='scroller' style='background: white content- box;'><div class='spacer'></div></div>" 32 "<div id='scroller11' class='scroller' style='background: white content- box;'><div class='spacer'></div></div>"
33 "<div id='scroller12' class='scroller' style='background: white content- box; padding: 10px;'><div class='spacer'></div></div>" 33 "<div id='scroller12' class='scroller' style='background: white content- box; padding: 10px;'><div class='spacer'></div></div>"
34 "<div id='scroller13' class='scroller' style='background: white border-b ox;'><div class='spacer'></div></div>" 34 "<div id='scroller13' class='scroller' style='background: white border-b ox;'><div class='spacer'></div></div>"
35 "<div id='scroller14' class='scroller' style='background: white; border: 1px solid black; outline: 1px solid blue; outline-offset: -1px;'><div class='sp acer'></div></div>" 35 "<div id='scroller14' class='scroller' style='background: white; border: 1px solid black; outline: 1px solid blue; outline-offset: -1px;'><div class='sp acer'></div></div>"
36 "<div id='scroller15' class='scroller' style='background: white; border: 1px solid black; outline: 1px solid blue; outline-offset: -2px;'><div class='sp acer'></div></div>" 36 "<div id='scroller15' class='scroller' style='background: white; border: 1px solid black; outline: 1px solid blue; outline-offset: -2px;'><div class='sp acer'></div></div>"
37 "<div id='scroller16' class='scroller' style='background: white; border 1px solid black; border-radius: 2px;'><div class='spacer'></div></div>" 37 "<div id='scroller16' class='scroller' style='background: white; clip: r ect(0px,10px,10px,0px);'><div class='spacer'></div></div>"
38 "<div id='scroller17' class='scroller' style='background: white; clip: r ect(0px,10px,10px,0px);'><div class='spacer'></div></div>"
39 ); 38 );
40 39
41 // #scroller1 cannot paint background into scrolling contents layer because it has a negative z-index child. 40 // #scroller1 cannot paint background into scrolling contents layer because it has a negative z-index child.
42 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller1")); 41 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller1"));
43 42
44 // #scroller2 cannot paint background into scrolling contents layer because it has a content-box clip without local attachment. 43 // #scroller2 cannot paint background into scrolling contents layer because it has a content-box clip without local attachment.
45 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller2")); 44 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller2"));
46 45
47 // #scroller3 can paint background into scrolling contents layer. 46 // #scroller3 can paint background into scrolling contents layer.
48 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller3")); 47 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller3"));
49 48
50 // #scroller4 cannot paint background into scrolling contents layer because the background image is not locally attached. 49 // #scroller4 cannot paint background into scrolling contents layer because the background image is not locally attached.
51 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller4")); 50 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller4"));
52 51
53 // #scroller5 can paint background into scrolling contents layer because bot h the image and color are locally attached. 52 // #scroller5 can paint background into scrolling contents layer because bot h the image and color are locally attached.
54 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller5")); 53 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller5"));
55 54
56 // #scroller6 can paint background into scrolling contents layer because the image is locally attached and even though 55 // #scroller6 can paint background into scrolling contents layer because the image is locally attached and even though
57 // the color is not, it is filled to the padding box so it will be drawn the same as a locally attached background. 56 // the color is not, it is filled to the padding box so it will be drawn the same as a locally attached background.
58 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller6")); 57 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller6"));
59 58
60 // #scroller7 cannot paint background into scrolling contents layer because the color is filled to the content 59 // #scroller7 cannot paint background into scrolling contents layer because the color is filled to the content
61 // box and we have padding so it is not equivalent to a locally attached bac kground. 60 // box and we have padding so it is not equivalent to a locally attached bac kground.
62 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller7")); 61 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller7"));
63 62
64 // #scroller8 can paint background into scrolling contents layer because its border-box is equivalent to its 63 // #scroller8 can paint background into scrolling contents layer because its border-box is equivalent to its
65 // padding box since it has no border. 64 // padding box since it has no border.
66 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller8")); 65 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller8"));
67 66
68 // #scroller9 can paint background into scrolling contents layer because its border is opaque so it completely 67 // #scroller9 can paint background into scrolling contents layer because its border is opaque so it completely
69 // covers the background outside of the padding-box. 68 // covers the background outside of the padding-box.
70 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller9")); 69 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller9"));
71 70
72 // #scroller10 cannot paint background into scrolling contents layer because its border is partially transparent 71 // #scroller10 cannot paint background into scrolling contents layer because its border is partially transparent
73 // so the background must be drawn to the border-box edges. 72 // so the background must be drawn to the border-box edges.
74 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller10")); 73 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller10"));
75 74
76 // #scroller11 can paint background into scrolling contents layer because it s content-box is equivalent to its 75 // #scroller11 can paint background into scrolling contents layer because it s content-box is equivalent to its
77 // padding box since it has no padding. 76 // padding box since it has no padding.
78 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller11")); 77 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller11"));
79 78
80 // #scroller12 cannot paint background into scrolling contents layer because it has padding so its content-box 79 // #scroller12 cannot paint background into scrolling contents layer because it has padding so its content-box
81 // is not equivalent to its padding-box. 80 // is not equivalent to its padding-box.
82 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller12")); 81 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller12"));
83 82
84 // #scroller13 cannot paint background into scrolling contents layer because it has a custom 83 // #scroller13 cannot paint background into scrolling contents layer because it has a custom
85 // scrollbar which the background may need to draw under. 84 // scrollbar which the background may need to draw under.
86 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller13")); 85 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller13"));
87 86
88 // #scroller14 can paint background into scrolling contents layer because th e outline is drawn outside the 87 // #scroller14 can paint background into scrolling contents layer because th e outline is drawn outside the
89 // padding box. 88 // padding box.
90 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller14")); 89 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller14"));
91 90
92 // #scroller15 cannot paint background into scrolling contents layer because the outline is drawn inside 91 // #scroller15 cannot paint background into scrolling contents layer because the outline is drawn inside
93 // the padding box. 92 // the padding box.
94 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller15")); 93 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller15"));
95 94
96 // #scroller16 cannot paint background into scrolling contents layer because it has a 95 // #scroller16 cannot paint background into scrolling contents layer because the scroller has a clip which
97 // border radius.
98 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller16"));
99
100 // #scroller17 cannot paint background into scrolling contents layer because the scroller has a clip which
101 // would not be respected by the scrolling contents layer. 96 // would not be respected by the scrolling contents layer.
102 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller17")); 97 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller16"));
103 } 98 }
104 99
105 TEST_F(PaintLayerScrollableAreaTest, OpaqueLayersPromoted) 100 TEST_F(PaintLayerScrollableAreaTest, OpaqueLayersPromoted)
106 { 101 {
107 RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true); 102 RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true);
108 103
109 setBodyInnerHTML( 104 setBodyInnerHTML(
110 "<style>" 105 "<style>"
111 "#scroller { overflow: scroll; height: 200px; width: 200px; background: white local content-box; border: 10px solid rgba(0, 255, 0, 0.5); }" 106 "#scroller { overflow: scroll; height: 200px; width: 200px; background: white local content-box; border: 10px solid rgba(0, 255, 0, 0.5); }"
112 "#scrolled { height: 300px; }" 107 "#scrolled { height: 300px; }"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer(); 192 paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer();
198 ASSERT_TRUE(paintLayer); 193 ASSERT_TRUE(paintLayer);
199 EXPECT_TRUE(paintLayer->needsCompositedScrolling()); 194 EXPECT_TRUE(paintLayer->needsCompositedScrolling());
200 EXPECT_TRUE(paintLayer->graphicsLayerBacking()); 195 EXPECT_TRUE(paintLayer->graphicsLayerBacking());
201 ASSERT_TRUE(paintLayer->graphicsLayerBackingForScrolling()); 196 ASSERT_TRUE(paintLayer->graphicsLayerBackingForScrolling());
202 EXPECT_TRUE(paintLayer->graphicsLayerBackingForScrolling()->contentsOpaque() ); 197 EXPECT_TRUE(paintLayer->graphicsLayerBackingForScrolling()->contentsOpaque() );
203 } 198 }
204 199
205 200
206 } 201 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698