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

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

Issue 2302743004: Reland Paint solid color backgrounds which are equivalent to locally attached into scrolling conten… (Closed)
Patch Set: Remove 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" 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, ShouldPaintBackgroundOntoScrollingContentsL ayer)
12 { 12 {
13 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); 13 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true);
14 setBodyInnerHTML( 14 setBodyInnerHTML(
15 "<style>.scroller { overflow: scroll; will-change: transform; width: 300 px; height: 300px;} .spacer { height: 1000px; }</style>" 15 "<style>"
16 ".scroller { overflow: scroll; will-change: transform; width: 300px; hei ght: 300px;} .spacer { height: 1000px; }"
17 "#scroller13::-webkit-scrollbar { width: 13px; height: 13px;}"
18 "</style>"
16 "<div id='scroller1' class='scroller' style='background: white local;'>" 19 "<div id='scroller1' class='scroller' style='background: white local;'>"
17 " <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>"
18 " <div class='spacer'></div>" 21 " <div class='spacer'></div>"
19 "</div>" 22 "</div>"
20 "<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>"
21 "<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>"
22 "<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>"
23 "<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>"
24 "<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>"
25 "<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>"
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>"
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>"
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>"
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>"
26 ); 37 );
27 38
28 // First scroller cannot paint background into scrolling contents layer beca use it has a negative z-index child. 39 // #scroller1 cannot paint background into scrolling contents layer because it has a negative z-index child.
29 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller1")); 40 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller1"));
30 41
31 // Second scroller cannot paint background into scrolling contents layer bec ause it has a content-box clip without local attachment. 42 // #scroller2 cannot paint background into scrolling contents layer because it has a content-box clip without local attachment.
32 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller2")); 43 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller2"));
33 44
34 // Third scroller can paint background into scrolling contents layer. 45 // #scroller3 can paint background into scrolling contents layer.
35 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller3")); 46 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller3"));
36 47
37 // Fourth scroller cannot paint background into scrolling contents layer bec ause the background image is not locally attached. 48 // #scroller4 cannot paint background into scrolling contents layer because the background image is not locally attached.
38 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller4")); 49 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller4"));
39 50
40 // Fifth scroller can paint background into scrolling contents layer because both the image and color are locally attached. 51 // #scroller5 can paint background into scrolling contents layer because bot h the image and color are locally attached.
41 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller5")); 52 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller5"));
42 53
43 // Sixth scroller can paint background into scrolling contents layer because the image is locally attached and even though 54 // #scroller6 can paint background into scrolling contents layer because the image is locally attached and even though
44 // the color is not, it is filled to the padding box so it will be drawn the same as a locally attached background. 55 // the color is not, it is filled to the padding box so it will be drawn the same as a locally attached background.
45 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller6")); 56 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller6"));
46 57
47 // Seventh scroller cannot paint background into scrolling contents layer be cause the color is filled to the content 58 // #scroller7 cannot paint background into scrolling contents layer because the color is filled to the content
48 // box and we have padding so it is not equivalent to a locally attached bac kground. 59 // box and we have padding so it is not equivalent to a locally attached bac kground.
49 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller7")); 60 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller7"));
61
62 // #scroller8 can paint background into scrolling contents layer because its border-box is equivalent to its
63 // padding box since it has no border.
64 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller8"));
65
66 // #scroller9 can paint background into scrolling contents layer because its border is opaque so it completely
67 // covers the background outside of the padding-box.
68 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller9"));
69
70 // #scroller10 cannot paint background into scrolling contents layer because its border is partially transparent
71 // so the background must be drawn to the border-box edges.
72 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller10"));
73
74 // #scroller11 can paint background into scrolling contents layer because it s content-box is equivalent to its
75 // padding box since it has no padding.
76 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller11"));
77
78 // #scroller12 cannot paint background into scrolling contents layer because it has padding so its content-box
79 // is not equivalent to its padding-box.
80 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller12"));
81
82 // #scroller13 cannot paint background into scrolling contents layer because it has a custom
83 // scrollbar which the background may need to draw under.
84 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller13"));
85
86 // #scroller14 can paint background into scrolling contents layer because th e outline is drawn outside the
87 // padding box.
88 EXPECT_TRUE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller14"));
89
90 // #scroller15 cannot paint background into scrolling contents layer because the outline is drawn inside
91 // the padding box.
92 EXPECT_FALSE(shouldPaintBackgroundOntoScrollingContentsLayer("scroller15"));
50 } 93 }
51 94
52 TEST_F(PaintLayerScrollableAreaTest, OpaqueLayersPromoted) 95 TEST_F(PaintLayerScrollableAreaTest, OpaqueLayersPromoted)
53 { 96 {
54 RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true); 97 RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true);
55 98
56 setBodyInnerHTML( 99 setBodyInnerHTML(
57 "<style>" 100 "<style>"
58 "#scroller { overflow: scroll; height: 200px; width: 200px; background: white local content-box; border: 10px solid rgba(0, 255, 0, 0.5); }" 101 "#scroller { overflow: scroll; height: 200px; width: 200px; background: white local content-box; border: 10px solid rgba(0, 255, 0, 0.5); }"
59 "#scrolled { height: 300px; }" 102 "#scrolled { height: 300px; }"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer(); 187 paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer();
145 ASSERT_TRUE(paintLayer); 188 ASSERT_TRUE(paintLayer);
146 EXPECT_TRUE(paintLayer->needsCompositedScrolling()); 189 EXPECT_TRUE(paintLayer->needsCompositedScrolling());
147 EXPECT_TRUE(paintLayer->graphicsLayerBacking()); 190 EXPECT_TRUE(paintLayer->graphicsLayerBacking());
148 ASSERT_TRUE(paintLayer->graphicsLayerBackingForScrolling()); 191 ASSERT_TRUE(paintLayer->graphicsLayerBackingForScrolling());
149 EXPECT_TRUE(paintLayer->graphicsLayerBackingForScrolling()->contentsOpaque() ); 192 EXPECT_TRUE(paintLayer->graphicsLayerBackingForScrolling()->contentsOpaque() );
150 } 193 }
151 194
152 195
153 } 196 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayer.cpp ('k') | third_party/WebKit/Source/core/style/ComputedStyle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698