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

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

Issue 2776563003: Only automatically promote sticky position elements which move with scroll. (Closed)
Patch Set: Merge with master 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
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 1627 matching lines...) Expand 10 before | Expand all | Expand 10 after
1638 EXPECT_FALSE(stickyLayer->needsCompositingInputsUpdate()); 1638 EXPECT_FALSE(stickyLayer->needsCompositingInputsUpdate());
1639 1639
1640 constraint = stickyMapping->mainGraphicsLayer() 1640 constraint = stickyMapping->mainGraphicsLayer()
1641 ->contentLayer() 1641 ->contentLayer()
1642 ->layer() 1642 ->layer()
1643 ->stickyPositionConstraint(); 1643 ->stickyPositionConstraint();
1644 EXPECT_EQ(IntPoint(0, 10), 1644 EXPECT_EQ(IntPoint(0, 10),
1645 IntPoint(constraint.parentRelativeStickyBoxOffset)); 1645 IntPoint(constraint.parentRelativeStickyBoxOffset));
1646 } 1646 }
1647 1647
1648 TEST_P(CompositedLayerMappingTest, StickyPositionNotSquashed) {
1649 setBodyInnerHTML(
1650 "<style>"
1651 "#scroller { overflow: auto; height: 200px; }"
1652 "#sticky1, #sticky2, #sticky3 {position: sticky; top: 0; width: 50px;"
1653 " height: 50px; background: rgba(0, 128, 0, 0.5);}"
1654 "#sticky1 {backface-visibility: hidden;}"
1655 ".spacer {height: 2000px;}"
1656 "</style>"
1657 "<div id='scroller'>"
1658 " <div id='sticky1'></div>"
1659 " <div id='sticky2'></div>"
1660 " <div id='sticky3'></div>"
1661 " <div class='spacer'></div>"
1662 "</div>");
1663
1664 PaintLayer* sticky1 =
1665 toLayoutBlock(getLayoutObjectByElementId("sticky1"))->layer();
1666 PaintLayer* sticky2 =
1667 toLayoutBlock(getLayoutObjectByElementId("sticky2"))->layer();
1668 PaintLayer* sticky3 =
1669 toLayoutBlock(getLayoutObjectByElementId("sticky3"))->layer();
1670 EXPECT_EQ(PaintsIntoOwnBacking, sticky1->compositingState());
1671 EXPECT_EQ(NotComposited, sticky2->compositingState());
1672 EXPECT_EQ(NotComposited, sticky3->compositingState());
1673
1674 PaintLayer* scroller =
1675 toLayoutBlock(getLayoutObjectByElementId("scroller"))->layer();
1676 PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea();
1677 scrollableArea->scrollToAbsolutePosition(
1678 FloatPoint(scrollableArea->scrollPosition().y(), 100));
1679 document().view()->updateAllLifecyclePhases();
1680
1681 // Now that sticky2 and sticky3 overlap sticky1 they will be promoted, but
1682 // they should not be squashed into the same layer because they scroll with
1683 // respect to each other.
1684 EXPECT_EQ(PaintsIntoOwnBacking, sticky1->compositingState());
1685 EXPECT_EQ(PaintsIntoOwnBacking, sticky2->compositingState());
1686 EXPECT_EQ(PaintsIntoOwnBacking, sticky3->compositingState());
1687 }
1688
1648 TEST_P(CompositedLayerMappingTest, StickyPositionNestedStickyContentOffset) { 1689 TEST_P(CompositedLayerMappingTest, StickyPositionNestedStickyContentOffset) {
1649 setBodyInnerHTML( 1690 setBodyInnerHTML(
1650 "<style>.composited { will-change: transform; }" 1691 "<style>.composited { will-change: transform; }"
1651 "#scroller { overflow: auto; height: 200px; width: 200px; }" 1692 "#scroller { overflow: auto; height: 200px; width: 200px; }"
1652 ".container { height: 500px; }" 1693 ".container { height: 500px; }"
1653 "#outerSticky { position: sticky; top: 0; height: 100px; }" 1694 "#outerSticky { position: sticky; top: 0; height: 100px; }"
1654 "#middleSticky { position: sticky; top: 10px; height: 50px; }" 1695 "#middleSticky { position: sticky; top: 10px; height: 50px; }"
1655 "#innerSticky { position: sticky; top: 25px; height: 25px; }</style>" 1696 "#innerSticky { position: sticky; top: 25px; height: 25px; }</style>"
1656 "<div id='scroller' class='composited'>" 1697 "<div id='scroller' class='composited'>"
1657 " <div style='height: 50px'></div>" 1698 " <div style='height: 50px'></div>"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1733 // the parent layer should remain constant. 1774 // the parent layer should remain constant.
1734 EXPECT_EQ(IntPoint(0, 10), 1775 EXPECT_EQ(IntPoint(0, 10),
1735 IntPoint(outerStickyConstraint.parentRelativeStickyBoxOffset)); 1776 IntPoint(outerStickyConstraint.parentRelativeStickyBoxOffset));
1736 EXPECT_EQ(IntPoint(0, 0), 1777 EXPECT_EQ(IntPoint(0, 0),
1737 IntPoint(middleStickyConstraint.parentRelativeStickyBoxOffset)); 1778 IntPoint(middleStickyConstraint.parentRelativeStickyBoxOffset));
1738 EXPECT_EQ(IntPoint(0, 5), 1779 EXPECT_EQ(IntPoint(0, 5),
1739 IntPoint(innerStickyConstraint.parentRelativeStickyBoxOffset)); 1780 IntPoint(innerStickyConstraint.parentRelativeStickyBoxOffset));
1740 } 1781 }
1741 1782
1742 } // namespace blink 1783 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698