| Index: third_party/WebKit/Source/core/page/scrolling/StickyPositionScrollingConstraints.h
|
| diff --git a/third_party/WebKit/Source/core/page/scrolling/StickyPositionScrollingConstraints.h b/third_party/WebKit/Source/core/page/scrolling/StickyPositionScrollingConstraints.h
|
| index e37687262edcd4a096f127a3a5054eeb78330e66..f2ec9ed594c1abc856819eef983441814aba0f1a 100644
|
| --- a/third_party/WebKit/Source/core/page/scrolling/StickyPositionScrollingConstraints.h
|
| +++ b/third_party/WebKit/Source/core/page/scrolling/StickyPositionScrollingConstraints.h
|
| @@ -6,9 +6,12 @@
|
| #define StickyPositionScrollingConstraints_h
|
|
|
| #include "platform/geometry/FloatRect.h"
|
| +#include "platform/geometry/FloatSize.h"
|
|
|
| namespace blink {
|
|
|
| +class LayoutBoxModelObject;
|
| +
|
| class StickyPositionScrollingConstraints final {
|
| public:
|
| enum AnchorEdgeFlags {
|
| @@ -24,7 +27,9 @@ class StickyPositionScrollingConstraints final {
|
| m_leftOffset(0),
|
| m_rightOffset(0),
|
| m_topOffset(0),
|
| - m_bottomOffset(0) {}
|
| + m_bottomOffset(0),
|
| + m_nearestStickyElementToContainingBlock(nullptr),
|
| + m_nearestStickyElementFromContainingBlockToViewport(nullptr) {}
|
|
|
| StickyPositionScrollingConstraints(
|
| const StickyPositionScrollingConstraints& other)
|
| @@ -36,9 +41,22 @@ class StickyPositionScrollingConstraints final {
|
| m_scrollContainerRelativeContainingBlockRect(
|
| other.m_scrollContainerRelativeContainingBlockRect),
|
| m_scrollContainerRelativeStickyBoxRect(
|
| - other.m_scrollContainerRelativeStickyBoxRect) {}
|
| + other.m_scrollContainerRelativeStickyBoxRect),
|
| + m_nearestStickyElementToContainingBlock(
|
| + other.m_nearestStickyElementToContainingBlock),
|
| + m_nearestStickyElementFromContainingBlockToViewport(
|
| + other.m_nearestStickyElementFromContainingBlockToViewport),
|
| + m_cachedAccumulatedStickyOffset(other.m_cachedAccumulatedStickyOffset) {
|
| + }
|
|
|
| - FloatSize computeStickyOffset(const FloatRect& viewportRect) const;
|
| + FloatSize computeStickyOffset(const FloatRect& viewportRect,
|
| + const FloatSize& accumulatedToCB,
|
| + const FloatSize& accumulatedToVP);
|
| +
|
| + bool hasAncestorStickyElement() {
|
| + return m_nearestStickyElementToContainingBlock ||
|
| + m_nearestStickyElementFromContainingBlockToViewport;
|
| + }
|
|
|
| AnchorEdges anchorEdges() const { return m_anchorEdges; }
|
| bool hasAnchorEdge(AnchorEdgeFlags flag) const {
|
| @@ -71,6 +89,26 @@ class StickyPositionScrollingConstraints final {
|
| return m_scrollContainerRelativeStickyBoxRect;
|
| }
|
|
|
| + void setNearestStickyElementToContainingBlock(LayoutBoxModelObject* layer) {
|
| + m_nearestStickyElementToContainingBlock = layer;
|
| + }
|
| + const LayoutBoxModelObject* nearestStickyElementToContainingBlock() {
|
| + return m_nearestStickyElementToContainingBlock;
|
| + }
|
| +
|
| + void setNearestStickyElementFromContainingBlockToViewport(
|
| + LayoutBoxModelObject* layer) {
|
| + m_nearestStickyElementFromContainingBlockToViewport = layer;
|
| + }
|
| + const LayoutBoxModelObject*
|
| + nearestStickyElementFromContainingBlockToViewport() {
|
| + return m_nearestStickyElementFromContainingBlockToViewport;
|
| + }
|
| +
|
| + const FloatSize& getCachedAccumulatedStickyOffset() {
|
| + return m_cachedAccumulatedStickyOffset;
|
| + }
|
| +
|
| bool operator==(const StickyPositionScrollingConstraints& other) const {
|
| return m_leftOffset == other.m_leftOffset &&
|
| m_rightOffset == other.m_rightOffset &&
|
| @@ -79,7 +117,13 @@ class StickyPositionScrollingConstraints final {
|
| m_scrollContainerRelativeContainingBlockRect ==
|
| other.m_scrollContainerRelativeContainingBlockRect &&
|
| m_scrollContainerRelativeStickyBoxRect ==
|
| - other.m_scrollContainerRelativeStickyBoxRect;
|
| + other.m_scrollContainerRelativeStickyBoxRect &&
|
| + m_nearestStickyElementToContainingBlock ==
|
| + other.m_nearestStickyElementToContainingBlock &&
|
| + m_nearestStickyElementFromContainingBlockToViewport ==
|
| + other.m_nearestStickyElementFromContainingBlockToViewport &&
|
| + m_cachedAccumulatedStickyOffset ==
|
| + other.m_cachedAccumulatedStickyOffset;
|
| }
|
|
|
| bool operator!=(const StickyPositionScrollingConstraints& other) const {
|
| @@ -94,6 +138,17 @@ class StickyPositionScrollingConstraints final {
|
| float m_bottomOffset;
|
| FloatRect m_scrollContainerRelativeContainingBlockRect;
|
| FloatRect m_scrollContainerRelativeStickyBoxRect;
|
| +
|
| + // In order to properly compute the stickyOffset, we need to know if we have
|
| + // any sticky ancestors both between ourselves and our containingBlock and
|
| + // between our containingBlock and the viewport.
|
| + //
|
| + // Any such ancestors are computed at layout time, and then the accumulated
|
| + // offset from them is recomputed after each scroll update.
|
| + LayoutBoxModelObject* m_nearestStickyElementToContainingBlock;
|
| + LayoutBoxModelObject* m_nearestStickyElementFromContainingBlockToViewport;
|
| +
|
| + FloatSize m_cachedAccumulatedStickyOffset;
|
| };
|
|
|
| } // namespace blink
|
|
|