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

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

Issue 1308273010: Adapt and reland old position sticky implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: WIP - Cache sticky constraints on ancestor PaintLayerScrollableArea. Created 4 years, 10 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 #ifndef StickyPositionScrollingConstraints_h
6 #define StickyPositionScrollingConstraints_h
7
8 #include "platform/geometry/FloatRect.h"
9
10 namespace blink {
11
12 class StickyPositionScrollingConstraints final {
13 public:
14 enum AnchorEdgeFlags {
15 AnchorEdgeLeft = 1 << 0,
16 AnchorEdgeRight = 1 << 1,
17 AnchorEdgeTop = 1 << 2,
18 AnchorEdgeBottom = 1 << 3
19 };
20 typedef unsigned AnchorEdges;
21
22 StickyPositionScrollingConstraints()
23 : m_leftOffset(0)
24 , m_rightOffset(0)
25 , m_topOffset(0)
26 , m_bottomOffset(0)
27 { }
28
29 StickyPositionScrollingConstraints(const StickyPositionScrollingConstraints& other)
30 : m_anchorEdges(0)
31 , m_leftOffset(other.m_leftOffset)
32 , m_rightOffset(other.m_rightOffset)
33 , m_topOffset(other.m_topOffset)
34 , m_bottomOffset(other.m_bottomOffset)
35 , m_scrollContainerRelativeContainingBlockRect(other.m_scrollContainerRe lativeContainingBlockRect)
36 , m_scrollContainerRelativeStickyBoxRect(other.m_scrollContainerRelative StickyBoxRect)
37 { }
38
39 FloatSize computeStickyOffset(const FloatRect& viewportRect) const;
40
41 AnchorEdges anchorEdges() const { return m_anchorEdges; }
42 bool hasAnchorEdge(AnchorEdgeFlags flag) const { return m_anchorEdges & flag ; }
43 void addAnchorEdge(AnchorEdgeFlags edgeFlag) { m_anchorEdges |= edgeFlag; }
44 void setAnchorEdges(AnchorEdges edges) { m_anchorEdges = edges; }
45
46 float leftOffset() const { return m_leftOffset; }
47 float rightOffset() const { return m_rightOffset; }
48 float topOffset() const { return m_topOffset; }
49 float bottomOffset() const { return m_bottomOffset; }
50
51 void setLeftOffset(float offset) { m_leftOffset = offset; }
52 void setRightOffset(float offset) { m_rightOffset = offset; }
53 void setTopOffset(float offset) { m_topOffset = offset; }
54 void setBottomOffset(float offset) { m_bottomOffset = offset; }
55
56 void setScrollContainerRelativeContainingBlockRect(const FloatRect& rect) { m_scrollContainerRelativeContainingBlockRect = rect; }
57
58 void setScrollContainerRelativeStickyBoxRect(const FloatRect& rect) { m_scro llContainerRelativeStickyBoxRect = rect; }
59
60 bool operator==(const StickyPositionScrollingConstraints& other) const
61 {
62 return m_leftOffset == other.m_leftOffset
63 && m_rightOffset == other.m_rightOffset
64 && m_topOffset == other.m_topOffset
65 && m_bottomOffset == other.m_bottomOffset
66 && m_scrollContainerRelativeContainingBlockRect == other.m_scrollCon tainerRelativeContainingBlockRect
67 && m_scrollContainerRelativeStickyBoxRect == other.m_scrollContainer RelativeStickyBoxRect;
68 }
69
70 bool operator!=(const StickyPositionScrollingConstraints& other) const { ret urn !(*this == other); }
71
72 private:
73 AnchorEdges m_anchorEdges;
74 float m_leftOffset;
75 float m_rightOffset;
76 float m_topOffset;
77 float m_bottomOffset;
78 FloatRect m_scrollContainerRelativeContainingBlockRect;
79 FloatRect m_scrollContainerRelativeStickyBoxRect;
80 };
81
82 } // namespace blink
83
84 #endif // StickyPositionScrollingConstraints_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698