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

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

Issue 1870663002: Reland main thread position sticky implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Only descend into children which have an ancestor overflow layer. Created 4 years, 8 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_anchorEdges(0)
24 , m_leftOffset(0)
25 , m_rightOffset(0)
26 , m_topOffset(0)
27 , m_bottomOffset(0)
28 { }
29
30 StickyPositionScrollingConstraints(const StickyPositionScrollingConstraints& other)
31 : m_anchorEdges(other.m_anchorEdges)
32 , m_leftOffset(other.m_leftOffset)
33 , m_rightOffset(other.m_rightOffset)
34 , m_topOffset(other.m_topOffset)
35 , m_bottomOffset(other.m_bottomOffset)
36 , m_scrollContainerRelativeContainingBlockRect(other.m_scrollContainerRe lativeContainingBlockRect)
37 , m_scrollContainerRelativeStickyBoxRect(other.m_scrollContainerRelative StickyBoxRect)
38 { }
39
40 FloatSize computeStickyOffset(const FloatRect& viewportRect) const;
41
42 AnchorEdges anchorEdges() const { return m_anchorEdges; }
43 bool hasAnchorEdge(AnchorEdgeFlags flag) const { return m_anchorEdges & flag ; }
44 void addAnchorEdge(AnchorEdgeFlags edgeFlag) { m_anchorEdges |= edgeFlag; }
45 void setAnchorEdges(AnchorEdges edges) { m_anchorEdges = edges; }
46
47 float leftOffset() const { return m_leftOffset; }
48 float rightOffset() const { return m_rightOffset; }
49 float topOffset() const { return m_topOffset; }
50 float bottomOffset() const { return m_bottomOffset; }
51
52 void setLeftOffset(float offset) { m_leftOffset = offset; }
53 void setRightOffset(float offset) { m_rightOffset = offset; }
54 void setTopOffset(float offset) { m_topOffset = offset; }
55 void setBottomOffset(float offset) { m_bottomOffset = offset; }
56
57 void setScrollContainerRelativeContainingBlockRect(const FloatRect& rect) { m_scrollContainerRelativeContainingBlockRect = rect; }
58
59 void setScrollContainerRelativeStickyBoxRect(const FloatRect& rect) { m_scro llContainerRelativeStickyBoxRect = rect; }
60
61 bool operator==(const StickyPositionScrollingConstraints& other) const
62 {
63 return m_leftOffset == other.m_leftOffset
64 && m_rightOffset == other.m_rightOffset
65 && m_topOffset == other.m_topOffset
66 && m_bottomOffset == other.m_bottomOffset
67 && m_scrollContainerRelativeContainingBlockRect == other.m_scrollCon tainerRelativeContainingBlockRect
68 && m_scrollContainerRelativeStickyBoxRect == other.m_scrollContainer RelativeStickyBoxRect;
69 }
70
71 bool operator!=(const StickyPositionScrollingConstraints& other) const { ret urn !(*this == other); }
72
73 private:
74 AnchorEdges m_anchorEdges;
75 float m_leftOffset;
76 float m_rightOffset;
77 float m_topOffset;
78 float m_bottomOffset;
79 FloatRect m_scrollContainerRelativeContainingBlockRect;
80 FloatRect m_scrollContainerRelativeStickyBoxRect;
81 };
82
83 } // namespace blink
84
85 #endif // StickyPositionScrollingConstraints_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698