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

Unified Diff: third_party/WebKit/Source/core/page/scrolling/StickyPositionScrollingConstraints.cpp

Issue 2636253002: Handle nested position:sticky elements (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/page/scrolling/StickyPositionScrollingConstraints.cpp
diff --git a/third_party/WebKit/Source/core/page/scrolling/StickyPositionScrollingConstraints.cpp b/third_party/WebKit/Source/core/page/scrolling/StickyPositionScrollingConstraints.cpp
index d0c2d01708f9e499bcf3344607592d95753dd366..baab3681331483d8648f3381327bcba1dd2f9045 100644
--- a/third_party/WebKit/Source/core/page/scrolling/StickyPositionScrollingConstraints.cpp
+++ b/third_party/WebKit/Source/core/page/scrolling/StickyPositionScrollingConstraints.cpp
@@ -7,16 +7,27 @@
namespace blink {
FloatSize StickyPositionScrollingConstraints::computeStickyOffset(
- const FloatRect& viewportRect) const {
- FloatRect boxRect = m_scrollContainerRelativeStickyBoxRect;
+ const FloatRect& viewportRect,
+ const FloatSize& accumulatedToCB,
+ const FloatSize& accumulatedToVP) {
+ // TODO(smcgruer): Explain what this is doing.
+ // TODO(smcgruer): Determine which we need to move for what (fairly sure
+ // moving both by both is incorrect, but currently done because I don't
flackr 2017/01/18 14:42:56 I think the stickyBoxRect does need to be moved by
smcgruer 2017/01/19 19:28:01 Done.
+ // accumulate properly.)
+ FloatRect stickyBoxRect = m_scrollContainerRelativeStickyBoxRect;
+ FloatRect containingBlockRect = m_scrollContainerRelativeContainingBlockRect;
+ stickyBoxRect.move(accumulatedToCB);
+ stickyBoxRect.move(accumulatedToVP);
+ containingBlockRect.move(accumulatedToCB);
flackr 2017/01/18 14:42:56 The containing block rect should only be moved by
smcgruer 2017/01/19 19:28:01 Done.
+ containingBlockRect.move(accumulatedToVP);
+
+ FloatRect boxRect = stickyBoxRect;
if (hasAnchorEdge(AnchorEdgeRight)) {
float rightLimit = viewportRect.maxX() - m_rightOffset;
- float rightDelta = std::min<float>(
- 0, rightLimit - m_scrollContainerRelativeStickyBoxRect.maxX());
+ float rightDelta = std::min<float>(0, rightLimit - stickyBoxRect.maxX());
float availableSpace =
- std::min<float>(0, m_scrollContainerRelativeContainingBlockRect.x() -
- m_scrollContainerRelativeStickyBoxRect.x());
+ std::min<float>(0, containingBlockRect.x() - stickyBoxRect.x());
if (rightDelta < availableSpace)
rightDelta = availableSpace;
@@ -25,11 +36,9 @@ FloatSize StickyPositionScrollingConstraints::computeStickyOffset(
if (hasAnchorEdge(AnchorEdgeLeft)) {
float leftLimit = viewportRect.x() + m_leftOffset;
- float leftDelta = std::max<float>(
- 0, leftLimit - m_scrollContainerRelativeStickyBoxRect.x());
+ float leftDelta = std::max<float>(0, leftLimit - stickyBoxRect.x());
float availableSpace =
- std::max<float>(0, m_scrollContainerRelativeContainingBlockRect.maxX() -
- m_scrollContainerRelativeStickyBoxRect.maxX());
+ std::max<float>(0, containingBlockRect.maxX() - stickyBoxRect.maxX());
if (leftDelta > availableSpace)
leftDelta = availableSpace;
@@ -38,11 +47,9 @@ FloatSize StickyPositionScrollingConstraints::computeStickyOffset(
if (hasAnchorEdge(AnchorEdgeBottom)) {
float bottomLimit = viewportRect.maxY() - m_bottomOffset;
- float bottomDelta = std::min<float>(
- 0, bottomLimit - m_scrollContainerRelativeStickyBoxRect.maxY());
+ float bottomDelta = std::min<float>(0, bottomLimit - stickyBoxRect.maxY());
float availableSpace =
- std::min<float>(0, m_scrollContainerRelativeContainingBlockRect.y() -
- m_scrollContainerRelativeStickyBoxRect.y());
+ std::min<float>(0, containingBlockRect.y() - stickyBoxRect.y());
if (bottomDelta < availableSpace)
bottomDelta = availableSpace;
@@ -51,18 +58,23 @@ FloatSize StickyPositionScrollingConstraints::computeStickyOffset(
if (hasAnchorEdge(AnchorEdgeTop)) {
float topLimit = viewportRect.y() + m_topOffset;
- float topDelta = std::max<float>(
- 0, topLimit - m_scrollContainerRelativeStickyBoxRect.y());
+ float topDelta = std::max<float>(0, topLimit - stickyBoxRect.y());
float availableSpace =
- std::max<float>(0, m_scrollContainerRelativeContainingBlockRect.maxY() -
- m_scrollContainerRelativeStickyBoxRect.maxY());
+ std::max<float>(0, containingBlockRect.maxY() - stickyBoxRect.maxY());
+
if (topDelta > availableSpace)
topDelta = availableSpace;
boxRect.move(0, topDelta);
}
- return boxRect.location() - m_scrollContainerRelativeStickyBoxRect.location();
+ FloatSize stickyOffset = boxRect.location() - stickyBoxRect.location();
+
+ // TODO(smcgruer): Determine what exactly we need to accumulate.
+ m_cachedAccumulatedStickyOffset.setWidth(stickyOffset.width());
+ m_cachedAccumulatedStickyOffset.setHeight(stickyOffset.height());
flackr 2017/01/18 14:42:56 I think we need to add the ToCB and ToVP offsets h
+
+ return stickyOffset;
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698