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

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

Issue 2522043002: Reland "Only promote opaque scrollers which are stacking contexts." (Closed)
Patch Set: Remove android svg-width-100p-as-background-expected.txt expectation. Created 4 years, 1 month 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
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 // the outline is drawn into the decoration layer which will not be covered 149 // the outline is drawn into the decoration layer which will not be covered
150 // up. 150 // up.
151 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller15")); 151 EXPECT_TRUE(canPaintBackgroundOntoScrollingContentsLayer("scroller15"));
152 152
153 // #scroller16 cannot paint background into scrolling contents layer because 153 // #scroller16 cannot paint background into scrolling contents layer because
154 // the scroller has a clip which would not be respected by the scrolling 154 // the scroller has a clip which would not be respected by the scrolling
155 // contents layer. 155 // contents layer.
156 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller16")); 156 EXPECT_FALSE(canPaintBackgroundOntoScrollingContentsLayer("scroller16"));
157 } 157 }
158 158
159 TEST_F(PaintLayerScrollableAreaTest, OpaqueLayersPromoted) { 159 TEST_F(PaintLayerScrollableAreaTest, OpaqueContainedLayersPromoted) {
160 RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true); 160 RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true);
161 161
162 setBodyInnerHTML( 162 setBodyInnerHTML(
163 "<style>" 163 "<style>"
164 "#scroller { overflow: scroll; height: 200px; width: 200px; background: " 164 "#scroller { overflow: scroll; height: 200px; width: 200px; "
165 "white local content-box; border: 10px solid rgba(0, 255, 0, 0.5); }" 165 "contain: paint; background: white local content-box; "
166 "border: 10px solid rgba(0, 255, 0, 0.5); }"
166 "#scrolled { height: 300px; }" 167 "#scrolled { height: 300px; }"
167 "</style>" 168 "</style>"
168 "<div id=\"scroller\"><div id=\"scrolled\"></div></div>"); 169 "<div id=\"scroller\"><div id=\"scrolled\"></div></div>");
169 document().view()->updateAllLifecyclePhases(); 170 document().view()->updateAllLifecyclePhases();
170 171
171 EXPECT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled()); 172 EXPECT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled());
172 Element* scroller = document().getElementById("scroller"); 173 Element* scroller = document().getElementById("scroller");
173 PaintLayer* paintLayer = 174 PaintLayer* paintLayer =
174 toLayoutBoxModelObject(scroller->layoutObject())->layer(); 175 toLayoutBoxModelObject(scroller->layoutObject())->layer();
175 ASSERT_TRUE(paintLayer); 176 ASSERT_TRUE(paintLayer);
176 EXPECT_TRUE(paintLayer->needsCompositedScrolling()); 177 EXPECT_TRUE(paintLayer->needsCompositedScrolling());
177 EXPECT_TRUE(paintLayer->graphicsLayerBacking()); 178 EXPECT_TRUE(paintLayer->graphicsLayerBacking());
178 ASSERT_TRUE(paintLayer->graphicsLayerBackingForScrolling()); 179 ASSERT_TRUE(paintLayer->graphicsLayerBackingForScrolling());
179 EXPECT_TRUE(paintLayer->graphicsLayerBackingForScrolling()->contentsOpaque()); 180 EXPECT_TRUE(paintLayer->graphicsLayerBackingForScrolling()->contentsOpaque());
180 } 181 }
181 182
183 // Tests that we don't promote scrolling content which would not be contained.
184 // Promoting the scroller would also require promoting the positioned div
185 // which would lose subpixel anti-aliasing due to its transparent background.
186 TEST_F(PaintLayerScrollableAreaTest, NonContainedLayersNotPromoted) {
187 RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true);
188
189 setBodyInnerHTML(
190 "<style>"
191 "#scroller { overflow: scroll; height: 200px; width: 200px; "
192 "background: white local content-box; "
193 "border: 10px solid rgba(0, 255, 0, 0.5); }"
194 "#scrolled { height: 300px; }"
195 "#positioned { position: relative; }"
196 "</style>"
197 "<div id=\"scroller\">"
198 " <div id=\"positioned\">Not contained by scroller.</div>"
199 " <div id=\"scrolled\"></div>"
200 "</div>");
201 document().view()->updateAllLifecyclePhases();
202
203 EXPECT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled());
204 Element* scroller = document().getElementById("scroller");
205 PaintLayer* paintLayer =
206 toLayoutBoxModelObject(scroller->layoutObject())->layer();
207 ASSERT_TRUE(paintLayer);
208 EXPECT_FALSE(paintLayer->needsCompositedScrolling());
209 EXPECT_FALSE(paintLayer->graphicsLayerBacking());
210 EXPECT_FALSE(paintLayer->graphicsLayerBackingForScrolling());
211 }
212
182 TEST_F(PaintLayerScrollableAreaTest, TransparentLayersNotPromoted) { 213 TEST_F(PaintLayerScrollableAreaTest, TransparentLayersNotPromoted) {
183 RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true); 214 RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true);
184 215
185 setBodyInnerHTML( 216 setBodyInnerHTML(
186 "<style>" 217 "<style>"
187 "#scroller { overflow: scroll; height: 200px; width: 200px; background: " 218 "#scroller { overflow: scroll; height: 200px; width: 200px; background: "
188 "rgba(0, 255, 0, 0.5) local content-box; border: 10px solid rgba(0, 255, " 219 "rgba(0, 255, 0, 0.5) local content-box; border: 10px solid rgba(0, 255, "
189 "0, 0.5); }" 220 "0, 0.5); contain: paint; }"
190 "#scrolled { height: 300px; }" 221 "#scrolled { height: 300px; }"
191 "</style>" 222 "</style>"
192 "<div id=\"scroller\"><div id=\"scrolled\"></div></div>"); 223 "<div id=\"scroller\"><div id=\"scrolled\"></div></div>");
193 document().view()->updateAllLifecyclePhases(); 224 document().view()->updateAllLifecyclePhases();
194 225
195 EXPECT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled()); 226 EXPECT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled());
196 Element* scroller = document().getElementById("scroller"); 227 Element* scroller = document().getElementById("scroller");
197 PaintLayer* paintLayer = 228 PaintLayer* paintLayer =
198 toLayoutBoxModelObject(scroller->layoutObject())->layer(); 229 toLayoutBoxModelObject(scroller->layoutObject())->layer();
199 ASSERT_TRUE(paintLayer); 230 ASSERT_TRUE(paintLayer);
200 EXPECT_FALSE(paintLayer->needsCompositedScrolling()); 231 EXPECT_FALSE(paintLayer->needsCompositedScrolling());
201 EXPECT_FALSE(paintLayer->graphicsLayerBacking()); 232 EXPECT_FALSE(paintLayer->graphicsLayerBacking());
202 EXPECT_FALSE(paintLayer->graphicsLayerBackingForScrolling()); 233 EXPECT_FALSE(paintLayer->graphicsLayerBackingForScrolling());
203 } 234 }
204 235
205 TEST_F(PaintLayerScrollableAreaTest, OpaqueLayersDepromotedOnStyleChange) { 236 TEST_F(PaintLayerScrollableAreaTest, OpaqueLayersDepromotedOnStyleChange) {
206 RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true); 237 RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true);
207 238
208 setBodyInnerHTML( 239 setBodyInnerHTML(
209 "<style>" 240 "<style>"
210 "#scroller { overflow: scroll; height: 200px; width: 200px; background: " 241 "#scroller { overflow: scroll; height: 200px; width: 200px; background: "
211 "white local content-box; }" 242 "white local content-box; contain: paint; }"
212 "#scrolled { height: 300px; }" 243 "#scrolled { height: 300px; }"
213 "</style>" 244 "</style>"
214 "<div id=\"scroller\"><div id=\"scrolled\"></div></div>"); 245 "<div id=\"scroller\"><div id=\"scrolled\"></div></div>");
215 document().view()->updateAllLifecyclePhases(); 246 document().view()->updateAllLifecyclePhases();
216 247
217 EXPECT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled()); 248 EXPECT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled());
218 Element* scroller = document().getElementById("scroller"); 249 Element* scroller = document().getElementById("scroller");
219 PaintLayer* paintLayer = 250 PaintLayer* paintLayer =
220 toLayoutBoxModelObject(scroller->layoutObject())->layer(); 251 toLayoutBoxModelObject(scroller->layoutObject())->layer();
221 ASSERT_TRUE(paintLayer); 252 ASSERT_TRUE(paintLayer);
(...skipping 10 matching lines...) Expand all
232 EXPECT_FALSE(paintLayer->graphicsLayerBacking()); 263 EXPECT_FALSE(paintLayer->graphicsLayerBacking());
233 EXPECT_FALSE(paintLayer->graphicsLayerBackingForScrolling()); 264 EXPECT_FALSE(paintLayer->graphicsLayerBackingForScrolling());
234 } 265 }
235 266
236 TEST_F(PaintLayerScrollableAreaTest, OpaqueLayersPromotedOnStyleChange) { 267 TEST_F(PaintLayerScrollableAreaTest, OpaqueLayersPromotedOnStyleChange) {
237 RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true); 268 RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true);
238 269
239 setBodyInnerHTML( 270 setBodyInnerHTML(
240 "<style>" 271 "<style>"
241 "#scroller { overflow: scroll; height: 200px; width: 200px; background: " 272 "#scroller { overflow: scroll; height: 200px; width: 200px; background: "
242 "rgba(255,255,255,0.5) local content-box; }" 273 "rgba(255,255,255,0.5) local content-box; contain: paint; }"
243 "#scrolled { height: 300px; }" 274 "#scrolled { height: 300px; }"
244 "</style>" 275 "</style>"
245 "<div id=\"scroller\"><div id=\"scrolled\"></div></div>"); 276 "<div id=\"scroller\"><div id=\"scrolled\"></div></div>");
246 document().view()->updateAllLifecyclePhases(); 277 document().view()->updateAllLifecyclePhases();
247 278
248 EXPECT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled()); 279 EXPECT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled());
249 Element* scroller = document().getElementById("scroller"); 280 Element* scroller = document().getElementById("scroller");
250 PaintLayer* paintLayer = 281 PaintLayer* paintLayer =
251 toLayoutBoxModelObject(scroller->layoutObject())->layer(); 282 toLayoutBoxModelObject(scroller->layoutObject())->layer();
252 ASSERT_TRUE(paintLayer); 283 ASSERT_TRUE(paintLayer);
(...skipping 13 matching lines...) Expand all
266 297
267 // Tests that a transform on the scroller or an ancestor will prevent promotion 298 // Tests that a transform on the scroller or an ancestor will prevent promotion
268 // TODO(flackr): Allow integer transforms as long as all of the ancestor 299 // TODO(flackr): Allow integer transforms as long as all of the ancestor
269 // transforms are also integer. 300 // transforms are also integer.
270 TEST_F(PaintLayerScrollableAreaTest, OnlyNonTransformedOpaqueLayersPromoted) { 301 TEST_F(PaintLayerScrollableAreaTest, OnlyNonTransformedOpaqueLayersPromoted) {
271 ScopedCompositeOpaqueScrollersForTest compositeOpaqueScrollers(true); 302 ScopedCompositeOpaqueScrollersForTest compositeOpaqueScrollers(true);
272 303
273 setBodyInnerHTML( 304 setBodyInnerHTML(
274 "<style>" 305 "<style>"
275 "#scroller { overflow: scroll; height: 200px; width: 200px; background: " 306 "#scroller { overflow: scroll; height: 200px; width: 200px; background: "
276 "white local content-box; }" 307 "white local content-box; contain: paint; }"
277 "#scrolled { height: 300px; }" 308 "#scrolled { height: 300px; }"
278 "</style>" 309 "</style>"
279 "<div id=\"parent\">" 310 "<div id=\"parent\">"
280 " <div id=\"scroller\"><div id=\"scrolled\"></div></div>" 311 " <div id=\"scroller\"><div id=\"scrolled\"></div></div>"
281 "</div>"); 312 "</div>");
282 document().view()->updateAllLifecyclePhases(); 313 document().view()->updateAllLifecyclePhases();
283 314
284 EXPECT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled()); 315 EXPECT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled());
285 Element* parent = document().getElementById("parent"); 316 Element* parent = document().getElementById("parent");
286 Element* scroller = document().getElementById("scroller"); 317 Element* scroller = document().getElementById("scroller");
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 } 351 }
321 352
322 // Test that opacity applied to the scroller or an ancestor will cause the 353 // Test that opacity applied to the scroller or an ancestor will cause the
323 // scrolling contents layer to not be promoted. 354 // scrolling contents layer to not be promoted.
324 TEST_F(PaintLayerScrollableAreaTest, OnlyOpaqueLayersPromoted) { 355 TEST_F(PaintLayerScrollableAreaTest, OnlyOpaqueLayersPromoted) {
325 ScopedCompositeOpaqueScrollersForTest compositeOpaqueScrollers(true); 356 ScopedCompositeOpaqueScrollersForTest compositeOpaqueScrollers(true);
326 357
327 setBodyInnerHTML( 358 setBodyInnerHTML(
328 "<style>" 359 "<style>"
329 "#scroller { overflow: scroll; height: 200px; width: 200px; background: " 360 "#scroller { overflow: scroll; height: 200px; width: 200px; background: "
330 "white local content-box; }" 361 "white local content-box; contain: paint; }"
331 "#scrolled { height: 300px; }" 362 "#scrolled { height: 300px; }"
332 "</style>" 363 "</style>"
333 "<div id=\"parent\">" 364 "<div id=\"parent\">"
334 " <div id=\"scroller\"><div id=\"scrolled\"></div></div>" 365 " <div id=\"scroller\"><div id=\"scrolled\"></div></div>"
335 "</div>"); 366 "</div>");
336 document().view()->updateAllLifecyclePhases(); 367 document().view()->updateAllLifecyclePhases();
337 368
338 EXPECT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled()); 369 EXPECT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled());
339 Element* parent = document().getElementById("parent"); 370 Element* parent = document().getElementById("parent");
340 Element* scroller = document().getElementById("scroller"); 371 Element* scroller = document().getElementById("scroller");
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 ASSERT_TRUE(blackLayer); 432 ASSERT_TRUE(blackLayer);
402 433
403 ASSERT_EQ(ScrollbarOverlayColorTheme::ScrollbarOverlayColorThemeDark, 434 ASSERT_EQ(ScrollbarOverlayColorTheme::ScrollbarOverlayColorThemeDark,
404 noneLayer->getScrollableArea()->getScrollbarOverlayColorTheme()); 435 noneLayer->getScrollableArea()->getScrollbarOverlayColorTheme());
405 ASSERT_EQ(ScrollbarOverlayColorTheme::ScrollbarOverlayColorThemeDark, 436 ASSERT_EQ(ScrollbarOverlayColorTheme::ScrollbarOverlayColorThemeDark,
406 whiteLayer->getScrollableArea()->getScrollbarOverlayColorTheme()); 437 whiteLayer->getScrollableArea()->getScrollbarOverlayColorTheme());
407 ASSERT_EQ(ScrollbarOverlayColorTheme::ScrollbarOverlayColorThemeLight, 438 ASSERT_EQ(ScrollbarOverlayColorTheme::ScrollbarOverlayColorThemeLight,
408 blackLayer->getScrollableArea()->getScrollbarOverlayColorTheme()); 439 blackLayer->getScrollableArea()->getScrollbarOverlayColorTheme());
409 } 440 }
410 } 441 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698