| 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" | 5 #include "core/layout/LayoutBlock.h" |
| 6 #include "core/layout/LayoutInline.h" | 6 #include "core/layout/LayoutInline.h" |
| 7 #include "core/layout/compositing/CompositedLayerMapping.h" | 7 #include "core/layout/compositing/CompositedLayerMapping.h" |
| 8 #include "core/paint/PaintControllerPaintTest.h" | 8 #include "core/paint/PaintControllerPaintTest.h" |
| 9 #include "platform/graphics/GraphicsContext.h" | 9 #include "platform/graphics/GraphicsContext.h" |
| 10 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" | 10 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseDescendantOutlines()); | 265 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseDescendantOutlines()); |
| 266 EXPECT_TRUE(displayItemListContains(rootPaintController().getDisplayItemList
(), selfPaintingLayerObject, DisplayItem::paintPhaseToDrawingType(PaintPhaseSelf
OutlineOnly))); | 266 EXPECT_TRUE(displayItemListContains(rootPaintController().getDisplayItemList
(), selfPaintingLayerObject, DisplayItem::paintPhaseToDrawingType(PaintPhaseSelf
OutlineOnly))); |
| 267 | 267 |
| 268 // needsPaintPhaseDescendantOutlines should be set when any descendant on th
e same layer has outline. | 268 // needsPaintPhaseDescendantOutlines should be set when any descendant on th
e same layer has outline. |
| 269 toHTMLElement(outlineDiv.node())->setAttribute(HTMLNames::styleAttr, styleWi
thOutline); | 269 toHTMLElement(outlineDiv.node())->setAttribute(HTMLNames::styleAttr, styleWi
thOutline); |
| 270 document().view()->updateAllLifecyclePhasesExceptPaint(); | 270 document().view()->updateAllLifecyclePhasesExceptPaint(); |
| 271 EXPECT_TRUE(selfPaintingLayer.needsPaintPhaseDescendantOutlines()); | 271 EXPECT_TRUE(selfPaintingLayer.needsPaintPhaseDescendantOutlines()); |
| 272 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseDescendantOutlines()); | 272 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseDescendantOutlines()); |
| 273 paint(); | 273 paint(); |
| 274 EXPECT_TRUE(displayItemListContains(rootPaintController().getDisplayItemList
(), outlineDiv, DisplayItem::paintPhaseToDrawingType(PaintPhaseSelfOutlineOnly))
); | 274 EXPECT_TRUE(displayItemListContains(rootPaintController().getDisplayItemList
(), outlineDiv, DisplayItem::paintPhaseToDrawingType(PaintPhaseSelfOutlineOnly))
); |
| 275 |
| 276 // needsPaintPhaseDescendantOutlines should be reset when no outline is actu
ally painted. |
| 277 toHTMLElement(outlineDiv.node())->setAttribute(HTMLNames::styleAttr, styleWi
thoutOutline); |
| 278 document().view()->updateAllLifecyclePhases(); |
| 279 EXPECT_FALSE(selfPaintingLayer.needsPaintPhaseDescendantOutlines()); |
| 275 } | 280 } |
| 276 | 281 |
| 277 TEST_P(PaintLayerPainterTest, PaintPhaseFloat) | 282 TEST_P(PaintLayerPainterTest, PaintPhaseFloat) |
| 278 { | 283 { |
| 279 AtomicString styleWithoutFloat = "width: 50px; height: 50px; background-colo
r: green"; | 284 AtomicString styleWithoutFloat = "width: 50px; height: 50px; background-colo
r: green"; |
| 280 AtomicString styleWithFloat = "float: left; " + styleWithoutFloat; | 285 AtomicString styleWithFloat = "float: left; " + styleWithoutFloat; |
| 281 setBodyInnerHTML( | 286 setBodyInnerHTML( |
| 282 "<div id='self-painting-layer' style='position: absolute'>" | 287 "<div id='self-painting-layer' style='position: absolute'>" |
| 283 " <div id='non-self-painting-layer' style='overflow: hidden'>" | 288 " <div id='non-self-painting-layer' style='overflow: hidden'>" |
| 284 " <div>" | 289 " <div>" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 300 EXPECT_FALSE(selfPaintingLayer.needsPaintPhaseFloat()); | 305 EXPECT_FALSE(selfPaintingLayer.needsPaintPhaseFloat()); |
| 301 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseFloat()); | 306 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseFloat()); |
| 302 | 307 |
| 303 // needsPaintPhaseFloat should be set when any descendant on the same layer
has float. | 308 // needsPaintPhaseFloat should be set when any descendant on the same layer
has float. |
| 304 toHTMLElement(floatDiv.node())->setAttribute(HTMLNames::styleAttr, styleWith
Float); | 309 toHTMLElement(floatDiv.node())->setAttribute(HTMLNames::styleAttr, styleWith
Float); |
| 305 document().view()->updateAllLifecyclePhasesExceptPaint(); | 310 document().view()->updateAllLifecyclePhasesExceptPaint(); |
| 306 EXPECT_TRUE(selfPaintingLayer.needsPaintPhaseFloat()); | 311 EXPECT_TRUE(selfPaintingLayer.needsPaintPhaseFloat()); |
| 307 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseFloat()); | 312 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseFloat()); |
| 308 paint(); | 313 paint(); |
| 309 EXPECT_TRUE(displayItemListContains(rootPaintController().getDisplayItemList
(), floatDiv, DisplayItem::kBoxDecorationBackground)); | 314 EXPECT_TRUE(displayItemListContains(rootPaintController().getDisplayItemList
(), floatDiv, DisplayItem::kBoxDecorationBackground)); |
| 315 |
| 316 // needsPaintPhaseFloat should be reset when there is no float actually pain
ted. |
| 317 toHTMLElement(floatDiv.node())->setAttribute(HTMLNames::styleAttr, styleWith
outFloat); |
| 318 document().view()->updateAllLifecyclePhases(); |
| 319 EXPECT_FALSE(selfPaintingLayer.needsPaintPhaseFloat()); |
| 310 } | 320 } |
| 311 | 321 |
| 312 TEST_P(PaintLayerPainterTest, PaintPhaseFloatUnderInlineLayer) | 322 TEST_P(PaintLayerPainterTest, PaintPhaseFloatUnderInlineLayer) |
| 313 { | 323 { |
| 314 setBodyInnerHTML( | 324 setBodyInnerHTML( |
| 315 "<div id='self-painting-layer' style='position: absolute'>" | 325 "<div id='self-painting-layer' style='position: absolute'>" |
| 316 " <div id='non-self-painting-layer' style='overflow: hidden'>" | 326 " <div id='non-self-painting-layer' style='overflow: hidden'>" |
| 317 " <span id='span' style='position: relative'>" | 327 " <span id='span' style='position: relative'>" |
| 318 " <div id='float' style='width: 10px; height: 10px; background-colo
r: blue; float: left'></div>" | 328 " <div id='float' style='width: 10px; height: 10px; background-colo
r: blue; float: left'></div>" |
| 319 " </span>" | 329 " </span>" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseDescendantBlockBackgrounds(
)); | 381 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseDescendantBlockBackgrounds(
)); |
| 372 EXPECT_TRUE(displayItemListContains(rootPaintController().getDisplayItemList
(), selfPaintingLayerObject, DisplayItem::kBoxDecorationBackground)); | 382 EXPECT_TRUE(displayItemListContains(rootPaintController().getDisplayItemList
(), selfPaintingLayerObject, DisplayItem::kBoxDecorationBackground)); |
| 373 | 383 |
| 374 // needsPaintPhaseDescendantBlockBackgrounds should be set when any descenda
nt on the same layer has Background. | 384 // needsPaintPhaseDescendantBlockBackgrounds should be set when any descenda
nt on the same layer has Background. |
| 375 toHTMLElement(backgroundDiv.node())->setAttribute(HTMLNames::styleAttr, styl
eWithBackground); | 385 toHTMLElement(backgroundDiv.node())->setAttribute(HTMLNames::styleAttr, styl
eWithBackground); |
| 376 document().view()->updateAllLifecyclePhasesExceptPaint(); | 386 document().view()->updateAllLifecyclePhasesExceptPaint(); |
| 377 EXPECT_TRUE(selfPaintingLayer.needsPaintPhaseDescendantBlockBackgrounds()); | 387 EXPECT_TRUE(selfPaintingLayer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 378 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseDescendantBlockBackgrounds(
)); | 388 EXPECT_FALSE(nonSelfPaintingLayer.needsPaintPhaseDescendantBlockBackgrounds(
)); |
| 379 paint(); | 389 paint(); |
| 380 EXPECT_TRUE(displayItemListContains(rootPaintController().getDisplayItemList
(), backgroundDiv, DisplayItem::kBoxDecorationBackground)); | 390 EXPECT_TRUE(displayItemListContains(rootPaintController().getDisplayItemList
(), backgroundDiv, DisplayItem::kBoxDecorationBackground)); |
| 391 |
| 392 // needsPaintPhaseDescendantBlockBackgrounds should be reset when no outline
is actually painted. |
| 393 toHTMLElement(backgroundDiv.node())->setAttribute(HTMLNames::styleAttr, styl
eWithoutBackground); |
| 394 document().view()->updateAllLifecyclePhases(); |
| 395 EXPECT_FALSE(selfPaintingLayer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 381 } | 396 } |
| 382 | 397 |
| 383 TEST_P(PaintLayerPainterTest, PaintPhasesUpdateOnLayerRemoval) | 398 TEST_P(PaintLayerPainterTest, PaintPhasesUpdateOnLayerRemoval) |
| 384 { | 399 { |
| 385 setBodyInnerHTML( | 400 setBodyInnerHTML( |
| 386 "<div id='layer' style='position: relative'>" | 401 "<div id='layer' style='position: relative'>" |
| 387 " <div style='height: 100px'>" | 402 " <div style='height: 100px'>" |
| 388 " <div style='height: 20px; outline: 1px solid red; background-color:
green'>outline and background</div>" | 403 " <div style='height: 20px; outline: 1px solid red; background-color:
green'>outline and background</div>" |
| 389 " <div style='float: left'>float</div>" | 404 " <div style='float: left'>float</div>" |
| 390 " </div>" | 405 " </div>" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 PaintLayer& layer = *table.layer(); | 543 PaintLayer& layer = *table.layer(); |
| 529 EXPECT_TRUE(layer.isSelfPaintingLayer()); | 544 EXPECT_TRUE(layer.isSelfPaintingLayer()); |
| 530 EXPECT_FALSE(layer.needsPaintPhaseDescendantBlockBackgrounds()); | 545 EXPECT_FALSE(layer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 531 | 546 |
| 532 toHTMLElement(table.node())->setAttribute(HTMLNames::styleAttr, "position: r
elative; border-collapse: collapse"); | 547 toHTMLElement(table.node())->setAttribute(HTMLNames::styleAttr, "position: r
elative; border-collapse: collapse"); |
| 533 document().view()->updateAllLifecyclePhases(); | 548 document().view()->updateAllLifecyclePhases(); |
| 534 EXPECT_TRUE(layer.needsPaintPhaseDescendantBlockBackgrounds()); | 549 EXPECT_TRUE(layer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 535 } | 550 } |
| 536 | 551 |
| 537 } // namespace blink | 552 } // namespace blink |
| OLD | NEW |