| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/paint/PaintLayer.h" | 5 #include "core/paint/PaintLayer.h" |
| 6 | 6 |
| 7 #include "core/html/HTMLIFrameElement.h" | 7 #include "core/html/HTMLIFrameElement.h" |
| 8 #include "core/layout/LayoutBoxModelObject.h" | 8 #include "core/layout/LayoutBoxModelObject.h" |
| 9 #include "core/layout/LayoutTestHelper.h" | 9 #include "core/layout/LayoutTestHelper.h" |
| 10 #include "core/layout/LayoutView.h" | 10 #include "core/layout/LayoutView.h" |
| (...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 | 583 |
| 584 EXPECT_EQ(span, floating->parent()); | 584 EXPECT_EQ(span, floating->parent()); |
| 585 | 585 |
| 586 EXPECT_EQ(LayoutPoint(83, 83), floating->location()); | 586 EXPECT_EQ(LayoutPoint(83, 83), floating->location()); |
| 587 EXPECT_EQ(LayoutPoint(100, 100), span->location()); | 587 EXPECT_EQ(LayoutPoint(100, 100), span->location()); |
| 588 EXPECT_EQ(LayoutPoint(83, 83), floating->visualOffsetFromAncestor(span)); | 588 EXPECT_EQ(LayoutPoint(83, 83), floating->visualOffsetFromAncestor(span)); |
| 589 EXPECT_EQ(LayoutPoint(183, 183), floating->visualOffsetFromAncestor( | 589 EXPECT_EQ(LayoutPoint(183, 183), floating->visualOffsetFromAncestor( |
| 590 document().layoutView()->layer())); | 590 document().layoutView()->layer())); |
| 591 } | 591 } |
| 592 | 592 |
| 593 TEST_P(PaintLayerTest, FloatLayerUnderFloatUnderInlineLayer) { |
| 594 setBodyInnerHTML( |
| 595 "<style>body {margin: 0}</style>" |
| 596 "<span id='span' style='position: relative; top: 100px; left: 100px'>" |
| 597 " <div style='float: left; margin: 33px'>" |
| 598 " <div id='floating'" |
| 599 " style='float: left; position: relative; top: 50px; left: 50px'>" |
| 600 " </div>" |
| 601 " </div>" |
| 602 "</span>"); |
| 603 |
| 604 PaintLayer* floating = |
| 605 toLayoutBoxModelObject(getLayoutObjectByElementId("floating"))->layer(); |
| 606 PaintLayer* span = |
| 607 toLayoutBoxModelObject(getLayoutObjectByElementId("span"))->layer(); |
| 608 |
| 609 EXPECT_EQ(LayoutPoint(83, 83), floating->location()); |
| 610 EXPECT_EQ(LayoutPoint(100, 100), span->location()); |
| 611 EXPECT_EQ(LayoutPoint(-17, -17), floating->visualOffsetFromAncestor(span)); |
| 612 EXPECT_EQ(LayoutPoint(83, 83), floating->visualOffsetFromAncestor( |
| 613 document().layoutView()->layer())); |
| 614 } |
| 615 |
| 616 TEST_P(PaintLayerTest, FloatLayerUnderFloatLayerUnderInlineLayer) { |
| 617 setBodyInnerHTML( |
| 618 "<style>body {margin: 0}</style>" |
| 619 "<span id='span' style='position: relative; top: 100px; left: 100px'>" |
| 620 " <div id='floatingParent'" |
| 621 " style='float: left; position: relative; margin: 33px'>" |
| 622 " <div id='floating'" |
| 623 " style='float: left; position: relative; top: 50px; left: 50px'>" |
| 624 " </div>" |
| 625 " </div>" |
| 626 "</span>"); |
| 627 |
| 628 PaintLayer* floating = |
| 629 toLayoutBoxModelObject(getLayoutObjectByElementId("floating"))->layer(); |
| 630 PaintLayer* floatingParent = |
| 631 toLayoutBoxModelObject(getLayoutObjectByElementId("floatingParent")) |
| 632 ->layer(); |
| 633 PaintLayer* span = |
| 634 toLayoutBoxModelObject(getLayoutObjectByElementId("span"))->layer(); |
| 635 |
| 636 EXPECT_EQ(LayoutPoint(50, 50), floating->location()); |
| 637 EXPECT_EQ(LayoutPoint(33, 33), floatingParent->location()); |
| 638 EXPECT_EQ(LayoutPoint(100, 100), span->location()); |
| 639 EXPECT_EQ(LayoutPoint(-17, -17), floating->visualOffsetFromAncestor(span)); |
| 640 EXPECT_EQ(LayoutPoint(-67, -67), |
| 641 floatingParent->visualOffsetFromAncestor(span)); |
| 642 EXPECT_EQ(LayoutPoint(83, 83), floating->visualOffsetFromAncestor( |
| 643 document().layoutView()->layer())); |
| 644 } |
| 645 |
| 646 TEST_P(PaintLayerTest, LayerUnderFloatUnderInlineLayer) { |
| 647 setBodyInnerHTML( |
| 648 "<style>body {margin: 0}</style>" |
| 649 "<span id='span' style='position: relative; top: 100px; left: 100px'>" |
| 650 " <div style='float: left; margin: 33px'>" |
| 651 " <div>" |
| 652 " <div id='child' style='position: relative; top: 50px; left: 50px'>" |
| 653 " </div>" |
| 654 " </div>" |
| 655 " </div>" |
| 656 "</span>"); |
| 657 |
| 658 PaintLayer* child = |
| 659 toLayoutBoxModelObject(getLayoutObjectByElementId("child"))->layer(); |
| 660 PaintLayer* span = |
| 661 toLayoutBoxModelObject(getLayoutObjectByElementId("span"))->layer(); |
| 662 |
| 663 EXPECT_EQ(LayoutPoint(83, 83), child->location()); |
| 664 EXPECT_EQ(LayoutPoint(100, 100), span->location()); |
| 665 EXPECT_EQ(LayoutPoint(-17, -17), child->visualOffsetFromAncestor(span)); |
| 666 EXPECT_EQ(LayoutPoint(83, 83), |
| 667 child->visualOffsetFromAncestor(document().layoutView()->layer())); |
| 668 } |
| 669 |
| 593 TEST_P(PaintLayerTest, CompositingContainerFloatingIframe) { | 670 TEST_P(PaintLayerTest, CompositingContainerFloatingIframe) { |
| 594 enableCompositing(); | 671 enableCompositing(); |
| 595 setBodyInnerHTML( | 672 setBodyInnerHTML( |
| 596 "<div id='compositedContainer' style='position: relative;" | 673 "<div id='compositedContainer' style='position: relative;" |
| 597 " will-change: transform'>" | 674 " will-change: transform'>" |
| 598 " <div id='containingBlock' style='position: relative; z-index: 0'>" | 675 " <div id='containingBlock' style='position: relative; z-index: 0'>" |
| 599 " <div style='backface-visibility: hidden'></div>" | 676 " <div style='backface-visibility: hidden'></div>" |
| 600 " <span id='span'" | 677 " <span id='span'" |
| 601 " style='clip-path: polygon(0px 15px, 0px 54px, 100px 0px)'>" | 678 " style='clip-path: polygon(0px 15px, 0px 54px, 100px 0px)'>" |
| 602 " <iframe srcdoc='foo' id='target' style='float: right'></iframe>" | 679 " <iframe srcdoc='foo' id='target' style='float: right'></iframe>" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 toLayoutBoxModelObject(getLayoutObjectByElementId("target"))->layer(); | 716 toLayoutBoxModelObject(getLayoutObjectByElementId("target"))->layer(); |
| 640 EXPECT_TRUE(target->isSelfPaintingLayer()); | 717 EXPECT_TRUE(target->isSelfPaintingLayer()); |
| 641 EXPECT_FALSE(target->stackingNode()->isStacked()); | 718 EXPECT_FALSE(target->stackingNode()->isStacked()); |
| 642 | 719 |
| 643 PaintLayer* span = | 720 PaintLayer* span = |
| 644 toLayoutBoxModelObject(getLayoutObjectByElementId("span"))->layer(); | 721 toLayoutBoxModelObject(getLayoutObjectByElementId("span"))->layer(); |
| 645 EXPECT_EQ(span, target->compositingContainer()); | 722 EXPECT_EQ(span, target->compositingContainer()); |
| 646 } | 723 } |
| 647 | 724 |
| 648 } // namespace blink | 725 } // namespace blink |
| OLD | NEW |