| 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..60d12fa15bc894d8032bb4b69bd2a5800726fa9d 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_nearestStickyElementShiftingStickyBox(nullptr),
|
| + m_nearestStickyElementShiftingContainingBlock(nullptr) {}
|
|
|
| StickyPositionScrollingConstraints(
|
| const StickyPositionScrollingConstraints& other)
|
| @@ -36,9 +41,25 @@ class StickyPositionScrollingConstraints final {
|
| m_scrollContainerRelativeContainingBlockRect(
|
| other.m_scrollContainerRelativeContainingBlockRect),
|
| m_scrollContainerRelativeStickyBoxRect(
|
| - other.m_scrollContainerRelativeStickyBoxRect) {}
|
| -
|
| - FloatSize computeStickyOffset(const FloatRect& viewportRect) const;
|
| + other.m_scrollContainerRelativeStickyBoxRect),
|
| + m_nearestStickyElementShiftingStickyBox(
|
| + other.m_nearestStickyElementShiftingStickyBox),
|
| + m_nearestStickyElementShiftingContainingBlock(
|
| + other.m_nearestStickyElementShiftingContainingBlock),
|
| + m_totalStickyBoxStickyOffset(other.m_totalStickyBoxStickyOffset),
|
| + m_totalContainingBlockStickyOffset(
|
| + other.m_totalContainingBlockStickyOffset),
|
| + m_cachedComputedStickyOffset(other.m_cachedComputedStickyOffset) {}
|
| +
|
| + FloatSize computeStickyOffset(
|
| + const FloatRect& viewportRect,
|
| + StickyPositionScrollingConstraints* ancestorStickyBoxConstraints,
|
| + StickyPositionScrollingConstraints* ancestorContainingBlockConstraints);
|
| +
|
| + bool hasAncestorStickyElement() const {
|
| + return m_nearestStickyElementShiftingStickyBox ||
|
| + m_nearestStickyElementShiftingContainingBlock;
|
| + }
|
|
|
| AnchorEdges anchorEdges() const { return m_anchorEdges; }
|
| bool hasAnchorEdge(AnchorEdgeFlags flag) const {
|
| @@ -71,6 +92,32 @@ class StickyPositionScrollingConstraints final {
|
| return m_scrollContainerRelativeStickyBoxRect;
|
| }
|
|
|
| + void setNearestStickyElementShiftingStickyBox(LayoutBoxModelObject* layer) {
|
| + m_nearestStickyElementShiftingStickyBox = layer;
|
| + }
|
| + LayoutBoxModelObject* nearestStickyElementShiftingStickyBox() const {
|
| + return m_nearestStickyElementShiftingStickyBox;
|
| + }
|
| +
|
| + void setNearestStickyElementShiftingContainingBlock(
|
| + LayoutBoxModelObject* layer) {
|
| + m_nearestStickyElementShiftingContainingBlock = layer;
|
| + }
|
| + LayoutBoxModelObject* nearestStickyElementShiftingContainingBlock() const {
|
| + return m_nearestStickyElementShiftingContainingBlock;
|
| + }
|
| +
|
| + const FloatSize& getTotalStickyBoxStickyOffset() const {
|
| + return m_totalStickyBoxStickyOffset;
|
| + }
|
| + const FloatSize& getTotalContainingBlockStickyOffset() const {
|
| + return m_totalContainingBlockStickyOffset;
|
| + }
|
| +
|
| + const FloatSize& getCachedComputedStickyOffset() const {
|
| + return m_cachedComputedStickyOffset;
|
| + }
|
| +
|
| bool operator==(const StickyPositionScrollingConstraints& other) const {
|
| return m_leftOffset == other.m_leftOffset &&
|
| m_rightOffset == other.m_rightOffset &&
|
| @@ -79,7 +126,15 @@ class StickyPositionScrollingConstraints final {
|
| m_scrollContainerRelativeContainingBlockRect ==
|
| other.m_scrollContainerRelativeContainingBlockRect &&
|
| m_scrollContainerRelativeStickyBoxRect ==
|
| - other.m_scrollContainerRelativeStickyBoxRect;
|
| + other.m_scrollContainerRelativeStickyBoxRect &&
|
| + m_nearestStickyElementShiftingStickyBox ==
|
| + other.m_nearestStickyElementShiftingStickyBox &&
|
| + m_nearestStickyElementShiftingContainingBlock ==
|
| + other.m_nearestStickyElementShiftingContainingBlock &&
|
| + m_totalStickyBoxStickyOffset == other.m_totalStickyBoxStickyOffset &&
|
| + m_totalContainingBlockStickyOffset ==
|
| + other.m_totalContainingBlockStickyOffset &&
|
| + m_cachedComputedStickyOffset == other.m_cachedComputedStickyOffset;
|
| }
|
|
|
| bool operator!=(const StickyPositionScrollingConstraints& other) const {
|
| @@ -94,6 +149,28 @@ 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 containing block and
|
| + // between our containing block and the viewport. These ancestors are needed
|
| + // to properly shift our constraining rects with regards to the containing
|
| + // block and viewport.
|
| + LayoutBoxModelObject* m_nearestStickyElementShiftingStickyBox;
|
| + LayoutBoxModelObject* m_nearestStickyElementShiftingContainingBlock;
|
| +
|
| + // For performance we cache our accumulated sticky offset to allow descendant
|
| + // sticky elements to offset their constraint rects. Because we can either
|
| + // affect the sticky box constraint rect or the containing block constraint
|
| + // rect, we need to accumulate both.
|
| + //
|
| + // The case where we can affect both the sticky box constraint rect and the
|
| + // constraining block constriant rect for different sticky descendants is
|
| + // quite complex. See the StickyPositionComplexTableNesting test in
|
| + // LayoutBoxModelObjectTest.cpp.
|
| + FloatSize m_totalStickyBoxStickyOffset;
|
| + FloatSize m_totalContainingBlockStickyOffset;
|
| +
|
| + FloatSize m_cachedComputedStickyOffset;
|
| };
|
|
|
| } // namespace blink
|
|
|