| 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 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 EXPECT_EQ(span, floating->parent()); | 620 EXPECT_EQ(span, floating->parent()); |
| 621 EXPECT_EQ(span, floating->containingLayer()); | 621 EXPECT_EQ(span, floating->containingLayer()); |
| 622 | 622 |
| 623 EXPECT_EQ(LayoutPoint(83, 83), floating->location()); | 623 EXPECT_EQ(LayoutPoint(83, 83), floating->location()); |
| 624 EXPECT_EQ(LayoutPoint(100, 100), span->location()); | 624 EXPECT_EQ(LayoutPoint(100, 100), span->location()); |
| 625 EXPECT_EQ(LayoutPoint(83, 83), floating->visualOffsetFromAncestor(span)); | 625 EXPECT_EQ(LayoutPoint(83, 83), floating->visualOffsetFromAncestor(span)); |
| 626 EXPECT_EQ(LayoutPoint(183, 183), floating->visualOffsetFromAncestor( | 626 EXPECT_EQ(LayoutPoint(183, 183), floating->visualOffsetFromAncestor( |
| 627 document().layoutView()->layer())); | 627 document().layoutView()->layer())); |
| 628 } | 628 } |
| 629 | 629 |
| 630 TEST_P(PaintLayerTest, FloatLayerUnderFloatUnderInlineLayer) { |
| 631 setBodyInnerHTML( |
| 632 "<style>body {margin: 0}</style>" |
| 633 "<span id='span' style='position: relative; top: 100px; left: 100px'>" |
| 634 " <div style='float: left; margin: 33px'>" |
| 635 " <div id='floating'" |
| 636 " style='float: left; position: relative; top: 50px; left: 50px'>" |
| 637 " </div>" |
| 638 " </div>" |
| 639 "</span>"); |
| 640 |
| 641 PaintLayer* floating = |
| 642 toLayoutBoxModelObject(getLayoutObjectByElementId("floating"))->layer(); |
| 643 PaintLayer* span = |
| 644 toLayoutBoxModelObject(getLayoutObjectByElementId("span"))->layer(); |
| 645 |
| 646 EXPECT_EQ(span, floating->parent()); |
| 647 EXPECT_EQ(span->parent(), floating->containingLayer()); |
| 648 |
| 649 EXPECT_EQ(LayoutPoint(83, 83), floating->location()); |
| 650 EXPECT_EQ(LayoutPoint(100, 100), span->location()); |
| 651 EXPECT_EQ(LayoutPoint(-17, -17), floating->visualOffsetFromAncestor(span)); |
| 652 EXPECT_EQ(LayoutPoint(83, 83), floating->visualOffsetFromAncestor( |
| 653 document().layoutView()->layer())); |
| 654 } |
| 655 |
| 656 TEST_P(PaintLayerTest, FloatLayerUnderFloatLayerUnderInlineLayer) { |
| 657 setBodyInnerHTML( |
| 658 "<style>body {margin: 0}</style>" |
| 659 "<span id='span' style='position: relative; top: 100px; left: 100px'>" |
| 660 " <div id='floatingParent'" |
| 661 " style='float: left; position: relative; margin: 33px'>" |
| 662 " <div id='floating'" |
| 663 " style='float: left; position: relative; top: 50px; left: 50px'>" |
| 664 " </div>" |
| 665 " </div>" |
| 666 "</span>"); |
| 667 |
| 668 PaintLayer* floating = |
| 669 toLayoutBoxModelObject(getLayoutObjectByElementId("floating"))->layer(); |
| 670 PaintLayer* floatingParent = |
| 671 toLayoutBoxModelObject(getLayoutObjectByElementId("floatingParent")) |
| 672 ->layer(); |
| 673 PaintLayer* span = |
| 674 toLayoutBoxModelObject(getLayoutObjectByElementId("span"))->layer(); |
| 675 |
| 676 EXPECT_EQ(floatingParent, floating->parent()); |
| 677 EXPECT_EQ(floatingParent, floating->containingLayer()); |
| 678 EXPECT_EQ(span, floatingParent->parent()); |
| 679 EXPECT_EQ(span->parent(), floatingParent->containingLayer()); |
| 680 |
| 681 EXPECT_EQ(LayoutPoint(50, 50), floating->location()); |
| 682 EXPECT_EQ(LayoutPoint(33, 33), floatingParent->location()); |
| 683 EXPECT_EQ(LayoutPoint(100, 100), span->location()); |
| 684 EXPECT_EQ(LayoutPoint(-17, -17), floating->visualOffsetFromAncestor(span)); |
| 685 EXPECT_EQ(LayoutPoint(-67, -67), |
| 686 floatingParent->visualOffsetFromAncestor(span)); |
| 687 EXPECT_EQ(LayoutPoint(83, 83), floating->visualOffsetFromAncestor( |
| 688 document().layoutView()->layer())); |
| 689 } |
| 690 |
| 691 TEST_P(PaintLayerTest, LayerUnderFloatUnderInlineLayer) { |
| 692 setBodyInnerHTML( |
| 693 "<style>body {margin: 0}</style>" |
| 694 "<span id='span' style='position: relative; top: 100px; left: 100px'>" |
| 695 " <div style='float: left; margin: 33px'>" |
| 696 " <div>" |
| 697 " <div id='child' style='position: relative; top: 50px; left: 50px'>" |
| 698 " </div>" |
| 699 " </div>" |
| 700 " </div>" |
| 701 "</span>"); |
| 702 |
| 703 PaintLayer* child = |
| 704 toLayoutBoxModelObject(getLayoutObjectByElementId("child"))->layer(); |
| 705 PaintLayer* span = |
| 706 toLayoutBoxModelObject(getLayoutObjectByElementId("span"))->layer(); |
| 707 |
| 708 EXPECT_EQ(span, child->parent()); |
| 709 EXPECT_EQ(span->parent(), child->containingLayer()); |
| 710 |
| 711 EXPECT_EQ(LayoutPoint(83, 83), child->location()); |
| 712 EXPECT_EQ(LayoutPoint(100, 100), span->location()); |
| 713 EXPECT_EQ(LayoutPoint(-17, -17), child->visualOffsetFromAncestor(span)); |
| 714 EXPECT_EQ(LayoutPoint(83, 83), |
| 715 child->visualOffsetFromAncestor(document().layoutView()->layer())); |
| 716 } |
| 717 |
| 630 TEST_P(PaintLayerTest, CompositingContainerFloatingIframe) { | 718 TEST_P(PaintLayerTest, CompositingContainerFloatingIframe) { |
| 631 enableCompositing(); | 719 enableCompositing(); |
| 632 setBodyInnerHTML( | 720 setBodyInnerHTML( |
| 633 "<div id='compositedContainer' style='position: relative;" | 721 "<div id='compositedContainer' style='position: relative;" |
| 634 " will-change: transform'>" | 722 " will-change: transform'>" |
| 635 " <div id='containingBlock' style='position: relative; z-index: 0'>" | 723 " <div id='containingBlock' style='position: relative; z-index: 0'>" |
| 636 " <div style='backface-visibility: hidden'></div>" | 724 " <div style='backface-visibility: hidden'></div>" |
| 637 " <span id='span'" | 725 " <span id='span'" |
| 638 " style='clip-path: polygon(0px 15px, 0px 54px, 100px 0px)'>" | 726 " style='clip-path: polygon(0px 15px, 0px 54px, 100px 0px)'>" |
| 639 " <iframe srcdoc='foo' id='target' style='float: right'></iframe>" | 727 " <iframe srcdoc='foo' id='target' style='float: right'></iframe>" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 EXPECT_EQ(LayoutPoint(-150, 50), spanner->location()); | 803 EXPECT_EQ(LayoutPoint(-150, 50), spanner->location()); |
| 716 EXPECT_EQ(LayoutPoint(100, 100), extraLayer->location()); | 804 EXPECT_EQ(LayoutPoint(100, 100), extraLayer->location()); |
| 717 // -60 = 2nd-column-x(40) - scroll-offset-x(200) + x-location(100) | 805 // -60 = 2nd-column-x(40) - scroll-offset-x(200) + x-location(100) |
| 718 // 20 = y-location(100) - column-height(80) | 806 // 20 = y-location(100) - column-height(80) |
| 719 EXPECT_EQ(LayoutPoint(-60, 20), | 807 EXPECT_EQ(LayoutPoint(-60, 20), |
| 720 extraLayer->visualOffsetFromAncestor(columns)); | 808 extraLayer->visualOffsetFromAncestor(columns)); |
| 721 EXPECT_EQ(LayoutPoint(-150, 50), spanner->visualOffsetFromAncestor(columns)); | 809 EXPECT_EQ(LayoutPoint(-150, 50), spanner->visualOffsetFromAncestor(columns)); |
| 722 } | 810 } |
| 723 | 811 |
| 724 } // namespace blink | 812 } // namespace blink |
| OLD | NEW |