| OLD | NEW |
| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 "border-box;'><div class='spacer'></div></div>" | 54 "border-box;'><div class='spacer'></div></div>" |
| 55 "<div id='scroller14' class='scroller' style='background: white; border: " | 55 "<div id='scroller14' class='scroller' style='background: white; border: " |
| 56 "1px solid black; outline: 1px solid blue; outline-offset: -1px;'><div " | 56 "1px solid black; outline: 1px solid blue; outline-offset: -1px;'><div " |
| 57 "class='spacer'></div></div>" | 57 "class='spacer'></div></div>" |
| 58 "<div id='scroller15' class='scroller' style='background: white; border: " | 58 "<div id='scroller15' class='scroller' style='background: white; border: " |
| 59 "1px solid black; outline: 1px solid blue; outline-offset: -2px;'><div " | 59 "1px solid black; outline: 1px solid blue; outline-offset: -2px;'><div " |
| 60 "class='spacer'></div></div>" | 60 "class='spacer'></div></div>" |
| 61 "<div id='scroller16' class='scroller' style='background: white; clip: " | 61 "<div id='scroller16' class='scroller' style='background: white; clip: " |
| 62 "rect(0px,10px,10px,0px);'><div class='spacer'></div></div>"); | 62 "rect(0px,10px,10px,0px);'><div class='spacer'></div></div>"); |
| 63 | 63 |
| 64 // #scroller1 cannot paint background into scrolling contents layer because it
has a negative z-index child. | 64 // #scroller1 cannot paint background into scrolling contents layer because it |
| 65 // has a negative z-index child. |
| 65 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller1")); | 66 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller1")); |
| 66 | 67 |
| 67 // #scroller2 cannot paint background into scrolling contents layer because it
has a content-box clip without local attachment. | 68 // #scroller2 cannot paint background into scrolling contents layer because it |
| 69 // has a content-box clip without local attachment. |
| 68 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller2")); | 70 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller2")); |
| 69 | 71 |
| 70 // #scroller3 can paint background into scrolling contents layer. | 72 // #scroller3 can paint background into scrolling contents layer. |
| 71 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller3")); | 73 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller3")); |
| 72 | 74 |
| 73 // #scroller4 cannot paint background into scrolling contents layer because th
e background image is not locally attached. | 75 // #scroller4 cannot paint background into scrolling contents layer because |
| 76 // the background image is not locally attached. |
| 74 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller4")); | 77 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller4")); |
| 75 | 78 |
| 76 // #scroller5 can paint background into scrolling contents layer because both
the image and color are locally attached. | 79 // #scroller5 can paint background into scrolling contents layer because both |
| 80 // the image and color are locally attached. |
| 77 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller5")); | 81 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller5")); |
| 78 | 82 |
| 79 // #scroller6 can paint background into scrolling contents layer because the i
mage is locally attached and even though | 83 // #scroller6 can paint background into scrolling contents layer because the |
| 80 // the color is not, it is filled to the padding box so it will be drawn the s
ame as a locally attached background. | 84 // image is locally attached and even though the color is not, it is filled to |
| 85 // the padding box so it will be drawn the same as a locally attached |
| 86 // background. |
| 81 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller6")); | 87 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller6")); |
| 82 | 88 |
| 83 // #scroller7 cannot paint background into scrolling contents layer because th
e color is filled to the content | 89 // #scroller7 cannot paint background into scrolling contents layer because |
| 84 // box and we have padding so it is not equivalent to a locally attached backg
round. | 90 // the color is filled to the content box and we have padding so it is not |
| 91 // equivalent to a locally attached background. |
| 85 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller7")); | 92 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller7")); |
| 86 | 93 |
| 87 // #scroller8 can paint background into scrolling contents layer because its b
order-box is equivalent to its | 94 // #scroller8 can paint background into scrolling contents layer because its |
| 88 // padding box since it has no border. | 95 // border-box is equivalent to its padding box since it has no border. |
| 89 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller8")); | 96 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller8")); |
| 90 | 97 |
| 91 // #scroller9 can paint background into scrolling contents layer because its b
order is opaque so it completely | 98 // #scroller9 can paint background into scrolling contents layer because its |
| 92 // covers the background outside of the padding-box. | 99 // border is opaque so it completely covers the background outside of the |
| 100 // padding-box. |
| 93 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller9")); | 101 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller9")); |
| 94 | 102 |
| 95 // #scroller10 cannot paint background into scrolling contents layer because i
ts border is partially transparent | 103 // #scroller10 cannot paint background into scrolling contents layer because |
| 96 // so the background must be drawn to the border-box edges. | 104 // its border is partially transparent so the background must be drawn to the |
| 105 // border-box edges. |
| 97 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller10")); | 106 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller10")); |
| 98 | 107 |
| 99 // #scroller11 can paint background into scrolling contents layer because its
content-box is equivalent to its | 108 // #scroller11 can paint background into scrolling contents layer because its |
| 100 // padding box since it has no padding. | 109 // content-box is equivalent to its padding box since it has no padding. |
| 101 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller11")); | 110 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller11")); |
| 102 | 111 |
| 103 // #scroller12 cannot paint background into scrolling contents layer because i
t has padding so its content-box | 112 // #scroller12 cannot paint background into scrolling contents layer because |
| 104 // is not equivalent to its padding-box. | 113 // it has padding so its content-box is not equivalent to its padding-box. |
| 105 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller12")); | 114 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller12")); |
| 106 | 115 |
| 107 // #scroller13 cannot paint background into scrolling contents layer because i
t has a custom | 116 // #scroller13 cannot paint background into scrolling contents layer because |
| 108 // scrollbar which the background may need to draw under. | 117 // it has a custom scrollbar which the background may need to draw under. |
| 109 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller13")); | 118 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller13")); |
| 110 | 119 |
| 111 // #scroller14 can paint background into scrolling contents layer because the
outline is drawn outside the | 120 // #scroller14 can paint background into scrolling contents layer because the |
| 112 // padding box. | 121 // outline is drawn outside the padding box. |
| 113 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller14")); | 122 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller14")); |
| 114 | 123 |
| 115 // #scroller15 cannot paint background into scrolling contents layer because t
he outline is drawn inside | 124 // #scroller15 cannot paint background into scrolling contents layer because |
| 116 // the padding box. | 125 // the outline is drawn inside the padding box. |
| 117 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller15")); | 126 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller15")); |
| 118 | 127 |
| 119 // #scroller16 cannot paint background into scrolling contents layer because t
he scroller has a clip which | 128 // #scroller16 cannot paint background into scrolling contents layer because |
| 120 // would not be respected by the scrolling contents layer. | 129 // the scroller has a clip which would not be respected by the scrolling |
| 130 // contents layer. |
| 121 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller16")); | 131 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller16")); |
| 122 } | 132 } |
| 123 | 133 |
| 124 TEST_F(PaintLayerScrollableAreaTest, OpaqueLayersPromoted) { | 134 TEST_F(PaintLayerScrollableAreaTest, OpaqueLayersPromoted) { |
| 125 RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true); | 135 RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true); |
| 126 | 136 |
| 127 setBodyInnerHTML( | 137 setBodyInnerHTML( |
| 128 "<style>" | 138 "<style>" |
| 129 "#scroller { overflow: scroll; height: 200px; width: 200px; background: " | 139 "#scroller { overflow: scroll; height: 200px; width: 200px; background: " |
| 130 "white local content-box; border: 10px solid rgba(0, 255, 0, 0.5); }" | 140 "white local content-box; border: 10px solid rgba(0, 255, 0, 0.5); }" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 "background: white local content-box;"); | 232 "background: white local content-box;"); |
| 223 document().view()->updateAllLifecyclePhases(); | 233 document().view()->updateAllLifecyclePhases(); |
| 224 paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer(); | 234 paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer(); |
| 225 ASSERT_TRUE(paintLayer); | 235 ASSERT_TRUE(paintLayer); |
| 226 EXPECT_TRUE(paintLayer->needsCompositedScrolling()); | 236 EXPECT_TRUE(paintLayer->needsCompositedScrolling()); |
| 227 EXPECT_TRUE(paintLayer->graphicsLayerBacking()); | 237 EXPECT_TRUE(paintLayer->graphicsLayerBacking()); |
| 228 ASSERT_TRUE(paintLayer->graphicsLayerBackingForScrolling()); | 238 ASSERT_TRUE(paintLayer->graphicsLayerBackingForScrolling()); |
| 229 EXPECT_TRUE(paintLayer->graphicsLayerBackingForScrolling()->contentsOpaque()); | 239 EXPECT_TRUE(paintLayer->graphicsLayerBackingForScrolling()->contentsOpaque()); |
| 230 } | 240 } |
| 231 } | 241 } |
| OLD | NEW |