| OLD | NEW | 
|---|
| 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 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1581   EXPECT_FALSE(stickyLayer->needsCompositingInputsUpdate()); | 1581   EXPECT_FALSE(stickyLayer->needsCompositingInputsUpdate()); | 
| 1582 | 1582 | 
| 1583   constraint = stickyMapping->mainGraphicsLayer() | 1583   constraint = stickyMapping->mainGraphicsLayer() | 
| 1584                    ->contentLayer() | 1584                    ->contentLayer() | 
| 1585                    ->layer() | 1585                    ->layer() | 
| 1586                    ->stickyPositionConstraint(); | 1586                    ->stickyPositionConstraint(); | 
| 1587   EXPECT_EQ(IntPoint(0, 10), | 1587   EXPECT_EQ(IntPoint(0, 10), | 
| 1588             IntPoint(constraint.parentRelativeStickyBoxOffset)); | 1588             IntPoint(constraint.parentRelativeStickyBoxOffset)); | 
| 1589 } | 1589 } | 
| 1590 | 1590 | 
|  | 1591 TEST_P(CompositedLayerMappingTest, StickyPositionNestedStickyContentOffset) { | 
|  | 1592   setBodyInnerHTML( | 
|  | 1593       "<style>.composited { will-change: transform; }" | 
|  | 1594       "#scroller { overflow: auto; height: 200px; width: 200px; }" | 
|  | 1595       ".container { height: 500px; }" | 
|  | 1596       "#outerSticky { position: sticky; top: 0; height: 100px; }" | 
|  | 1597       "#middleSticky { position: sticky; top: 10px; height: 50px; }" | 
|  | 1598       "#innerSticky { position: sticky; top: 25px; height: 25px; }</style>" | 
|  | 1599       "<div id='scroller' class='composited'>" | 
|  | 1600       "  <div style='height: 50px'></div>" | 
|  | 1601       "  <div class='composited container'>" | 
|  | 1602       "    <div style='height: 10px;'></div>" | 
|  | 1603       "    <div id='outerSticky' class='composited'>" | 
|  | 1604       "      <div id='middleSticky' class='composited'>" | 
|  | 1605       "        <div style='height: 5px;'></div>" | 
|  | 1606       "        <div id='innerSticky' class='composited'></div>" | 
|  | 1607       "      </div>" | 
|  | 1608       "    </div>" | 
|  | 1609       "  </div>" | 
|  | 1610       "</div>"); | 
|  | 1611 | 
|  | 1612   PaintLayer* outerSticky = | 
|  | 1613       toLayoutBox(getLayoutObjectByElementId("outerSticky"))->layer(); | 
|  | 1614   PaintLayer* middleSticky = | 
|  | 1615       toLayoutBox(getLayoutObjectByElementId("middleSticky"))->layer(); | 
|  | 1616   PaintLayer* innerSticky = | 
|  | 1617       toLayoutBox(getLayoutObjectByElementId("innerSticky"))->layer(); | 
|  | 1618 | 
|  | 1619   WebLayerStickyPositionConstraint outerStickyConstraint = | 
|  | 1620       outerSticky->compositedLayerMapping() | 
|  | 1621           ->mainGraphicsLayer() | 
|  | 1622           ->contentLayer() | 
|  | 1623           ->layer() | 
|  | 1624           ->stickyPositionConstraint(); | 
|  | 1625   WebLayerStickyPositionConstraint middleStickyConstraint = | 
|  | 1626       middleSticky->compositedLayerMapping() | 
|  | 1627           ->mainGraphicsLayer() | 
|  | 1628           ->contentLayer() | 
|  | 1629           ->layer() | 
|  | 1630           ->stickyPositionConstraint(); | 
|  | 1631   WebLayerStickyPositionConstraint innerStickyConstraint = | 
|  | 1632       innerSticky->compositedLayerMapping() | 
|  | 1633           ->mainGraphicsLayer() | 
|  | 1634           ->contentLayer() | 
|  | 1635           ->layer() | 
|  | 1636           ->stickyPositionConstraint(); | 
|  | 1637 | 
|  | 1638   EXPECT_EQ(IntPoint(0, 10), | 
|  | 1639             IntPoint(outerStickyConstraint.parentRelativeStickyBoxOffset)); | 
|  | 1640   EXPECT_EQ(IntPoint(0, 0), | 
|  | 1641             IntPoint(middleStickyConstraint.parentRelativeStickyBoxOffset)); | 
|  | 1642   EXPECT_EQ(IntPoint(0, 5), | 
|  | 1643             IntPoint(innerStickyConstraint.parentRelativeStickyBoxOffset)); | 
|  | 1644 | 
|  | 1645   // Scroll the content to engage the sticky elements. | 
|  | 1646   LayoutBoxModelObject* scroller = | 
|  | 1647       toLayoutBoxModelObject(getLayoutObjectByElementId("scroller")); | 
|  | 1648   PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea(); | 
|  | 1649   scrollableArea->scrollToAbsolutePosition( | 
|  | 1650       FloatPoint(scrollableArea->scrollPosition().x(), 110)); | 
|  | 1651   ASSERT_EQ(110.0, scrollableArea->scrollPosition().y()); | 
|  | 1652 | 
|  | 1653   outerSticky->setNeedsCompositingInputsUpdate(); | 
|  | 1654   middleSticky->setNeedsCompositingInputsUpdate(); | 
|  | 1655   innerSticky->setNeedsCompositingInputsUpdate(); | 
|  | 1656 | 
|  | 1657   document().view()->updateLifecycleToCompositingCleanPlusScrolling(); | 
|  | 1658 | 
|  | 1659   outerStickyConstraint = outerSticky->compositedLayerMapping() | 
|  | 1660                               ->mainGraphicsLayer() | 
|  | 1661                               ->contentLayer() | 
|  | 1662                               ->layer() | 
|  | 1663                               ->stickyPositionConstraint(); | 
|  | 1664   middleStickyConstraint = middleSticky->compositedLayerMapping() | 
|  | 1665                                ->mainGraphicsLayer() | 
|  | 1666                                ->contentLayer() | 
|  | 1667                                ->layer() | 
|  | 1668                                ->stickyPositionConstraint(); | 
|  | 1669   innerStickyConstraint = innerSticky->compositedLayerMapping() | 
|  | 1670                               ->mainGraphicsLayer() | 
|  | 1671                               ->contentLayer() | 
|  | 1672                               ->layer() | 
|  | 1673                               ->stickyPositionConstraint(); | 
|  | 1674 | 
|  | 1675   // After scrolling and despite ancestor sticky changes, the offset relative to | 
|  | 1676   // the parent layer should remain constant. | 
|  | 1677   EXPECT_EQ(IntPoint(0, 10), | 
|  | 1678             IntPoint(outerStickyConstraint.parentRelativeStickyBoxOffset)); | 
|  | 1679   EXPECT_EQ(IntPoint(0, 0), | 
|  | 1680             IntPoint(middleStickyConstraint.parentRelativeStickyBoxOffset)); | 
|  | 1681   EXPECT_EQ(IntPoint(0, 5), | 
|  | 1682             IntPoint(innerStickyConstraint.parentRelativeStickyBoxOffset)); | 
|  | 1683 } | 
|  | 1684 | 
| 1591 }  // namespace blink | 1685 }  // namespace blink | 
| OLD | NEW | 
|---|