| 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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 updateLifecyclePhasesBeforePaint(); | 357 updateLifecyclePhasesBeforePaint(); |
| 358 EXPECT_TRUE(selfPaintingLayer.needsPaintPhaseDescendantBlockBackgrounds()); | 358 EXPECT_TRUE(selfPaintingLayer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 359 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseDescendantBlockBackgrounds(
)); | 359 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseDescendantBlockBackgrounds(
)); |
| 360 paint(); | 360 paint(); |
| 361 EXPECT_TRUE(displayItemListContains(rootPaintController().getDisplayItemList
(), backgroundDiv, DisplayItem::BoxDecorationBackground)); | 361 EXPECT_TRUE(displayItemListContains(rootPaintController().getDisplayItemList
(), backgroundDiv, DisplayItem::BoxDecorationBackground)); |
| 362 } | 362 } |
| 363 | 363 |
| 364 TEST_P(PaintLayerPainterTest, PaintPhasesUpdateOnLayerRemoval) | 364 TEST_P(PaintLayerPainterTest, PaintPhasesUpdateOnLayerRemoval) |
| 365 { | 365 { |
| 366 setBodyInnerHTML( | 366 setBodyInnerHTML( |
| 367 "<div id='layer' style='opacity: 0.5'>" | 367 "<div id='layer' style='position: relative'>" |
| 368 " <div style='height: 100px'>" | 368 " <div style='height: 100px'>" |
| 369 " <div style='height: 20px; outline: 1px solid red; background-color:
green'>outline and background</div>" | 369 " <div style='height: 20px; outline: 1px solid red; background-color:
green'>outline and background</div>" |
| 370 " <div style='float: left'>float</div>" | 370 " <div style='float: left'>float</div>" |
| 371 " </div>" | 371 " </div>" |
| 372 "</div>"); | 372 "</div>"); |
| 373 | 373 |
| 374 LayoutBlock& layerDiv = *toLayoutBlock(document().getElementById("layer")->l
ayoutObject()); | 374 LayoutBlock& layerDiv = *toLayoutBlock(document().getElementById("layer")->l
ayoutObject()); |
| 375 PaintLayer& layer = *layerDiv.layer(); | 375 PaintLayer& layer = *layerDiv.layer(); |
| 376 ASSERT_TRUE(layer.isSelfPaintingLayer()); | 376 ASSERT_TRUE(layer.isSelfPaintingLayer()); |
| 377 EXPECT_TRUE(layer.needsPaintPhaseDescendantOutlines()); | 377 EXPECT_TRUE(layer.needsPaintPhaseDescendantOutlines()); |
| 378 EXPECT_TRUE(layer.needsPaintPhaseFloat()); | 378 EXPECT_TRUE(layer.needsPaintPhaseFloat()); |
| 379 EXPECT_TRUE(layer.needsPaintPhaseDescendantBlockBackgrounds()); | 379 EXPECT_TRUE(layer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 380 | 380 |
| 381 PaintLayer& htmlLayer = *toLayoutBlock(document().documentElement()->layoutO
bject())->layer(); | 381 PaintLayer& htmlLayer = *toLayoutBlock(document().documentElement()->layoutO
bject())->layer(); |
| 382 EXPECT_FALSE(htmlLayer.needsPaintPhaseDescendantOutlines()); | 382 EXPECT_FALSE(htmlLayer.needsPaintPhaseDescendantOutlines()); |
| 383 EXPECT_FALSE(htmlLayer.needsPaintPhaseFloat()); | 383 EXPECT_FALSE(htmlLayer.needsPaintPhaseFloat()); |
| 384 EXPECT_FALSE(htmlLayer.needsPaintPhaseDescendantBlockBackgrounds()); | 384 EXPECT_FALSE(htmlLayer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 385 | 385 |
| 386 toHTMLElement(layerDiv.node())->setAttribute(HTMLNames::styleAttr, "opacity:
1"); | 386 toHTMLElement(layerDiv.node())->setAttribute(HTMLNames::styleAttr, ""); |
| 387 document().view()->updateAllLifecyclePhases(); | 387 document().view()->updateAllLifecyclePhases(); |
| 388 | 388 |
| 389 EXPECT_FALSE(layerDiv.hasLayer()); | 389 EXPECT_FALSE(layerDiv.hasLayer()); |
| 390 EXPECT_TRUE(htmlLayer.needsPaintPhaseDescendantOutlines()); | 390 EXPECT_TRUE(htmlLayer.needsPaintPhaseDescendantOutlines()); |
| 391 EXPECT_TRUE(htmlLayer.needsPaintPhaseFloat()); | 391 EXPECT_TRUE(htmlLayer.needsPaintPhaseFloat()); |
| 392 EXPECT_TRUE(htmlLayer.needsPaintPhaseDescendantBlockBackgrounds()); | 392 EXPECT_TRUE(htmlLayer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 393 } | 393 } |
| 394 | 394 |
| 395 TEST_P(PaintLayerPainterTest, PaintPhasesUpdateOnLayerAddition) |
| 396 { |
| 397 setBodyInnerHTML( |
| 398 "<div id='will-be-layer'>" |
| 399 " <div style='height: 100px'>" |
| 400 " <div style='height: 20px; outline: 1px solid red; background-color:
green'>outline and background</div>" |
| 401 " <div style='float: left'>float</div>" |
| 402 " </div>" |
| 403 "</div>"); |
| 404 |
| 405 LayoutBlock& layerDiv = *toLayoutBlock(document().getElementById("will-be-la
yer")->layoutObject()); |
| 406 EXPECT_FALSE(layerDiv.hasLayer()); |
| 407 |
| 408 PaintLayer& htmlLayer = *toLayoutBlock(document().documentElement()->layoutO
bject())->layer(); |
| 409 EXPECT_TRUE(htmlLayer.needsPaintPhaseDescendantOutlines()); |
| 410 EXPECT_TRUE(htmlLayer.needsPaintPhaseFloat()); |
| 411 EXPECT_TRUE(htmlLayer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 412 |
| 413 toHTMLElement(layerDiv.node())->setAttribute(HTMLNames::styleAttr, "position
: relative"); |
| 414 document().view()->updateAllLifecyclePhases(); |
| 415 ASSERT_TRUE(layerDiv.hasLayer()); |
| 416 PaintLayer& layer = *layerDiv.layer(); |
| 417 ASSERT_TRUE(layer.isSelfPaintingLayer()); |
| 418 EXPECT_TRUE(layer.needsPaintPhaseDescendantOutlines()); |
| 419 EXPECT_TRUE(layer.needsPaintPhaseFloat()); |
| 420 EXPECT_TRUE(layer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 421 } |
| 422 |
| 395 } // namespace blink | 423 } // namespace blink |
| OLD | NEW |