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

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

Issue 1308273010: Adapt and reland old position sticky implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: WIP - fix on release, still hits CHECK in LayoutGeometryMap.cpp:156 Created 4 years, 9 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "core/page/scrolling/StickyPositionScrollingConstraints.h"
6
7 namespace blink {
8
9 FloatSize StickyPositionScrollingConstraints::computeStickyOffset(const FloatRec t& viewportRect) const
10 {
11 FloatRect boxRect = m_scrollContainerRelativeStickyBoxRect;
12
13 if (hasAnchorEdge(AnchorEdgeRight)) {
14 float rightLimit = viewportRect.maxX() - m_rightOffset;
15 float rightDelta = std::min<float>(0, rightLimit - m_scrollContainerRela tiveStickyBoxRect.maxX());
16 float availableSpace = std::min<float>(0, m_scrollContainerRelativeConta iningBlockRect.x() - m_scrollContainerRelativeStickyBoxRect.x());
17 if (rightDelta < availableSpace)
18 rightDelta = availableSpace;
19
20 boxRect.move(rightDelta, 0);
21 }
22
23 if (hasAnchorEdge(AnchorEdgeLeft)) {
24 float leftLimit = viewportRect.x() + m_leftOffset;
25 float leftDelta = std::max<float>(0, leftLimit - m_scrollContainerRelati veStickyBoxRect.x());
26 float availableSpace = std::max<float>(0, m_scrollContainerRelativeConta iningBlockRect.maxX() - m_scrollContainerRelativeStickyBoxRect.maxX());
27 if (leftDelta > availableSpace)
28 leftDelta = availableSpace;
29
30 boxRect.move(leftDelta, 0);
31 }
32
33 if (hasAnchorEdge(AnchorEdgeBottom)) {
34 float bottomLimit = viewportRect.maxY() - m_bottomOffset;
35 float bottomDelta = std::min<float>(0, bottomLimit - m_scrollContainerRe lativeStickyBoxRect.maxY());
36 float availableSpace = std::min<float>(0, m_scrollContainerRelativeConta iningBlockRect.y() - m_scrollContainerRelativeStickyBoxRect.y());
37 if (bottomDelta < availableSpace)
38 bottomDelta = availableSpace;
39
40 boxRect.move(0, bottomDelta);
41 }
42
43 if (hasAnchorEdge(AnchorEdgeTop)) {
44 float topLimit = viewportRect.y() + m_topOffset;
45 float topDelta = std::max<float>(0, topLimit - m_scrollContainerRelative StickyBoxRect.y());
46 float availableSpace = std::max<float>(0, m_scrollContainerRelativeConta iningBlockRect.maxY() - m_scrollContainerRelativeStickyBoxRect.maxY());
47 if (topDelta > availableSpace)
48 topDelta = availableSpace;
49
50 boxRect.move(0, topDelta);
51 }
52
53 return boxRect.location() - m_scrollContainerRelativeStickyBoxRect.location( );
54 }
55
56 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698