| 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 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 EXPECT_EQ(span, floating->parent()); | 642 EXPECT_EQ(span, floating->parent()); |
| 643 EXPECT_EQ(span, floating->containingLayer()); | 643 EXPECT_EQ(span, floating->containingLayer()); |
| 644 | 644 |
| 645 EXPECT_EQ(LayoutPoint(83, 83), floating->location()); | 645 EXPECT_EQ(LayoutPoint(83, 83), floating->location()); |
| 646 EXPECT_EQ(LayoutPoint(100, 100), span->location()); | 646 EXPECT_EQ(LayoutPoint(100, 100), span->location()); |
| 647 EXPECT_EQ(LayoutPoint(83, 83), floating->visualOffsetFromAncestor(span)); | 647 EXPECT_EQ(LayoutPoint(83, 83), floating->visualOffsetFromAncestor(span)); |
| 648 EXPECT_EQ(LayoutPoint(183, 183), floating->visualOffsetFromAncestor( | 648 EXPECT_EQ(LayoutPoint(183, 183), floating->visualOffsetFromAncestor( |
| 649 document().layoutView()->layer())); | 649 document().layoutView()->layer())); |
| 650 } | 650 } |
| 651 | 651 |
| 652 TEST_P(PaintLayerTest, FloatLayerUnderFloatUnderInlineLayer) { |
| 653 setBodyInnerHTML( |
| 654 "<style>body {margin: 0}</style>" |
| 655 "<span id='span' style='position: relative; top: 100px; left: 100px'>" |
| 656 " <div style='float: left; margin: 33px'>" |
| 657 " <div id='floating'" |
| 658 " style='float: left; position: relative; top: 50px; left: 50px'>" |
| 659 " </div>" |
| 660 " </div>" |
| 661 "</span>"); |
| 662 |
| 663 PaintLayer* floating = |
| 664 toLayoutBoxModelObject(getLayoutObjectByElementId("floating"))->layer(); |
| 665 PaintLayer* span = |
| 666 toLayoutBoxModelObject(getLayoutObjectByElementId("span"))->layer(); |
| 667 |
| 668 EXPECT_EQ(span, floating->parent()); |
| 669 EXPECT_EQ(span->parent(), floating->containingLayer()); |
| 670 |
| 671 EXPECT_EQ(LayoutPoint(83, 83), floating->location()); |
| 672 EXPECT_EQ(LayoutPoint(100, 100), span->location()); |
| 673 EXPECT_EQ(LayoutPoint(-17, -17), floating->visualOffsetFromAncestor(span)); |
| 674 EXPECT_EQ(LayoutPoint(83, 83), floating->visualOffsetFromAncestor( |
| 675 document().layoutView()->layer())); |
| 676 } |
| 677 |
| 678 TEST_P(PaintLayerTest, FloatLayerUnderFloatLayerUnderInlineLayer) { |
| 679 setBodyInnerHTML( |
| 680 "<style>body {margin: 0}</style>" |
| 681 "<span id='span' style='position: relative; top: 100px; left: 100px'>" |
| 682 " <div id='floatingParent'" |
| 683 " style='float: left; position: relative; margin: 33px'>" |
| 684 " <div id='floating'" |
| 685 " style='float: left; position: relative; top: 50px; left: 50px'>" |
| 686 " </div>" |
| 687 " </div>" |
| 688 "</span>"); |
| 689 |
| 690 PaintLayer* floating = |
| 691 toLayoutBoxModelObject(getLayoutObjectByElementId("floating"))->layer(); |
| 692 PaintLayer* floatingParent = |
| 693 toLayoutBoxModelObject(getLayoutObjectByElementId("floatingParent")) |
| 694 ->layer(); |
| 695 PaintLayer* span = |
| 696 toLayoutBoxModelObject(getLayoutObjectByElementId("span"))->layer(); |
| 697 |
| 698 EXPECT_EQ(floatingParent, floating->parent()); |
| 699 EXPECT_EQ(floatingParent, floating->containingLayer()); |
| 700 EXPECT_EQ(span, floatingParent->parent()); |
| 701 EXPECT_EQ(span->parent(), floatingParent->containingLayer()); |
| 702 |
| 703 EXPECT_EQ(LayoutPoint(50, 50), floating->location()); |
| 704 EXPECT_EQ(LayoutPoint(33, 33), floatingParent->location()); |
| 705 EXPECT_EQ(LayoutPoint(100, 100), span->location()); |
| 706 EXPECT_EQ(LayoutPoint(-17, -17), floating->visualOffsetFromAncestor(span)); |
| 707 EXPECT_EQ(LayoutPoint(-67, -67), |
| 708 floatingParent->visualOffsetFromAncestor(span)); |
| 709 EXPECT_EQ(LayoutPoint(83, 83), floating->visualOffsetFromAncestor( |
| 710 document().layoutView()->layer())); |
| 711 } |
| 712 |
| 713 TEST_P(PaintLayerTest, LayerUnderFloatUnderInlineLayer) { |
| 714 setBodyInnerHTML( |
| 715 "<style>body {margin: 0}</style>" |
| 716 "<span id='span' style='position: relative; top: 100px; left: 100px'>" |
| 717 " <div style='float: left; margin: 33px'>" |
| 718 " <div>" |
| 719 " <div id='child' style='position: relative; top: 50px; left: 50px'>" |
| 720 " </div>" |
| 721 " </div>" |
| 722 " </div>" |
| 723 "</span>"); |
| 724 |
| 725 PaintLayer* child = |
| 726 toLayoutBoxModelObject(getLayoutObjectByElementId("child"))->layer(); |
| 727 PaintLayer* span = |
| 728 toLayoutBoxModelObject(getLayoutObjectByElementId("span"))->layer(); |
| 729 |
| 730 EXPECT_EQ(span, child->parent()); |
| 731 EXPECT_EQ(span->parent(), child->containingLayer()); |
| 732 |
| 733 EXPECT_EQ(LayoutPoint(83, 83), child->location()); |
| 734 EXPECT_EQ(LayoutPoint(100, 100), span->location()); |
| 735 EXPECT_EQ(LayoutPoint(-17, -17), child->visualOffsetFromAncestor(span)); |
| 736 EXPECT_EQ(LayoutPoint(83, 83), |
| 737 child->visualOffsetFromAncestor(document().layoutView()->layer())); |
| 738 } |
| 739 |
| 652 TEST_P(PaintLayerTest, CompositingContainerFloatingIframe) { | 740 TEST_P(PaintLayerTest, CompositingContainerFloatingIframe) { |
| 653 enableCompositing(); | 741 enableCompositing(); |
| 654 setBodyInnerHTML( | 742 setBodyInnerHTML( |
| 655 "<div id='compositedContainer' style='position: relative;" | 743 "<div id='compositedContainer' style='position: relative;" |
| 656 " will-change: transform'>" | 744 " will-change: transform'>" |
| 657 " <div id='containingBlock' style='position: relative; z-index: 0'>" | 745 " <div id='containingBlock' style='position: relative; z-index: 0'>" |
| 658 " <div style='backface-visibility: hidden'></div>" | 746 " <div style='backface-visibility: hidden'></div>" |
| 659 " <span id='span'" | 747 " <span id='span'" |
| 660 " style='clip-path: polygon(0px 15px, 0px 54px, 100px 0px)'>" | 748 " style='clip-path: polygon(0px 15px, 0px 54px, 100px 0px)'>" |
| 661 " <iframe srcdoc='foo' id='target' style='float: right'></iframe>" | 749 " <iframe srcdoc='foo' id='target' style='float: right'></iframe>" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 EXPECT_EQ(LayoutPoint(-150, 50), spanner->location()); | 825 EXPECT_EQ(LayoutPoint(-150, 50), spanner->location()); |
| 738 EXPECT_EQ(LayoutPoint(100, 100), extraLayer->location()); | 826 EXPECT_EQ(LayoutPoint(100, 100), extraLayer->location()); |
| 739 // -60 = 2nd-column-x(40) - scroll-offset-x(200) + x-location(100) | 827 // -60 = 2nd-column-x(40) - scroll-offset-x(200) + x-location(100) |
| 740 // 20 = y-location(100) - column-height(80) | 828 // 20 = y-location(100) - column-height(80) |
| 741 EXPECT_EQ(LayoutPoint(-60, 20), | 829 EXPECT_EQ(LayoutPoint(-60, 20), |
| 742 extraLayer->visualOffsetFromAncestor(columns)); | 830 extraLayer->visualOffsetFromAncestor(columns)); |
| 743 EXPECT_EQ(LayoutPoint(-150, 50), spanner->visualOffsetFromAncestor(columns)); | 831 EXPECT_EQ(LayoutPoint(-150, 50), spanner->visualOffsetFromAncestor(columns)); |
| 744 } | 832 } |
| 745 | 833 |
| 746 } // namespace blink | 834 } // namespace blink |
| OLD | NEW |