| 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/LayoutBlock.h" |
| 6 #include "core/layout/LayoutInline.h" |
| 5 #include "core/layout/compositing/CompositedLayerMapping.h" | 7 #include "core/layout/compositing/CompositedLayerMapping.h" |
| 6 #include "core/paint/PaintControllerPaintTest.h" | 8 #include "core/paint/PaintControllerPaintTest.h" |
| 7 #include "platform/graphics/GraphicsContext.h" | 9 #include "platform/graphics/GraphicsContext.h" |
| 8 | 10 |
| 9 namespace blink { | 11 namespace blink { |
| 10 | 12 |
| 11 class PaintLayerPainterTest | 13 class PaintLayerPainterTest |
| 12 : public PaintControllerPaintTest | 14 : public PaintControllerPaintTest |
| 13 , public testing::WithParamInterface<FrameSettingOverrideFunction> { | 15 , public testing::WithParamInterface<FrameSettingOverrideFunction> { |
| 14 USING_FAST_MALLOC(PaintLayerPainterTest); | 16 USING_FAST_MALLOC(PaintLayerPainterTest); |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 | 314 |
| 313 // needsPaintPhaseFloat should be set when any descendant on the same layer
has float. | 315 // needsPaintPhaseFloat should be set when any descendant on the same layer
has float. |
| 314 toHTMLElement(floatDiv.node())->setAttribute(HTMLNames::styleAttr, styleWith
Float); | 316 toHTMLElement(floatDiv.node())->setAttribute(HTMLNames::styleAttr, styleWith
Float); |
| 315 updateLifecyclePhasesBeforePaint(); | 317 updateLifecyclePhasesBeforePaint(); |
| 316 EXPECT_TRUE(selfPaintingLayer.needsPaintPhaseFloat()); | 318 EXPECT_TRUE(selfPaintingLayer.needsPaintPhaseFloat()); |
| 317 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseFloat()); | 319 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseFloat()); |
| 318 paint(); | 320 paint(); |
| 319 EXPECT_TRUE(displayItemListContains(rootPaintController().getDisplayItemList
(), floatDiv, DisplayItem::BoxDecorationBackground)); | 321 EXPECT_TRUE(displayItemListContains(rootPaintController().getDisplayItemList
(), floatDiv, DisplayItem::BoxDecorationBackground)); |
| 320 } | 322 } |
| 321 | 323 |
| 324 TEST_P(PaintLayerPainterTest, PaintPhaseFloatUnderInlineLayer) |
| 325 { |
| 326 setBodyInnerHTML( |
| 327 "<div id='self-painting-layer' style='position: absolute'>" |
| 328 " <div id='non-self-painting-layer' style='overflow: hidden'>" |
| 329 " <span id='span' style='position: relative'>" |
| 330 " <div id='float' style='width: 10px; height: 10px; background-colo
r: blue; float: left'></div>" |
| 331 " </span>" |
| 332 " </div>" |
| 333 "</div>"); |
| 334 document().view()->updateAllLifecyclePhases(); |
| 335 |
| 336 LayoutObject& floatDiv = *document().getElementById("float")->layoutObject()
; |
| 337 LayoutInline& span = *toLayoutInline(document().getElementById("span")->layo
utObject()); |
| 338 PaintLayer& spanLayer = *span.layer(); |
| 339 ASSERT_TRUE(&spanLayer == floatDiv.enclosingLayer()); |
| 340 ASSERT_FALSE(spanLayer.needsPaintPhaseFloat()); |
| 341 LayoutBlock& selfPaintingLayerObject = *toLayoutBlock(document().getElementB
yId("self-painting-layer")->layoutObject()); |
| 342 PaintLayer& selfPaintingLayer = *selfPaintingLayerObject.layer(); |
| 343 ASSERT_TRUE(selfPaintingLayer.isSelfPaintingLayer()); |
| 344 PaintLayer& nonSelfPaintingLayer = *toLayoutBoxModelObject(document().getEle
mentById("non-self-painting-layer")->layoutObject())->layer(); |
| 345 ASSERT_FALSE(nonSelfPaintingLayer.isSelfPaintingLayer()); |
| 346 |
| 347 EXPECT_TRUE(selfPaintingLayer.needsPaintPhaseFloat()); |
| 348 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseFloat()); |
| 349 EXPECT_FALSE(spanLayer.needsPaintPhaseFloat()); |
| 350 EXPECT_TRUE(displayItemListContains(rootPaintController().getDisplayItemList
(), floatDiv, DisplayItem::BoxDecorationBackground)); |
| 351 } |
| 352 |
| 322 TEST_P(PaintLayerPainterTest, PaintPhaseBlockBackground) | 353 TEST_P(PaintLayerPainterTest, PaintPhaseBlockBackground) |
| 323 { | 354 { |
| 324 AtomicString styleWithoutBackground = "width: 50px; height: 50px"; | 355 AtomicString styleWithoutBackground = "width: 50px; height: 50px"; |
| 325 AtomicString styleWithBackground = "background: blue; " + styleWithoutBackgr
ound; | 356 AtomicString styleWithBackground = "background: blue; " + styleWithoutBackgr
ound; |
| 326 setBodyInnerHTML( | 357 setBodyInnerHTML( |
| 327 "<div id='self-painting-layer' style='position: absolute'>" | 358 "<div id='self-painting-layer' style='position: absolute'>" |
| 328 " <div id='non-self-painting-layer' style='overflow: hidden'>" | 359 " <div id='non-self-painting-layer' style='overflow: hidden'>" |
| 329 " <div>" | 360 " <div>" |
| 330 " <div id='background'></div>" | 361 " <div id='background'></div>" |
| 331 " </div>" | 362 " </div>" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 document().view()->updateAllLifecyclePhases(); | 445 document().view()->updateAllLifecyclePhases(); |
| 415 ASSERT_TRUE(layerDiv.hasLayer()); | 446 ASSERT_TRUE(layerDiv.hasLayer()); |
| 416 PaintLayer& layer = *layerDiv.layer(); | 447 PaintLayer& layer = *layerDiv.layer(); |
| 417 ASSERT_TRUE(layer.isSelfPaintingLayer()); | 448 ASSERT_TRUE(layer.isSelfPaintingLayer()); |
| 418 EXPECT_TRUE(layer.needsPaintPhaseDescendantOutlines()); | 449 EXPECT_TRUE(layer.needsPaintPhaseDescendantOutlines()); |
| 419 EXPECT_TRUE(layer.needsPaintPhaseFloat()); | 450 EXPECT_TRUE(layer.needsPaintPhaseFloat()); |
| 420 EXPECT_TRUE(layer.needsPaintPhaseDescendantBlockBackgrounds()); | 451 EXPECT_TRUE(layer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 421 } | 452 } |
| 422 | 453 |
| 423 } // namespace blink | 454 } // namespace blink |
| OLD | NEW |