| 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/LayoutBoxModelObject.h" |
| 6 #include "core/layout/LayoutInline.h" | |
| 7 #include "core/layout/compositing/CompositedLayerMapping.h" | 6 #include "core/layout/compositing/CompositedLayerMapping.h" |
| 8 #include "core/paint/PaintControllerPaintTest.h" | 7 #include "core/paint/PaintControllerPaintTest.h" |
| 9 #include "platform/graphics/GraphicsContext.h" | 8 #include "platform/graphics/GraphicsContext.h" |
| 10 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" | 9 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
| 11 | 10 |
| 12 namespace blink { | 11 namespace blink { |
| 13 | 12 |
| 14 struct PaintLayerPainterTestParam { | 13 struct PaintLayerPainterTestParam { |
| 15 PaintLayerPainterTestParam(bool rootLayerScrolling, bool slimmingPaintV2) | 14 PaintLayerPainterTestParam(bool rootLayerScrolling, bool slimmingPaintV2) |
| 16 : rootLayerScrolling(rootLayerScrolling), | 15 : rootLayerScrolling(rootLayerScrolling), |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 " <div id='outline'></div>" | 396 " <div id='outline'></div>" |
| 398 " </div>" | 397 " </div>" |
| 399 " </div>" | 398 " </div>" |
| 400 "</div>"); | 399 "</div>"); |
| 401 LayoutObject& outlineDiv = | 400 LayoutObject& outlineDiv = |
| 402 *document().getElementById("outline")->layoutObject(); | 401 *document().getElementById("outline")->layoutObject(); |
| 403 toHTMLElement(outlineDiv.node()) | 402 toHTMLElement(outlineDiv.node()) |
| 404 ->setAttribute(HTMLNames::styleAttr, styleWithoutOutline); | 403 ->setAttribute(HTMLNames::styleAttr, styleWithoutOutline); |
| 405 document().view()->updateAllLifecyclePhases(); | 404 document().view()->updateAllLifecyclePhases(); |
| 406 | 405 |
| 407 LayoutBlock& selfPaintingLayerObject = *toLayoutBlock( | 406 LayoutBoxModelObject& selfPaintingLayerObject = *toLayoutBoxModelObject( |
| 408 document().getElementById("self-painting-layer")->layoutObject()); | 407 document().getElementById("self-painting-layer")->layoutObject()); |
| 409 PaintLayer& selfPaintingLayer = *selfPaintingLayerObject.layer(); | 408 PaintLayer& selfPaintingLayer = *selfPaintingLayerObject.layer(); |
| 410 ASSERT_TRUE(selfPaintingLayer.isSelfPaintingLayer()); | 409 ASSERT_TRUE(selfPaintingLayer.isSelfPaintingLayer()); |
| 411 PaintLayer& nonSelfPaintingLayer = | 410 PaintLayer& nonSelfPaintingLayer = |
| 412 *toLayoutBoxModelObject( | 411 *toLayoutBoxModelObject( |
| 413 document().getElementById("non-self-painting-layer")->layoutObject()) | 412 document().getElementById("non-self-painting-layer")->layoutObject()) |
| 414 ->layer(); | 413 ->layer(); |
| 415 ASSERT_FALSE(nonSelfPaintingLayer.isSelfPaintingLayer()); | 414 ASSERT_FALSE(nonSelfPaintingLayer.isSelfPaintingLayer()); |
| 416 ASSERT_TRUE(&nonSelfPaintingLayer == outlineDiv.enclosingLayer()); | 415 ASSERT_TRUE(&nonSelfPaintingLayer == outlineDiv.enclosingLayer()); |
| 417 | 416 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 " <div id='float' style='width: 10px; height: 10px; " | 460 " <div id='float' style='width: 10px; height: 10px; " |
| 462 "background-color: blue'></div>" | 461 "background-color: blue'></div>" |
| 463 " </div>" | 462 " </div>" |
| 464 " </div>" | 463 " </div>" |
| 465 "</div>"); | 464 "</div>"); |
| 466 LayoutObject& floatDiv = *document().getElementById("float")->layoutObject(); | 465 LayoutObject& floatDiv = *document().getElementById("float")->layoutObject(); |
| 467 toHTMLElement(floatDiv.node()) | 466 toHTMLElement(floatDiv.node()) |
| 468 ->setAttribute(HTMLNames::styleAttr, styleWithoutFloat); | 467 ->setAttribute(HTMLNames::styleAttr, styleWithoutFloat); |
| 469 document().view()->updateAllLifecyclePhases(); | 468 document().view()->updateAllLifecyclePhases(); |
| 470 | 469 |
| 471 LayoutBlock& selfPaintingLayerObject = *toLayoutBlock( | 470 LayoutBoxModelObject& selfPaintingLayerObject = *toLayoutBoxModelObject( |
| 472 document().getElementById("self-painting-layer")->layoutObject()); | 471 document().getElementById("self-painting-layer")->layoutObject()); |
| 473 PaintLayer& selfPaintingLayer = *selfPaintingLayerObject.layer(); | 472 PaintLayer& selfPaintingLayer = *selfPaintingLayerObject.layer(); |
| 474 ASSERT_TRUE(selfPaintingLayer.isSelfPaintingLayer()); | 473 ASSERT_TRUE(selfPaintingLayer.isSelfPaintingLayer()); |
| 475 PaintLayer& nonSelfPaintingLayer = | 474 PaintLayer& nonSelfPaintingLayer = |
| 476 *toLayoutBoxModelObject( | 475 *toLayoutBoxModelObject( |
| 477 document().getElementById("non-self-painting-layer")->layoutObject()) | 476 document().getElementById("non-self-painting-layer")->layoutObject()) |
| 478 ->layer(); | 477 ->layer(); |
| 479 ASSERT_FALSE(nonSelfPaintingLayer.isSelfPaintingLayer()); | 478 ASSERT_FALSE(nonSelfPaintingLayer.isSelfPaintingLayer()); |
| 480 ASSERT_TRUE(&nonSelfPaintingLayer == floatDiv.enclosingLayer()); | 479 ASSERT_TRUE(&nonSelfPaintingLayer == floatDiv.enclosingLayer()); |
| 481 | 480 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 508 " <div id='non-self-painting-layer' style='overflow: hidden'>" | 507 " <div id='non-self-painting-layer' style='overflow: hidden'>" |
| 509 " <span id='span' style='position: relative'>" | 508 " <span id='span' style='position: relative'>" |
| 510 " <div id='float' style='width: 10px; height: 10px; " | 509 " <div id='float' style='width: 10px; height: 10px; " |
| 511 "background-color: blue; float: left'></div>" | 510 "background-color: blue; float: left'></div>" |
| 512 " </span>" | 511 " </span>" |
| 513 " </div>" | 512 " </div>" |
| 514 "</div>"); | 513 "</div>"); |
| 515 document().view()->updateAllLifecyclePhases(); | 514 document().view()->updateAllLifecyclePhases(); |
| 516 | 515 |
| 517 LayoutObject& floatDiv = *document().getElementById("float")->layoutObject(); | 516 LayoutObject& floatDiv = *document().getElementById("float")->layoutObject(); |
| 518 LayoutInline& span = | 517 LayoutBoxModelObject& span = *toLayoutBoxModelObject( |
| 519 *toLayoutInline(document().getElementById("span")->layoutObject()); | 518 document().getElementById("span")->layoutObject()); |
| 520 PaintLayer& spanLayer = *span.layer(); | 519 PaintLayer& spanLayer = *span.layer(); |
| 521 ASSERT_TRUE(&spanLayer == floatDiv.enclosingLayer()); | 520 ASSERT_TRUE(&spanLayer == floatDiv.enclosingLayer()); |
| 522 ASSERT_FALSE(spanLayer.needsPaintPhaseFloat()); | 521 ASSERT_FALSE(spanLayer.needsPaintPhaseFloat()); |
| 523 LayoutBlock& selfPaintingLayerObject = *toLayoutBlock( | 522 LayoutBoxModelObject& selfPaintingLayerObject = *toLayoutBoxModelObject( |
| 524 document().getElementById("self-painting-layer")->layoutObject()); | 523 document().getElementById("self-painting-layer")->layoutObject()); |
| 525 PaintLayer& selfPaintingLayer = *selfPaintingLayerObject.layer(); | 524 PaintLayer& selfPaintingLayer = *selfPaintingLayerObject.layer(); |
| 526 ASSERT_TRUE(selfPaintingLayer.isSelfPaintingLayer()); | 525 ASSERT_TRUE(selfPaintingLayer.isSelfPaintingLayer()); |
| 527 PaintLayer& nonSelfPaintingLayer = | 526 PaintLayer& nonSelfPaintingLayer = |
| 528 *toLayoutBoxModelObject( | 527 *toLayoutBoxModelObject( |
| 529 document().getElementById("non-self-painting-layer")->layoutObject()) | 528 document().getElementById("non-self-painting-layer")->layoutObject()) |
| 530 ->layer(); | 529 ->layer(); |
| 531 ASSERT_FALSE(nonSelfPaintingLayer.isSelfPaintingLayer()); | 530 ASSERT_FALSE(nonSelfPaintingLayer.isSelfPaintingLayer()); |
| 532 | 531 |
| 533 EXPECT_TRUE(selfPaintingLayer.needsPaintPhaseFloat()); | 532 EXPECT_TRUE(selfPaintingLayer.needsPaintPhaseFloat()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 549 " <div id='background'></div>" | 548 " <div id='background'></div>" |
| 550 " </div>" | 549 " </div>" |
| 551 " </div>" | 550 " </div>" |
| 552 "</div>"); | 551 "</div>"); |
| 553 LayoutObject& backgroundDiv = | 552 LayoutObject& backgroundDiv = |
| 554 *document().getElementById("background")->layoutObject(); | 553 *document().getElementById("background")->layoutObject(); |
| 555 toHTMLElement(backgroundDiv.node()) | 554 toHTMLElement(backgroundDiv.node()) |
| 556 ->setAttribute(HTMLNames::styleAttr, styleWithoutBackground); | 555 ->setAttribute(HTMLNames::styleAttr, styleWithoutBackground); |
| 557 document().view()->updateAllLifecyclePhases(); | 556 document().view()->updateAllLifecyclePhases(); |
| 558 | 557 |
| 559 LayoutBlock& selfPaintingLayerObject = *toLayoutBlock( | 558 LayoutBoxModelObject& selfPaintingLayerObject = *toLayoutBoxModelObject( |
| 560 document().getElementById("self-painting-layer")->layoutObject()); | 559 document().getElementById("self-painting-layer")->layoutObject()); |
| 561 PaintLayer& selfPaintingLayer = *selfPaintingLayerObject.layer(); | 560 PaintLayer& selfPaintingLayer = *selfPaintingLayerObject.layer(); |
| 562 ASSERT_TRUE(selfPaintingLayer.isSelfPaintingLayer()); | 561 ASSERT_TRUE(selfPaintingLayer.isSelfPaintingLayer()); |
| 563 PaintLayer& nonSelfPaintingLayer = | 562 PaintLayer& nonSelfPaintingLayer = |
| 564 *toLayoutBoxModelObject( | 563 *toLayoutBoxModelObject( |
| 565 document().getElementById("non-self-painting-layer")->layoutObject()) | 564 document().getElementById("non-self-painting-layer")->layoutObject()) |
| 566 ->layer(); | 565 ->layer(); |
| 567 ASSERT_FALSE(nonSelfPaintingLayer.isSelfPaintingLayer()); | 566 ASSERT_FALSE(nonSelfPaintingLayer.isSelfPaintingLayer()); |
| 568 ASSERT_TRUE(&nonSelfPaintingLayer == backgroundDiv.enclosingLayer()); | 567 ASSERT_TRUE(&nonSelfPaintingLayer == backgroundDiv.enclosingLayer()); |
| 569 | 568 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 TEST_P(PaintLayerPainterTest, PaintPhasesUpdateOnLayerRemoval) { | 607 TEST_P(PaintLayerPainterTest, PaintPhasesUpdateOnLayerRemoval) { |
| 609 setBodyInnerHTML( | 608 setBodyInnerHTML( |
| 610 "<div id='layer' style='position: relative'>" | 609 "<div id='layer' style='position: relative'>" |
| 611 " <div style='height: 100px'>" | 610 " <div style='height: 100px'>" |
| 612 " <div style='height: 20px; outline: 1px solid red; background-color: " | 611 " <div style='height: 20px; outline: 1px solid red; background-color: " |
| 613 "green'>outline and background</div>" | 612 "green'>outline and background</div>" |
| 614 " <div style='float: left'>float</div>" | 613 " <div style='float: left'>float</div>" |
| 615 " </div>" | 614 " </div>" |
| 616 "</div>"); | 615 "</div>"); |
| 617 | 616 |
| 618 LayoutBlock& layerDiv = | 617 LayoutBoxModelObject& layerDiv = *toLayoutBoxModelObject( |
| 619 *toLayoutBlock(document().getElementById("layer")->layoutObject()); | 618 document().getElementById("layer")->layoutObject()); |
| 620 PaintLayer& layer = *layerDiv.layer(); | 619 PaintLayer& layer = *layerDiv.layer(); |
| 621 ASSERT_TRUE(layer.isSelfPaintingLayer()); | 620 ASSERT_TRUE(layer.isSelfPaintingLayer()); |
| 622 EXPECT_TRUE(layer.needsPaintPhaseDescendantOutlines()); | 621 EXPECT_TRUE(layer.needsPaintPhaseDescendantOutlines()); |
| 623 EXPECT_TRUE(layer.needsPaintPhaseFloat()); | 622 EXPECT_TRUE(layer.needsPaintPhaseFloat()); |
| 624 EXPECT_TRUE(layer.needsPaintPhaseDescendantBlockBackgrounds()); | 623 EXPECT_TRUE(layer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 625 | 624 |
| 626 PaintLayer& htmlLayer = | 625 PaintLayer& htmlLayer = |
| 627 *toLayoutBlock(document().documentElement()->layoutObject())->layer(); | 626 *toLayoutBoxModelObject(document().documentElement()->layoutObject()) |
| 627 ->layer(); |
| 628 EXPECT_FALSE(htmlLayer.needsPaintPhaseDescendantOutlines()); | 628 EXPECT_FALSE(htmlLayer.needsPaintPhaseDescendantOutlines()); |
| 629 EXPECT_FALSE(htmlLayer.needsPaintPhaseFloat()); | 629 EXPECT_FALSE(htmlLayer.needsPaintPhaseFloat()); |
| 630 EXPECT_FALSE(htmlLayer.needsPaintPhaseDescendantBlockBackgrounds()); | 630 EXPECT_FALSE(htmlLayer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 631 | 631 |
| 632 toHTMLElement(layerDiv.node())->setAttribute(HTMLNames::styleAttr, ""); | 632 toHTMLElement(layerDiv.node())->setAttribute(HTMLNames::styleAttr, ""); |
| 633 document().view()->updateAllLifecyclePhases(); | 633 document().view()->updateAllLifecyclePhases(); |
| 634 | 634 |
| 635 EXPECT_FALSE(layerDiv.hasLayer()); | 635 EXPECT_FALSE(layerDiv.hasLayer()); |
| 636 EXPECT_TRUE(htmlLayer.needsPaintPhaseDescendantOutlines()); | 636 EXPECT_TRUE(htmlLayer.needsPaintPhaseDescendantOutlines()); |
| 637 EXPECT_TRUE(htmlLayer.needsPaintPhaseFloat()); | 637 EXPECT_TRUE(htmlLayer.needsPaintPhaseFloat()); |
| 638 EXPECT_TRUE(htmlLayer.needsPaintPhaseDescendantBlockBackgrounds()); | 638 EXPECT_TRUE(htmlLayer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 639 } | 639 } |
| 640 | 640 |
| 641 TEST_P(PaintLayerPainterTest, PaintPhasesUpdateOnLayerAddition) { | 641 TEST_P(PaintLayerPainterTest, PaintPhasesUpdateOnLayerAddition) { |
| 642 setBodyInnerHTML( | 642 setBodyInnerHTML( |
| 643 "<div id='will-be-layer'>" | 643 "<div id='will-be-layer'>" |
| 644 " <div style='height: 100px'>" | 644 " <div style='height: 100px'>" |
| 645 " <div style='height: 20px; outline: 1px solid red; background-color: " | 645 " <div style='height: 20px; outline: 1px solid red; background-color: " |
| 646 "green'>outline and background</div>" | 646 "green'>outline and background</div>" |
| 647 " <div style='float: left'>float</div>" | 647 " <div style='float: left'>float</div>" |
| 648 " </div>" | 648 " </div>" |
| 649 "</div>"); | 649 "</div>"); |
| 650 | 650 |
| 651 LayoutBlock& layerDiv = *toLayoutBlock( | 651 LayoutBoxModelObject& layerDiv = *toLayoutBoxModelObject( |
| 652 document().getElementById("will-be-layer")->layoutObject()); | 652 document().getElementById("will-be-layer")->layoutObject()); |
| 653 EXPECT_FALSE(layerDiv.hasLayer()); | 653 EXPECT_FALSE(layerDiv.hasLayer()); |
| 654 | 654 |
| 655 PaintLayer& htmlLayer = | 655 PaintLayer& htmlLayer = |
| 656 *toLayoutBlock(document().documentElement()->layoutObject())->layer(); | 656 *toLayoutBoxModelObject(document().documentElement()->layoutObject()) |
| 657 ->layer(); |
| 657 EXPECT_TRUE(htmlLayer.needsPaintPhaseDescendantOutlines()); | 658 EXPECT_TRUE(htmlLayer.needsPaintPhaseDescendantOutlines()); |
| 658 EXPECT_TRUE(htmlLayer.needsPaintPhaseFloat()); | 659 EXPECT_TRUE(htmlLayer.needsPaintPhaseFloat()); |
| 659 EXPECT_TRUE(htmlLayer.needsPaintPhaseDescendantBlockBackgrounds()); | 660 EXPECT_TRUE(htmlLayer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 660 | 661 |
| 661 toHTMLElement(layerDiv.node()) | 662 toHTMLElement(layerDiv.node()) |
| 662 ->setAttribute(HTMLNames::styleAttr, "position: relative"); | 663 ->setAttribute(HTMLNames::styleAttr, "position: relative"); |
| 663 document().view()->updateAllLifecyclePhases(); | 664 document().view()->updateAllLifecyclePhases(); |
| 664 ASSERT_TRUE(layerDiv.hasLayer()); | 665 ASSERT_TRUE(layerDiv.hasLayer()); |
| 665 PaintLayer& layer = *layerDiv.layer(); | 666 PaintLayer& layer = *layerDiv.layer(); |
| 666 ASSERT_TRUE(layer.isSelfPaintingLayer()); | 667 ASSERT_TRUE(layer.isSelfPaintingLayer()); |
| 667 EXPECT_TRUE(layer.needsPaintPhaseDescendantOutlines()); | 668 EXPECT_TRUE(layer.needsPaintPhaseDescendantOutlines()); |
| 668 EXPECT_TRUE(layer.needsPaintPhaseFloat()); | 669 EXPECT_TRUE(layer.needsPaintPhaseFloat()); |
| 669 EXPECT_TRUE(layer.needsPaintPhaseDescendantBlockBackgrounds()); | 670 EXPECT_TRUE(layer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 670 } | 671 } |
| 671 | 672 |
| 672 TEST_P(PaintLayerPainterTest, PaintPhasesUpdateOnBecomingSelfPainting) { | 673 TEST_P(PaintLayerPainterTest, PaintPhasesUpdateOnBecomingSelfPainting) { |
| 673 setBodyInnerHTML( | 674 setBodyInnerHTML( |
| 674 "<div id='will-be-self-painting' style='width: 100px; height: 100px; " | 675 "<div id='will-be-self-painting' style='width: 100px; height: 100px; " |
| 675 "overflow: hidden'>" | 676 "overflow: hidden'>" |
| 676 " <div>" | 677 " <div>" |
| 677 " <div style='outline: 1px solid red; background-color: " | 678 " <div style='outline: 1px solid red; background-color: " |
| 678 "green'>outline and background</div>" | 679 "green'>outline and background</div>" |
| 679 " </div>" | 680 " </div>" |
| 680 "</div>"); | 681 "</div>"); |
| 681 | 682 |
| 682 LayoutBlock& layerDiv = *toLayoutBlock( | 683 LayoutBoxModelObject& layerDiv = *toLayoutBoxModelObject( |
| 683 document().getElementById("will-be-self-painting")->layoutObject()); | 684 document().getElementById("will-be-self-painting")->layoutObject()); |
| 684 ASSERT_TRUE(layerDiv.hasLayer()); | 685 ASSERT_TRUE(layerDiv.hasLayer()); |
| 685 EXPECT_FALSE(layerDiv.layer()->isSelfPaintingLayer()); | 686 EXPECT_FALSE(layerDiv.layer()->isSelfPaintingLayer()); |
| 686 | 687 |
| 687 PaintLayer& htmlLayer = | 688 PaintLayer& htmlLayer = |
| 688 *toLayoutBlock(document().documentElement()->layoutObject())->layer(); | 689 *toLayoutBoxModelObject(document().documentElement()->layoutObject()) |
| 690 ->layer(); |
| 689 EXPECT_TRUE(htmlLayer.needsPaintPhaseDescendantOutlines()); | 691 EXPECT_TRUE(htmlLayer.needsPaintPhaseDescendantOutlines()); |
| 690 EXPECT_TRUE(htmlLayer.needsPaintPhaseDescendantBlockBackgrounds()); | 692 EXPECT_TRUE(htmlLayer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 691 | 693 |
| 692 toHTMLElement(layerDiv.node()) | 694 toHTMLElement(layerDiv.node()) |
| 693 ->setAttribute( | 695 ->setAttribute( |
| 694 HTMLNames::styleAttr, | 696 HTMLNames::styleAttr, |
| 695 "width: 100px; height: 100px; overflow: hidden; position: relative"); | 697 "width: 100px; height: 100px; overflow: hidden; position: relative"); |
| 696 document().view()->updateAllLifecyclePhases(); | 698 document().view()->updateAllLifecyclePhases(); |
| 697 PaintLayer& layer = *layerDiv.layer(); | 699 PaintLayer& layer = *layerDiv.layer(); |
| 698 ASSERT_TRUE(layer.isSelfPaintingLayer()); | 700 ASSERT_TRUE(layer.isSelfPaintingLayer()); |
| 699 EXPECT_TRUE(layer.needsPaintPhaseDescendantOutlines()); | 701 EXPECT_TRUE(layer.needsPaintPhaseDescendantOutlines()); |
| 700 EXPECT_TRUE(layer.needsPaintPhaseDescendantBlockBackgrounds()); | 702 EXPECT_TRUE(layer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 701 } | 703 } |
| 702 | 704 |
| 703 TEST_P(PaintLayerPainterTest, PaintPhasesUpdateOnBecomingNonSelfPainting) { | 705 TEST_P(PaintLayerPainterTest, PaintPhasesUpdateOnBecomingNonSelfPainting) { |
| 704 setBodyInnerHTML( | 706 setBodyInnerHTML( |
| 705 "<div id='will-be-non-self-painting' style='width: 100px; height: 100px; " | 707 "<div id='will-be-non-self-painting' style='width: 100px; height: 100px; " |
| 706 "overflow: hidden; position: relative'>" | 708 "overflow: hidden; position: relative'>" |
| 707 " <div>" | 709 " <div>" |
| 708 " <div style='outline: 1px solid red; background-color: " | 710 " <div style='outline: 1px solid red; background-color: " |
| 709 "green'>outline and background</div>" | 711 "green'>outline and background</div>" |
| 710 " </div>" | 712 " </div>" |
| 711 "</div>"); | 713 "</div>"); |
| 712 | 714 |
| 713 LayoutBlock& layerDiv = *toLayoutBlock( | 715 LayoutBoxModelObject& layerDiv = *toLayoutBoxModelObject( |
| 714 document().getElementById("will-be-non-self-painting")->layoutObject()); | 716 document().getElementById("will-be-non-self-painting")->layoutObject()); |
| 715 ASSERT_TRUE(layerDiv.hasLayer()); | 717 ASSERT_TRUE(layerDiv.hasLayer()); |
| 716 PaintLayer& layer = *layerDiv.layer(); | 718 PaintLayer& layer = *layerDiv.layer(); |
| 717 EXPECT_TRUE(layer.isSelfPaintingLayer()); | 719 EXPECT_TRUE(layer.isSelfPaintingLayer()); |
| 718 EXPECT_TRUE(layer.needsPaintPhaseDescendantOutlines()); | 720 EXPECT_TRUE(layer.needsPaintPhaseDescendantOutlines()); |
| 719 EXPECT_TRUE(layer.needsPaintPhaseDescendantBlockBackgrounds()); | 721 EXPECT_TRUE(layer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 720 | 722 |
| 721 PaintLayer& htmlLayer = | 723 PaintLayer& htmlLayer = |
| 722 *toLayoutBlock(document().documentElement()->layoutObject())->layer(); | 724 *toLayoutBoxModelObject(document().documentElement()->layoutObject()) |
| 725 ->layer(); |
| 723 EXPECT_FALSE(htmlLayer.needsPaintPhaseDescendantOutlines()); | 726 EXPECT_FALSE(htmlLayer.needsPaintPhaseDescendantOutlines()); |
| 724 EXPECT_FALSE(htmlLayer.needsPaintPhaseDescendantBlockBackgrounds()); | 727 EXPECT_FALSE(htmlLayer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 725 | 728 |
| 726 toHTMLElement(layerDiv.node()) | 729 toHTMLElement(layerDiv.node()) |
| 727 ->setAttribute(HTMLNames::styleAttr, | 730 ->setAttribute(HTMLNames::styleAttr, |
| 728 "width: 100px; height: 100px; overflow: hidden"); | 731 "width: 100px; height: 100px; overflow: hidden"); |
| 729 document().view()->updateAllLifecyclePhases(); | 732 document().view()->updateAllLifecyclePhases(); |
| 730 EXPECT_FALSE(layer.isSelfPaintingLayer()); | 733 EXPECT_FALSE(layer.isSelfPaintingLayer()); |
| 731 EXPECT_TRUE(htmlLayer.needsPaintPhaseDescendantOutlines()); | 734 EXPECT_TRUE(htmlLayer.needsPaintPhaseDescendantOutlines()); |
| 732 EXPECT_TRUE(htmlLayer.needsPaintPhaseDescendantBlockBackgrounds()); | 735 EXPECT_TRUE(htmlLayer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 733 } | 736 } |
| 734 | 737 |
| 735 TEST_P(PaintLayerPainterTest, | 738 TEST_P(PaintLayerPainterTest, |
| 736 TableCollapsedBorderNeedsPaintPhaseDescendantBlockBackgrounds) { | 739 TableCollapsedBorderNeedsPaintPhaseDescendantBlockBackgrounds) { |
| 737 // TODO(wangxianzhu): Enable this test slimmingPaintInvalidation when its | 740 // TODO(wangxianzhu): Enable this test slimmingPaintInvalidation when its |
| 738 // fully functional. | 741 // fully functional. |
| 739 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) | 742 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) |
| 740 return; | 743 return; |
| 741 | 744 |
| 742 // "position: relative" makes the table and td self-painting layers. | 745 // "position: relative" makes the table and td self-painting layers. |
| 743 // The table's layer should be marked needsPaintPhaseDescendantBlockBackground | 746 // The table's layer should be marked needsPaintPhaseDescendantBlockBackground |
| 744 // because it will paint collapsed borders in the phase. | 747 // because it will paint collapsed borders in the phase. |
| 745 setBodyInnerHTML( | 748 setBodyInnerHTML( |
| 746 "<table id='table' style='position: relative; border-collapse: collapse'>" | 749 "<table id='table' style='position: relative; border-collapse: collapse'>" |
| 747 " <tr><td style='position: relative; border: 1px solid " | 750 " <tr><td style='position: relative; border: 1px solid " |
| 748 "green'>Cell</td></tr>" | 751 "green'>Cell</td></tr>" |
| 749 "</table>"); | 752 "</table>"); |
| 750 | 753 |
| 751 LayoutBlock& table = *toLayoutBlock(getLayoutObjectByElementId("table")); | 754 LayoutBoxModelObject& table = |
| 755 *toLayoutBoxModelObject(getLayoutObjectByElementId("table")); |
| 752 ASSERT_TRUE(table.hasLayer()); | 756 ASSERT_TRUE(table.hasLayer()); |
| 753 PaintLayer& layer = *table.layer(); | 757 PaintLayer& layer = *table.layer(); |
| 754 EXPECT_TRUE(layer.isSelfPaintingLayer()); | 758 EXPECT_TRUE(layer.isSelfPaintingLayer()); |
| 755 EXPECT_TRUE(layer.needsPaintPhaseDescendantBlockBackgrounds()); | 759 EXPECT_TRUE(layer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 756 } | 760 } |
| 757 | 761 |
| 758 TEST_P(PaintLayerPainterTest, | 762 TEST_P(PaintLayerPainterTest, |
| 759 TableCollapsedBorderNeedsPaintPhaseDescendantBlockBackgroundsDynamic) { | 763 TableCollapsedBorderNeedsPaintPhaseDescendantBlockBackgroundsDynamic) { |
| 760 // TODO(wangxianzhu): Enable this test slimmingPaintInvalidation when its | 764 // TODO(wangxianzhu): Enable this test slimmingPaintInvalidation when its |
| 761 // fully functional. | 765 // fully functional. |
| 762 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) | 766 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) |
| 763 return; | 767 return; |
| 764 | 768 |
| 765 setBodyInnerHTML( | 769 setBodyInnerHTML( |
| 766 "<table id='table' style='position: relative'>" | 770 "<table id='table' style='position: relative'>" |
| 767 " <tr><td style='position: relative; border: 1px solid " | 771 " <tr><td style='position: relative; border: 1px solid " |
| 768 "green'>Cell</td></tr>" | 772 "green'>Cell</td></tr>" |
| 769 "</table>"); | 773 "</table>"); |
| 770 | 774 |
| 771 LayoutBlock& table = *toLayoutBlock(getLayoutObjectByElementId("table")); | 775 LayoutBoxModelObject& table = |
| 776 *toLayoutBoxModelObject(getLayoutObjectByElementId("table")); |
| 772 ASSERT_TRUE(table.hasLayer()); | 777 ASSERT_TRUE(table.hasLayer()); |
| 773 PaintLayer& layer = *table.layer(); | 778 PaintLayer& layer = *table.layer(); |
| 774 EXPECT_TRUE(layer.isSelfPaintingLayer()); | 779 EXPECT_TRUE(layer.isSelfPaintingLayer()); |
| 775 EXPECT_FALSE(layer.needsPaintPhaseDescendantBlockBackgrounds()); | 780 EXPECT_FALSE(layer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 776 | 781 |
| 777 toHTMLElement(table.node()) | 782 toHTMLElement(table.node()) |
| 778 ->setAttribute(HTMLNames::styleAttr, | 783 ->setAttribute(HTMLNames::styleAttr, |
| 779 "position: relative; border-collapse: collapse"); | 784 "position: relative; border-collapse: collapse"); |
| 780 document().view()->updateAllLifecyclePhases(); | 785 document().view()->updateAllLifecyclePhases(); |
| 781 EXPECT_TRUE(layer.needsPaintPhaseDescendantBlockBackgrounds()); | 786 EXPECT_TRUE(layer.needsPaintPhaseDescendantBlockBackgrounds()); |
| 782 } | 787 } |
| 783 | 788 |
| 784 } // namespace blink | 789 } // namespace blink |
| OLD | NEW |