| 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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseFloat()); | 311 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseFloat()); |
| 312 | 312 |
| 313 // 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. |
| 314 toHTMLElement(floatDiv.node())->setAttribute(HTMLNames::styleAttr, styleWith
Float); | 314 toHTMLElement(floatDiv.node())->setAttribute(HTMLNames::styleAttr, styleWith
Float); |
| 315 updateLifecyclePhasesBeforePaint(); | 315 updateLifecyclePhasesBeforePaint(); |
| 316 EXPECT_TRUE(selfPaintingLayer.needsPaintPhaseFloat()); | 316 EXPECT_TRUE(selfPaintingLayer.needsPaintPhaseFloat()); |
| 317 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseFloat()); | 317 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseFloat()); |
| 318 paint(); | 318 paint(); |
| 319 } | 319 } |
| 320 | 320 |
| 321 TEST_P(PaintLayerPainterTest, PaintPhaseBlockBackground) |
| 322 { |
| 323 AtomicString styleWithoutBackground = "width: 50px; height: 50px"; |
| 324 AtomicString styleWithBackground = "background: blue; " + styleWithoutBackgr
ound; |
| 325 setBodyInnerHTML( |
| 326 "<div id='self-painting-layer' style='position: absolute'>" |
| 327 " <div id='non-self-painting-layer' style='overflow: hidden'>" |
| 328 " <div>" |
| 329 " <div id='background'></div>" |
| 330 " </div>" |
| 331 " </div>" |
| 332 "</div>"); |
| 333 LayoutObject& backgroundDiv = *document().getElementById("background")->layo
utObject(); |
| 334 toHTMLElement(backgroundDiv.node())->setAttribute(HTMLNames::styleAttr, styl
eWithoutBackground); |
| 335 document().view()->updateAllLifecyclePhases(); |
| 336 |
| 337 LayoutBlock& selfPaintingLayerObject = *toLayoutBlock(document().getElementB
yId("self-painting-layer")->layoutObject()); |
| 338 PaintLayer& selfPaintingLayer = *selfPaintingLayerObject.layer(); |
| 339 ASSERT_TRUE(selfPaintingLayer.isSelfPaintingLayer()); |
| 340 PaintLayer& nonSelfPaintingLayer = *toLayoutBoxModelObject(document().getEle
mentById("non-self-painting-layer")->layoutObject())->layer(); |
| 341 ASSERT_FALSE(nonSelfPaintingLayer.isSelfPaintingLayer()); |
| 342 ASSERT_TRUE(&nonSelfPaintingLayer == backgroundDiv.enclosingLayer()); |
| 343 |
| 344 EXPECT_FALSE(selfPaintingLayer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 345 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseDescendantBlockBackgrounds(
)); |
| 346 |
| 347 // Background on the self-painting-layer node itself doesn't affect PaintPha
seDescendantBlockBackgrounds. |
| 348 toHTMLElement(selfPaintingLayerObject.node())->setAttribute(HTMLNames::style
Attr, "position: absolute; background: green"); |
| 349 document().view()->updateAllLifecyclePhases(); |
| 350 EXPECT_FALSE(selfPaintingLayer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 351 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseDescendantBlockBackgrounds(
)); |
| 352 EXPECT_TRUE(displayItemListContains(rootPaintController().displayItemList(),
selfPaintingLayerObject, DisplayItem::BoxDecorationBackground)); |
| 353 |
| 354 // needsPaintPhaseDescendantBlockBackgrounds should be set when any descenda
nt on the same layer has Background. |
| 355 toHTMLElement(backgroundDiv.node())->setAttribute(HTMLNames::styleAttr, styl
eWithBackground); |
| 356 updateLifecyclePhasesBeforePaint(); |
| 357 EXPECT_TRUE(selfPaintingLayer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 358 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseDescendantBlockBackgrounds(
)); |
| 359 paint(); |
| 360 EXPECT_TRUE(displayItemListContains(rootPaintController().displayItemList(),
backgroundDiv, DisplayItem::BoxDecorationBackground)); |
| 361 } |
| 362 |
| 321 } // namespace blink | 363 } // namespace blink |
| OLD | NEW |