OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/layout/compositing/CompositedLayerMapping.h" | 5 #include "core/layout/compositing/CompositedLayerMapping.h" |
6 #include "core/paint/PaintControllerPaintTest.h" | 6 #include "core/paint/PaintControllerPaintTest.h" |
7 #include "platform/graphics/GraphicsContext.h" | 7 #include "platform/graphics/GraphicsContext.h" |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 | 10 |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 277 |
278 // needsPaintPhaseDescendantOutlines should be set when any descendant on th
e same layer has outline. | 278 // needsPaintPhaseDescendantOutlines should be set when any descendant on th
e same layer has outline. |
279 toHTMLElement(outlineDiv.node())->setAttribute(HTMLNames::styleAttr, styleWi
thOutline); | 279 toHTMLElement(outlineDiv.node())->setAttribute(HTMLNames::styleAttr, styleWi
thOutline); |
280 updateLifecyclePhasesBeforePaint(); | 280 updateLifecyclePhasesBeforePaint(); |
281 EXPECT_TRUE(selfPaintingLayer.needsPaintPhaseDescendantOutlines()); | 281 EXPECT_TRUE(selfPaintingLayer.needsPaintPhaseDescendantOutlines()); |
282 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseDescendantOutlines()); | 282 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseDescendantOutlines()); |
283 paint(); | 283 paint(); |
284 EXPECT_TRUE(displayItemListContains(rootPaintController().displayItemList(),
outlineDiv, DisplayItem::paintPhaseToDrawingType(PaintPhaseSelfOutlineOnly))); | 284 EXPECT_TRUE(displayItemListContains(rootPaintController().displayItemList(),
outlineDiv, DisplayItem::paintPhaseToDrawingType(PaintPhaseSelfOutlineOnly))); |
285 } | 285 } |
286 | 286 |
287 // TODO(wangxianzhu): This test weirdly caused memory leaks of a chromium conten
t_browsertests test. | |
288 // Figure out the issue and enable this test. | |
289 TEST_P(PaintLayerPainterTest, PaintPhaseFloat) | 287 TEST_P(PaintLayerPainterTest, PaintPhaseFloat) |
290 { | 288 { |
291 AtomicString styleWithoutFloat = "width: 50px; height: 50px; background-colo
r: green"; | 289 AtomicString styleWithoutFloat = "width: 50px; height: 50px; background-colo
r: green"; |
292 AtomicString styleWithFloat = "float: left; " + styleWithoutFloat; | 290 AtomicString styleWithFloat = "float: left; " + styleWithoutFloat; |
293 setBodyInnerHTML( | 291 setBodyInnerHTML( |
294 "<div id='self-painting-layer' style='position: absolute'>" | 292 "<div id='self-painting-layer' style='position: absolute'>" |
295 " <div id='non-self-painting-layer' style='overflow: hidden'>" | 293 " <div id='non-self-painting-layer' style='overflow: hidden'>" |
296 " <div>" | 294 " <div>" |
297 " <div id='float' style='width: 10px; height: 10px; background-colo
r: blue'></div>" | 295 " <div id='float' style='width: 10px; height: 10px; background-colo
r: blue'></div>" |
298 " </div>" | 296 " </div>" |
(...skipping 15 matching lines...) Expand all Loading... |
314 | 312 |
315 // needsPaintPhaseFloat should be set when any descendant on the same layer
has float. | 313 // needsPaintPhaseFloat should be set when any descendant on the same layer
has float. |
316 toHTMLElement(floatDiv.node())->setAttribute(HTMLNames::styleAttr, styleWith
Float); | 314 toHTMLElement(floatDiv.node())->setAttribute(HTMLNames::styleAttr, styleWith
Float); |
317 updateLifecyclePhasesBeforePaint(); | 315 updateLifecyclePhasesBeforePaint(); |
318 EXPECT_TRUE(selfPaintingLayer.needsPaintPhaseFloat()); | 316 EXPECT_TRUE(selfPaintingLayer.needsPaintPhaseFloat()); |
319 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseFloat()); | 317 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseFloat()); |
320 paint(); | 318 paint(); |
321 EXPECT_TRUE(displayItemListContains(rootPaintController().displayItemList(),
floatDiv, DisplayItem::BoxDecorationBackground)); | 319 EXPECT_TRUE(displayItemListContains(rootPaintController().displayItemList(),
floatDiv, DisplayItem::BoxDecorationBackground)); |
322 } | 320 } |
323 | 321 |
| 322 TEST_P(PaintLayerPainterTest, PaintPhaseBlockBackground) |
| 323 { |
| 324 AtomicString styleWithoutBackground = "width: 50px; height: 50px"; |
| 325 AtomicString styleWithBackground = "background: blue; " + styleWithoutBackgr
ound; |
| 326 setBodyInnerHTML( |
| 327 "<div id='self-painting-layer' style='position: absolute'>" |
| 328 " <div id='non-self-painting-layer' style='overflow: hidden'>" |
| 329 " <div>" |
| 330 " <div id='background'></div>" |
| 331 " </div>" |
| 332 " </div>" |
| 333 "</div>"); |
| 334 LayoutObject& backgroundDiv = *document().getElementById("background")->layo
utObject(); |
| 335 toHTMLElement(backgroundDiv.node())->setAttribute(HTMLNames::styleAttr, styl
eWithoutBackground); |
| 336 document().view()->updateAllLifecyclePhases(); |
| 337 |
| 338 LayoutBlock& selfPaintingLayerObject = *toLayoutBlock(document().getElementB
yId("self-painting-layer")->layoutObject()); |
| 339 PaintLayer& selfPaintingLayer = *selfPaintingLayerObject.layer(); |
| 340 ASSERT_TRUE(selfPaintingLayer.isSelfPaintingLayer()); |
| 341 PaintLayer& nonSelfPaintingLayer = *toLayoutBoxModelObject(document().getEle
mentById("non-self-painting-layer")->layoutObject())->layer(); |
| 342 ASSERT_FALSE(nonSelfPaintingLayer.isSelfPaintingLayer()); |
| 343 ASSERT_TRUE(&nonSelfPaintingLayer == backgroundDiv.enclosingLayer()); |
| 344 |
| 345 EXPECT_FALSE(selfPaintingLayer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 346 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseDescendantBlockBackgrounds(
)); |
| 347 |
| 348 // Background on the self-painting-layer node itself doesn't affect PaintPha
seDescendantBlockBackgrounds. |
| 349 toHTMLElement(selfPaintingLayerObject.node())->setAttribute(HTMLNames::style
Attr, "position: absolute; background: green"); |
| 350 document().view()->updateAllLifecyclePhases(); |
| 351 EXPECT_FALSE(selfPaintingLayer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 352 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseDescendantBlockBackgrounds(
)); |
| 353 EXPECT_TRUE(displayItemListContains(rootPaintController().displayItemList(),
selfPaintingLayerObject, DisplayItem::BoxDecorationBackground)); |
| 354 |
| 355 // needsPaintPhaseDescendantBlockBackgrounds should be set when any descenda
nt on the same layer has Background. |
| 356 toHTMLElement(backgroundDiv.node())->setAttribute(HTMLNames::styleAttr, styl
eWithBackground); |
| 357 updateLifecyclePhasesBeforePaint(); |
| 358 EXPECT_TRUE(selfPaintingLayer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 359 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseDescendantBlockBackgrounds(
)); |
| 360 paint(); |
| 361 EXPECT_TRUE(displayItemListContains(rootPaintController().displayItemList(),
backgroundDiv, DisplayItem::BoxDecorationBackground)); |
| 362 } |
| 363 |
324 } // namespace blink | 364 } // namespace blink |
OLD | NEW |