Chromium Code Reviews| 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/PaintLayerScrollableArea.h" | 5 #include "core/paint/PaintLayerScrollableArea.h" |
| 6 | 6 |
| 7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
| 8 #include "core/layout/LayoutBoxModelObject.h" | 8 #include "core/layout/LayoutBoxModelObject.h" |
| 9 #include "core/layout/LayoutTestHelper.h" | 9 #include "core/layout/LayoutTestHelper.h" |
| 10 #include "core/paint/PaintLayer.h" | 10 #include "core/paint/PaintLayer.h" |
| 11 #include "platform/graphics/GraphicsLayer.h" | 11 #include "platform/graphics/GraphicsLayer.h" |
| 12 #include "platform/scroll/ScrollTypes.h" | 12 #include "platform/scroll/ScrollTypes.h" |
| 13 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" | 13 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 class PaintLayerScrollableAreaTest : public RenderingTest { | 17 class PaintLayerScrollableAreaTest : public RenderingTest { |
| 18 public: | 18 public: |
| 19 PaintLayerScrollableAreaTest() | 19 PaintLayerScrollableAreaTest() |
| 20 : RenderingTest(SingleChildFrameLoaderClient::create()) {} | 20 : RenderingTest(SingleChildFrameLoaderClient::create()) {} |
| 21 | 21 |
| 22 bool canPaintBackgroundOntoScrollingContentsLayer(const char* elementId) { | 22 BackgroundPaintLocation backgroundPaintLocation(const char* elementId) { |
|
chrishtr
2016/11/17 20:55:39
Is one of the tests below exercising solid-color b
flackr
2016/11/17 23:38:00
Yes, scroller10 and scroller13 test solid color ba
| |
| 23 PaintLayer* paintLayer = | 23 PaintLayer* paintLayer = |
| 24 toLayoutBoxModelObject(getLayoutObjectByElementId(elementId))->layer(); | 24 toLayoutBoxModelObject(getLayoutObjectByElementId(elementId))->layer(); |
| 25 return paintLayer->canPaintBackgroundOntoScrollingContentsLayer(); | 25 return paintLayer->backgroundPaintLocation(); |
| 26 } | 26 } |
| 27 | 27 |
| 28 private: | 28 private: |
| 29 void SetUp() override { | 29 void SetUp() override { |
| 30 RenderingTest::SetUp(); | 30 RenderingTest::SetUp(); |
| 31 enableCompositing(); | 31 enableCompositing(); |
| 32 } | 32 } |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 TEST_F(PaintLayerScrollableAreaTest, | 35 TEST_F(PaintLayerScrollableAreaTest, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 "1px solid black; outline: 1px solid blue; outline-offset: -1px;'><div " | 80 "1px solid black; outline: 1px solid blue; outline-offset: -1px;'><div " |
| 81 "class='spacer'></div></div>" | 81 "class='spacer'></div></div>" |
| 82 "<div id='scroller15' class='scroller' style='background: white; border: " | 82 "<div id='scroller15' class='scroller' style='background: white; border: " |
| 83 "1px solid black; outline: 1px solid blue; outline-offset: -2px;'><div " | 83 "1px solid black; outline: 1px solid blue; outline-offset: -2px;'><div " |
| 84 "class='spacer'></div></div>" | 84 "class='spacer'></div></div>" |
| 85 "<div id='scroller16' class='scroller' style='background: white; clip: " | 85 "<div id='scroller16' class='scroller' style='background: white; clip: " |
| 86 "rect(0px,10px,10px,0px);'><div class='spacer'></div></div>"); | 86 "rect(0px,10px,10px,0px);'><div class='spacer'></div></div>"); |
| 87 | 87 |
| 88 // #scroller1 cannot paint background into scrolling contents layer because it | 88 // #scroller1 cannot paint background into scrolling contents layer because it |
| 89 // has a negative z-index child. | 89 // has a negative z-index child. |
| 90 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller1")); | 90 EXPECT_EQ(BackgroundPaintInGraphicsLayer, |
| 91 backgroundPaintLocation("scroller1")); | |
| 91 | 92 |
| 92 // #scroller2 cannot paint background into scrolling contents layer because it | 93 // #scroller2 cannot paint background into scrolling contents layer because it |
| 93 // has a content-box clip without local attachment. | 94 // has a content-box clip without local attachment. |
| 94 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller2")); | 95 EXPECT_EQ(BackgroundPaintInGraphicsLayer, |
| 96 backgroundPaintLocation("scroller2")); | |
| 95 | 97 |
| 96 // #scroller3 can paint background into scrolling contents layer. | 98 // #scroller3 can paint background into scrolling contents layer. |
| 97 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller3")); | 99 EXPECT_EQ(BackgroundPaintInScrollingContents, |
| 100 backgroundPaintLocation("scroller3")); | |
| 98 | 101 |
| 99 // #scroller4 cannot paint background into scrolling contents layer because | 102 // #scroller4 cannot paint background into scrolling contents layer because |
| 100 // the background image is not locally attached. | 103 // the background image is not locally attached. |
| 101 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller4")); | 104 EXPECT_EQ(BackgroundPaintInGraphicsLayer, |
| 105 backgroundPaintLocation("scroller4")); | |
| 102 | 106 |
| 103 // #scroller5 can paint background into scrolling contents layer because both | 107 // #scroller5 can paint background into scrolling contents layer because both |
| 104 // the image and color are locally attached. | 108 // the image and color are locally attached. |
| 105 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller5")); | 109 EXPECT_EQ(BackgroundPaintInScrollingContents, |
| 110 backgroundPaintLocation("scroller5")); | |
| 106 | 111 |
| 107 // #scroller6 can paint background into scrolling contents layer because the | 112 // #scroller6 can paint background into scrolling contents layer because the |
| 108 // image is locally attached and even though the color is not, it is filled to | 113 // image is locally attached and even though the color is not, it is filled to |
| 109 // the padding box so it will be drawn the same as a locally attached | 114 // the padding box so it will be drawn the same as a locally attached |
| 110 // background. | 115 // background. |
| 111 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller6")); | 116 EXPECT_EQ(BackgroundPaintInScrollingContents, |
| 117 backgroundPaintLocation("scroller6")); | |
| 112 | 118 |
| 113 // #scroller7 cannot paint background into scrolling contents layer because | 119 // #scroller7 cannot paint background into scrolling contents layer because |
| 114 // the color is filled to the content box and we have padding so it is not | 120 // the color is filled to the content box and we have padding so it is not |
| 115 // equivalent to a locally attached background. | 121 // equivalent to a locally attached background. |
| 116 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller7")); | 122 EXPECT_EQ(BackgroundPaintInGraphicsLayer, |
| 123 backgroundPaintLocation("scroller7")); | |
| 117 | 124 |
| 118 // #scroller8 can paint background into scrolling contents layer because its | 125 // #scroller8 can paint background into scrolling contents layer because its |
| 119 // border-box is equivalent to its padding box since it has no border. | 126 // border-box is equivalent to its padding box since it has no border. |
| 120 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller8")); | 127 EXPECT_EQ(BackgroundPaintInScrollingContents, |
| 128 backgroundPaintLocation("scroller8")); | |
| 121 | 129 |
| 122 // #scroller9 can paint background into scrolling contents layer because its | 130 // #scroller9 can paint background into scrolling contents layer because its |
| 123 // border is opaque so it completely covers the background outside of the | 131 // border is opaque so it completely covers the background outside of the |
| 124 // padding-box. | 132 // padding-box. |
| 125 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller9")); | 133 EXPECT_EQ(BackgroundPaintInScrollingContents, |
| 134 backgroundPaintLocation("scroller9")); | |
| 126 | 135 |
| 127 // #scroller10 cannot paint background into scrolling contents layer because | 136 // #scroller10 paints the background into both layers because its border is |
| 128 // its border is partially transparent so the background must be drawn to the | 137 // partially transparent so the background must be drawn to the |
| 129 // border-box edges. | 138 // border-box edges. |
| 130 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller10")); | 139 EXPECT_EQ(BackgroundPaintInGraphicsLayer | BackgroundPaintInScrollingContents, |
| 140 backgroundPaintLocation("scroller10")); | |
| 131 | 141 |
| 132 // #scroller11 can paint background into scrolling contents layer because its | 142 // #scroller11 can paint background into scrolling contents layer because its |
| 133 // content-box is equivalent to its padding box since it has no padding. | 143 // content-box is equivalent to its padding box since it has no padding. |
| 134 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller11")); | 144 EXPECT_EQ(BackgroundPaintInScrollingContents, |
| 145 backgroundPaintLocation("scroller11")); | |
| 135 | 146 |
| 136 // #scroller12 cannot paint background into scrolling contents layer because | 147 // #scroller12 cannot paint background into scrolling contents layer because |
| 137 // it has padding so its content-box is not equivalent to its padding-box. | 148 // it has padding so its content-box is not equivalent to its padding-box. |
| 138 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller12")); | 149 EXPECT_EQ(BackgroundPaintInGraphicsLayer, |
| 150 backgroundPaintLocation("scroller12")); | |
| 139 | 151 |
| 140 // #scroller13 cannot paint background into scrolling contents layer because | 152 // #scroller13 paints the background into both layers because it has a custom |
| 141 // it has a custom scrollbar which the background may need to draw under. | 153 // scrollbar which the background may need to draw under. |
| 142 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller13")); | 154 EXPECT_EQ(BackgroundPaintInGraphicsLayer | BackgroundPaintInScrollingContents, |
| 155 backgroundPaintLocation("scroller13")); | |
| 143 | 156 |
| 144 // #scroller14 can paint background into scrolling contents layer because the | 157 // #scroller14 can paint background into scrolling contents layer because the |
| 145 // outline is drawn outside the padding box. | 158 // outline is drawn outside the padding box. |
| 146 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller14")); | 159 EXPECT_EQ(BackgroundPaintInScrollingContents, |
| 160 backgroundPaintLocation("scroller14")); | |
| 147 | 161 |
| 148 // #scroller15 cannot paint background into scrolling contents layer because | 162 // #scroller15 cannot paint background into scrolling contents layer because |
| 149 // the outline is drawn inside the padding box. | 163 // the outline is drawn inside the padding box. |
| 150 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller15")); | 164 EXPECT_EQ(BackgroundPaintInGraphicsLayer, |
| 165 backgroundPaintLocation("scroller15")); | |
| 151 | 166 |
| 152 // #scroller16 cannot paint background into scrolling contents layer because | 167 // #scroller16 cannot paint background into scrolling contents layer because |
| 153 // the scroller has a clip which would not be respected by the scrolling | 168 // the scroller has a clip which would not be respected by the scrolling |
| 154 // contents layer. | 169 // contents layer. |
| 155 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller16")); | 170 EXPECT_EQ(BackgroundPaintInGraphicsLayer, |
| 171 backgroundPaintLocation("scroller16")); | |
| 156 } | 172 } |
| 157 | 173 |
| 158 TEST_F(PaintLayerScrollableAreaTest, OpaqueLayersPromoted) { | 174 TEST_F(PaintLayerScrollableAreaTest, OpaqueLayersPromoted) { |
| 159 RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true); | 175 RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true); |
| 160 | 176 |
| 161 setBodyInnerHTML( | 177 setBodyInnerHTML( |
| 162 "<style>" | 178 "<style>" |
| 163 "#scroller { overflow: scroll; height: 200px; width: 200px; background: " | 179 "#scroller { overflow: scroll; height: 200px; width: 200px; background: " |
| 164 "white local content-box; border: 10px solid rgba(0, 255, 0, 0.5); }" | 180 "white local content-box; border: 10px solid rgba(0, 255, 0, 0.5); }" |
| 165 "#scrolled { height: 300px; }" | 181 "#scrolled { height: 300px; }" |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 400 ASSERT_TRUE(blackLayer); | 416 ASSERT_TRUE(blackLayer); |
| 401 | 417 |
| 402 ASSERT_EQ(ScrollbarOverlayColorTheme::ScrollbarOverlayColorThemeDark, | 418 ASSERT_EQ(ScrollbarOverlayColorTheme::ScrollbarOverlayColorThemeDark, |
| 403 noneLayer->getScrollableArea()->getScrollbarOverlayColorTheme()); | 419 noneLayer->getScrollableArea()->getScrollbarOverlayColorTheme()); |
| 404 ASSERT_EQ(ScrollbarOverlayColorTheme::ScrollbarOverlayColorThemeDark, | 420 ASSERT_EQ(ScrollbarOverlayColorTheme::ScrollbarOverlayColorThemeDark, |
| 405 whiteLayer->getScrollableArea()->getScrollbarOverlayColorTheme()); | 421 whiteLayer->getScrollableArea()->getScrollbarOverlayColorTheme()); |
| 406 ASSERT_EQ(ScrollbarOverlayColorTheme::ScrollbarOverlayColorThemeLight, | 422 ASSERT_EQ(ScrollbarOverlayColorTheme::ScrollbarOverlayColorThemeLight, |
| 407 blackLayer->getScrollableArea()->getScrollbarOverlayColorTheme()); | 423 blackLayer->getScrollableArea()->getScrollbarOverlayColorTheme()); |
| 408 } | 424 } |
| 409 } | 425 } |
| OLD | NEW |