Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(748)

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayerTest.cpp

Issue 2761413002: Fix position of floating layer whose containing block is also floating (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
652 TEST_P(PaintLayerTest, CompositingContainerFloatingIframe) { 713 TEST_P(PaintLayerTest, CompositingContainerFloatingIframe) {
653 enableCompositing(); 714 enableCompositing();
654 setBodyInnerHTML( 715 setBodyInnerHTML(
655 "<div id='compositedContainer' style='position: relative;" 716 "<div id='compositedContainer' style='position: relative;"
656 " will-change: transform'>" 717 " will-change: transform'>"
657 " <div id='containingBlock' style='position: relative; z-index: 0'>" 718 " <div id='containingBlock' style='position: relative; z-index: 0'>"
658 " <div style='backface-visibility: hidden'></div>" 719 " <div style='backface-visibility: hidden'></div>"
659 " <span id='span'" 720 " <span id='span'"
660 " style='clip-path: polygon(0px 15px, 0px 54px, 100px 0px)'>" 721 " style='clip-path: polygon(0px 15px, 0px 54px, 100px 0px)'>"
661 " <iframe srcdoc='foo' id='target' style='float: right'></iframe>" 722 " <iframe srcdoc='foo' id='target' style='float: right'></iframe>"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 EXPECT_EQ(LayoutPoint(-150, 50), spanner->location()); 798 EXPECT_EQ(LayoutPoint(-150, 50), spanner->location());
738 EXPECT_EQ(LayoutPoint(100, 100), extraLayer->location()); 799 EXPECT_EQ(LayoutPoint(100, 100), extraLayer->location());
739 // -60 = 2nd-column-x(40) - scroll-offset-x(200) + x-location(100) 800 // -60 = 2nd-column-x(40) - scroll-offset-x(200) + x-location(100)
740 // 20 = y-location(100) - column-height(80) 801 // 20 = y-location(100) - column-height(80)
741 EXPECT_EQ(LayoutPoint(-60, 20), 802 EXPECT_EQ(LayoutPoint(-60, 20),
742 extraLayer->visualOffsetFromAncestor(columns)); 803 extraLayer->visualOffsetFromAncestor(columns));
743 EXPECT_EQ(LayoutPoint(-150, 50), spanner->visualOffsetFromAncestor(columns)); 804 EXPECT_EQ(LayoutPoint(-150, 50), spanner->visualOffsetFromAncestor(columns));
744 } 805 }
745 806
746 } // namespace blink 807 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698