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

Side by Side Diff: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp

Issue 2803593007: Fix position:sticky location bug when scroller is not a stacking context (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/compositing/CompositedLayerMapping.h" 5 #include "core/layout/compositing/CompositedLayerMapping.h"
6 6
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.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/api/LayoutViewItem.h" 10 #include "core/layout/api/LayoutViewItem.h"
(...skipping 1671 matching lines...) Expand 10 before | Expand all | Expand 10 after
1682 WebLayerStickyPositionConstraint constraint = 1682 WebLayerStickyPositionConstraint constraint =
1683 sticky->mainGraphicsLayer() 1683 sticky->mainGraphicsLayer()
1684 ->contentLayer() 1684 ->contentLayer()
1685 ->layer() 1685 ->layer()
1686 ->stickyPositionConstraint(); 1686 ->stickyPositionConstraint();
1687 EXPECT_EQ(IntPoint(0, 50), 1687 EXPECT_EQ(IntPoint(0, 50),
1688 IntPoint(constraint.parentRelativeStickyBoxOffset)); 1688 IntPoint(constraint.parentRelativeStickyBoxOffset));
1689 } 1689 }
1690 1690
1691 TEST_P(CompositedLayerMappingTest, StickyPositionEnclosingLayersContentOffset) { 1691 TEST_P(CompositedLayerMappingTest, StickyPositionEnclosingLayersContentOffset) {
1692 // Using backface-visibility: hidden causes the scroller to become composited
1693 // without creating a stacking context. This is important as enclosing layer
1694 // scroll correction works differently depending on whether you are in a
1695 // stacking context or not.
1696 setBodyInnerHTML(
1697 "<style>.composited { backface-visibility: hidden; }"
1698 "#scroller { overflow: auto; height: 200px; width: 200px; }"
1699 ".container { height: 500px; }"
1700 ".innerPadding { height: 10px; }"
1701 "#sticky { position: sticky; top: 25px; height: 50px; }</style>"
1702 "<div id='scroller' class='composited'>"
1703 " <div class='composited container'>"
1704 " <div class='composited container'>"
1705 " <div class='innerPadding'></div>"
1706 " <div id='sticky' class='composited'></div>"
1707 " </div></div></div>");
1708
1709 PaintLayer* stickyLayer =
1710 toLayoutBox(getLayoutObjectByElementId("sticky"))->layer();
1711 CompositedLayerMapping* stickyMapping = stickyLayer->compositedLayerMapping();
1712 ASSERT_TRUE(stickyMapping);
1713
1714 WebLayerStickyPositionConstraint constraint =
1715 stickyMapping->mainGraphicsLayer()
1716 ->contentLayer()
1717 ->layer()
1718 ->stickyPositionConstraint();
1719 EXPECT_EQ(IntPoint(0, 10),
1720 IntPoint(constraint.parentRelativeStickyBoxOffset));
1721
1722 // Now scroll the page - this should not affect the parent-relative offset.
1723 LayoutBoxModelObject* scroller =
1724 toLayoutBoxModelObject(getLayoutObjectByElementId("scroller"));
1725 PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea();
1726 scrollableArea->scrollToAbsolutePosition(
1727 FloatPoint(scrollableArea->scrollPosition().x(), 100));
1728 ASSERT_EQ(100.0, scrollableArea->scrollPosition().y());
1729
1730 stickyLayer->setNeedsCompositingInputsUpdate();
1731 EXPECT_TRUE(stickyLayer->needsCompositingInputsUpdate());
1732 document().view()->updateLifecycleToCompositingCleanPlusScrolling();
1733 EXPECT_FALSE(stickyLayer->needsCompositingInputsUpdate());
1734
1735 constraint = stickyMapping->mainGraphicsLayer()
1736 ->contentLayer()
1737 ->layer()
1738 ->stickyPositionConstraint();
1739 EXPECT_EQ(IntPoint(0, 10),
1740 IntPoint(constraint.parentRelativeStickyBoxOffset));
1741 }
1742
1743 TEST_P(CompositedLayerMappingTest,
1744 StickyPositionEnclosingLayersWithStackingContextContentOffset) {
1745 // Using will-change: transform causes the scroller to become a stacking
1746 // context. This changes how its descendant layers interact with it; they no
1747 // longer have a scrollParent and instead just refer to it only as their
1748 // ancestorOverflowLayer.
1692 setBodyInnerHTML( 1749 setBodyInnerHTML(
1693 "<style>.composited { will-change: transform; }" 1750 "<style>.composited { will-change: transform; }"
1694 "#scroller { overflow: auto; height: 200px; width: 200px; }" 1751 "#scroller { overflow: auto; height: 200px; width: 200px; }"
1695 ".container { height: 500px; }" 1752 ".container { height: 500px; }"
1696 ".innerPadding { height: 10px; }" 1753 ".innerPadding { height: 10px; }"
1697 "#sticky { position: sticky; top: 25px; height: 50px; }</style>" 1754 "#sticky { position: sticky; top: 25px; height: 50px; }</style>"
1698 "<div id='scroller' class='composited'>" 1755 "<div id='scroller' class='composited'>"
1699 "<div class='composited container'>"
1700 " <div class='composited container'>" 1756 " <div class='composited container'>"
1701 " <div class='innerPadding'></div>" 1757 " <div class='composited container'>"
1702 " <div id='sticky' class='composited'></div>" 1758 " <div class='innerPadding'></div>"
1759 " <div id='sticky' class='composited'></div>"
1703 " </div></div></div>"); 1760 " </div></div></div>");
1704 1761
1705 PaintLayer* stickyLayer = 1762 PaintLayer* stickyLayer =
1706 toLayoutBox(getLayoutObjectByElementId("sticky"))->layer(); 1763 toLayoutBox(getLayoutObjectByElementId("sticky"))->layer();
1707 CompositedLayerMapping* stickyMapping = stickyLayer->compositedLayerMapping(); 1764 CompositedLayerMapping* stickyMapping = stickyLayer->compositedLayerMapping();
1708 ASSERT_TRUE(stickyMapping); 1765 ASSERT_TRUE(stickyMapping);
1709 1766
1710 WebLayerStickyPositionConstraint constraint = 1767 WebLayerStickyPositionConstraint constraint =
1711 stickyMapping->mainGraphicsLayer() 1768 stickyMapping->mainGraphicsLayer()
1712 ->contentLayer() 1769 ->contentLayer()
(...skipping 17 matching lines...) Expand all
1730 1787
1731 constraint = stickyMapping->mainGraphicsLayer() 1788 constraint = stickyMapping->mainGraphicsLayer()
1732 ->contentLayer() 1789 ->contentLayer()
1733 ->layer() 1790 ->layer()
1734 ->stickyPositionConstraint(); 1791 ->stickyPositionConstraint();
1735 EXPECT_EQ(IntPoint(0, 10), 1792 EXPECT_EQ(IntPoint(0, 10),
1736 IntPoint(constraint.parentRelativeStickyBoxOffset)); 1793 IntPoint(constraint.parentRelativeStickyBoxOffset));
1737 } 1794 }
1738 1795
1739 } // namespace blink 1796 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698