| Index: Source/core/page/scrolling/ScrollingConstraints.cpp
|
| diff --git a/Source/core/page/scrolling/ScrollingConstraints.cpp b/Source/core/page/scrolling/ScrollingConstraints.cpp
|
| index 0e59a00cdb3e4b03e77fb82564dc83ada4d4b827..89badd279ae44d2fd9067e74a709977b2558aefc 100644
|
| --- a/Source/core/page/scrolling/ScrollingConstraints.cpp
|
| +++ b/Source/core/page/scrolling/ScrollingConstraints.cpp
|
| @@ -28,9 +28,9 @@
|
|
|
| namespace blink {
|
|
|
| -FloatPoint FixedPositionViewportConstraints::layerPositionForViewportRect(const FloatRect& viewportRect) const
|
| +LayoutPoint FixedPositionViewportConstraints::layerPositionForViewportRect(const LayoutRect& viewportRect) const
|
| {
|
| - FloatSize offset;
|
| + LayoutSize offset;
|
|
|
| if (hasAnchorEdge(AnchorEdgeLeft))
|
| offset.setWidth(viewportRect.x() - m_viewportRectAtLastLayout.x());
|
| @@ -45,4 +45,57 @@ FloatPoint FixedPositionViewportConstraints::layerPositionForViewportRect(const
|
| return m_layerPositionAtLastLayout + offset;
|
| }
|
|
|
| +LayoutSize StickyPositionViewportConstraints::computeStickyOffset(const LayoutRect& viewportRect) const
|
| +{
|
| + LayoutRect boxRect = m_absoluteStickyBoxRect;
|
| +
|
| + if (hasAnchorEdge(AnchorEdgeRight)) {
|
| + LayoutUnit rightLimit = viewportRect.maxX() - m_rightOffset;
|
| + LayoutUnit rightDelta = std::min<LayoutUnit>(0, rightLimit - m_absoluteStickyBoxRect.maxX());
|
| + LayoutUnit availableSpace = std::min<LayoutUnit>(0, m_absoluteContainingBlockRect.x() - m_absoluteStickyBoxRect.x());
|
| + if (rightDelta < availableSpace)
|
| + rightDelta = availableSpace;
|
| +
|
| + boxRect.move(rightDelta, 0);
|
| + }
|
| +
|
| + if (hasAnchorEdge(AnchorEdgeLeft)) {
|
| + LayoutUnit leftLimit = viewportRect.x() + m_leftOffset;
|
| + LayoutUnit leftDelta = std::max<LayoutUnit>(0, leftLimit - m_absoluteStickyBoxRect.x());
|
| + LayoutUnit availableSpace = std::max<LayoutUnit>(0, m_absoluteContainingBlockRect.maxX() - m_absoluteStickyBoxRect.maxX());
|
| + if (leftDelta > availableSpace)
|
| + leftDelta = availableSpace;
|
| +
|
| + boxRect.move(leftDelta, 0);
|
| + }
|
| +
|
| + if (hasAnchorEdge(AnchorEdgeBottom)) {
|
| + LayoutUnit bottomLimit = viewportRect.maxY() - m_bottomOffset;
|
| + LayoutUnit bottomDelta = std::min<LayoutUnit>(0, bottomLimit - m_absoluteStickyBoxRect.maxY());
|
| + LayoutUnit availableSpace = std::min<LayoutUnit>(0, m_absoluteContainingBlockRect.y() - m_absoluteStickyBoxRect.y());
|
| + if (bottomDelta < availableSpace)
|
| + bottomDelta = availableSpace;
|
| +
|
| + boxRect.move(0, bottomDelta);
|
| + }
|
| +
|
| + if (hasAnchorEdge(AnchorEdgeTop)) {
|
| + LayoutUnit topLimit = viewportRect.y() + m_topOffset;
|
| + LayoutUnit topDelta = std::max<LayoutUnit>(0, topLimit - m_absoluteStickyBoxRect.y());
|
| + LayoutUnit availableSpace = std::max<LayoutUnit>(0, m_absoluteContainingBlockRect.maxY() - m_absoluteStickyBoxRect.maxY());
|
| + if (topDelta > availableSpace)
|
| + topDelta = availableSpace;
|
| +
|
| + boxRect.move(0, topDelta);
|
| + }
|
| +
|
| + return boxRect.location() - m_absoluteStickyBoxRect.location();
|
| +}
|
| +
|
| +LayoutPoint StickyPositionViewportConstraints::layerPositionForViewportRect(const LayoutRect& viewportRect) const
|
| +{
|
| + LayoutSize offset = computeStickyOffset(viewportRect);
|
| + return m_layerPositionAtLastLayout + offset - m_stickyOffsetAtLastLayout;
|
| +}
|
| +
|
| } // namespace blink
|
|
|